-
-
未解决
[求助]算法的逆推
-
发表于:
2023-11-23 11:30
2047
-
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<Windows.h>
char Str[] = "AB0CD1EF2GH3IJ4KL5MN6OP7QR8ST9UV-WX=YZ";
int sub_100010C0(const char a1[], int a2)
{
unsigned int v2 = 0;
int v3 = 0;
if (a2 <= 0)
{
return 0;
}
for (int i = 0; i < a2; i++)
{
int v5 = a1[i];
v2 |= v5;
for (int j = 0; j < 8; j++)
{
v2 *= 2;
if ((v2 & 0x1000000) != 0)
v2 ^= 0x1800500u;
}
}
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 8; j++)
{
v2 *= 2;
if ((v2 & 0x1000000) != 0)
v2 ^= 0x1800500u;
}
}
return v2 >> 8;
}
int sub_10001120(char* a1, int a2, char* a3)
{
unsigned __int8 result; // al
if (a2 <= 0)
{
return 0;
}
for (int i = 0; i < a2; i++)
{
result = a1[i];
if (a1[i] < 0x30 || result > 0x39)
{
if (result < 0x41 || result > 0x5A)
{
if (result < 0x61 || result > 0x7A)
{
continue;
}
result -= 49;
}
else
{
result -= 55;
}
}
else
{
result -= 48;
}
a3[i] = result;
}
return result;
}
int __cdecl sub_10001160(char* a1, int a2, char* a3, int a4)
{
int result; // eax
int v5 = 0;
result = a2;
if (a2 <= 0)
{
return 0;
}
for (int i = 0; i < result; i++)
{
if (v5 >= a4)
{
v5 = 0;
a3 -= a4;
}
unsigned int v8 = (unsigned int)strchr(Str, a1[i]);
unsigned int v9 = a3[i] - (DWORD)Str;
v8 = v8 + v9;
if (v8 >= 0x26)
{
v8 -= 38;
}
a1[i] = Str[v8];
++v5;
}
return 0;
}
int main()
{
char a0[] = "0";
char v11[32] = { 0 };
char v12[32] = { 0 };
char v9[32] = { "111111111119999333333" };
char v10[32] = { 0 };
char v13[32] = { 0 };
unsigned __int16 v7 = sub_100010C0(v9, strlen(v9));
wsprintfA(v11, "%04X%04X", v7, (unsigned __int16)~v7);
sub_10001120(v11, strlen(v11), v12);
sub_10001160(v9, strlen(v9), v12, strlen(v11));
strcpy(v10, (const char*)"9999");
strncpy(&v10[4], (const char*)"11111111111" + 4, 7);
sub_10001120(v10, strlen(v10), v13);
strcat(v9, v11);
sub_10001160(v9, strlen(v9), v13, strlen(v10));
char a4[50] = {};
strcpy((char*)a4, a0);
strcat((char*)a4, v9);
printf("%s", a4);
return 0;
}
这是算法的源代码。我也是从IDA拖出来的,不过运行是没问题的。怎样做才能还原出密匙呢,这份代码“9999”是密匙 “11111111111”是序列号,“333333”这个是自己的标识, 现在已知是加密过后的加密数据前4位和倒数第二次的加密数据前四位可以推算出密匙。
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
最后于 2023-11-24 09:19
被木魚·编辑
,原因: