MGAME Password Encryption Description

Knight Online private server tutorials/guides, new releases, and discussion
Post Reply
User avatar
DeadPoetic
Posts: 57
Joined: Fri Aug 17, 2018 3:45 am

Sat Aug 18, 2018 10:48 pm

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>

uint32_t stepa(uint32_t ins)
{
uint32_t res = 0;
uint32_t dat;
uint8_t* key = (uint8_t*)"\x1A\x1F\x11\x0A\x1E\x10\x18\x02\x1D\x08\x14\x0F\x1C\x0B\x0D\x04\x13\x17\x00\x0C\x0E\x1B\x06\x12\x15\x03\x09\x07\x16\x01\x19\x05\x12\x1D\x07\x19\x0F\x1F\x16\x1B\x09\x1A\x03\x0D\x13\x0E\x14\x0B\x05\x02\x17\x10\x0A\x18\x1C\x11\x06\x1E\x00\x15\x0C\x08\x04\x01";
int i;
for(i = 0;i < 64;i++)
{
dat = ins - (ins & 0xFFFFFFFE);
ins >>= 1;
if(dat)
{
res += dat << key;
}
if(!ins)
{
return res;
}
}
return res;
}

void stepb(uint32_t ins)
{
uint8_t* key = (uint8_t*)"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
uint32_t dat;
int i;
for(i = 0; i < 7; i++)
{
dat = (((uint64_t)ins) * 0x38e38e39) >> 35;
ins -= ((dat * 9) << 2);
if(ins < 36)
{
printf("%c", key[ins]);
}
ins = dat;
}
}

int main(int argc, char** argv)
{
if(argc < 2)
{
if(argc == 1)
{
printf("usage: %s password\n", argv[0]);
}
return 0;
}
uint8_t len;
uint8_t i;
uint8_t xtr;
uint32_t* dat;

len = strlen(argv[1]);
xtr = len % 4;
if(xtr)
{
xtr = 4 - xtr;
}

dat = (uint32_t*)malloc(len + xtr);
memcpy((void*)dat, (void*)argv[1], len);
if(xtr)
{
memset((void*)(((uint8_t*)dat) + len), 0, xtr);
len += xtr;
}
len /= 4;
for(i = 0; i < len; i++)
{
stepb(stepa(dat + 0x3e8));
}
printf("\n");
return 0;
}
Image
Post Reply