本帖最后由 洋洋不得意 于 2020-1-21 18:17 编辑
editplus 4.3
官网 https://www.editplus.com/
逆向算法后得到如下代码
[C] 纯文本查看 复制代码 #include <stdio.h>
#include <windows.h>
wchar_t table[0x100];
wchar_t word_5F73E0[0x100];
void initTable()
{
int i = 0;
for (; i < 0x100; ++i)
{
int v = i;
CharUpperW((wchar_t*)&v);
table[i] = v;
}
}
int sub_4D9470(int a, char* buff, int size)
{
if (0 == size)
return 0;
int t = a;
for (int i = 0; i < size; ++i)
{
int _esi = t & 0xff;
t = t >> 8;
_esi ^= buff[i];
t ^= word_5F73E0[_esi];
}
return t;
}
int sub_4D94B0(char* buff, int buffSize, wchar_t* str, int strSize)
{
char* t = buff;
for (int i = 0; i < strSize; ++i)
{
int wSize = sprintf_s(buff, buffSize, "%04X", str[i]);
buff += wSize;
buffSize -= wSize;
}
return buff - t;
}
void init5F73E0()
{
memset(word_5F73E0, 0, 0x200);
for (int i = 0; i < 0x100; ++i)
{
int _ecx = 1;
int _eax = 0xc0c1;
do
{
if (i & _ecx)
{
word_5F73E0[i] ^= _eax & 0xffff;
}
_eax += _eax;
_eax ^= 0x4003;
_ecx += _ecx;
} while (_ecx < 0x100);
}
}
bool compute(char* account, char* passwd)//校验算法
{
int accLenth = strlen(account);
int passwdLenth = strlen(passwd);
init5F73E0();
int computeNum = sub_4D9470(0, (char*)account, accLenth);
char buff[100];
sprintf(buff, "%02X", computeNum);
char* p = (char*)passwd;
if (p[2] != buff[0])
{
return false;
}
if (p[3] != buff[1])
{
return false;
}
computeNum = sub_4D9470(0, &p[2], passwdLenth - 2);
sprintf(buff, "%02X", computeNum);
if (p[0] != buff[0])
{
return false;
}
if (p[1] != buff[1])
{
return false;
}
return true;
}
void getPasswd(char* account, char* passwd)//注册机算法
{
int accLenth = strlen(account);
init5F73E0();
int computeNum = sub_4D9470(0, (char*)account, accLenth);
char tmp[100];
sprintf(tmp, "%02X", computeNum);
passwd[2] = tmp[0];
passwd[3] = tmp[1];
strcpy(passwd + 4, "123456");
computeNum = sub_4D9470(0, passwd + 2, 8);
sprintf(tmp, "%02X", computeNum);
passwd[0] = tmp[0];
passwd[1] = tmp[1];
for (int i = 0; i < 10; ++i)
{
char t = passwd[i];
for (int j = 0; j < 0x100; ++j)
{
if (t == table[j])
{
passwd[i] = j;
break;
}
}
}
}
int main()
{
initTable();
char account[100] = "fdas54fdsa";
char pd[100];
getPasswd(account, pd);
printf("password:%s\n", pd); return 0;
}
|