0xmalloc / knightonline

knight online server(koserver) project. full bug fixed for koserver 3.0
21 stars 28 forks source link

客户端密码加密算法 #26

Closed 0xmalloc closed 10 years ago

0xmalloc commented 10 years ago

// ConsoleApplication6.cpp : 定义控制台应用程序的入口点。 //

//#include "stdafx.h"

include

include

include

include

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[i]; } if(!ins) { return res; } } return res; }

void stepb(uint32_t ins) { uint8_t* key = (uint8t)"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 _tmain(int argc, TCHAR argv[])

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[i] + 0x3e8));
}
printf("\n");
getchar();
return 0;

}

0xmalloc commented 10 years ago

other info : http://www.snoxd.net/index.php/topic/4900-knight-online-password-encryption-description/

0xmalloc commented 10 years ago

商城直接用二级密码解决 绕过此问题