// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。
//
#include <windows.h>
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <random>
int main(int argc, char* argv[])
{
int hash[42] = {
0x63B25AF1, 0xC5659BA5, 0x4C7A3C33, 0x0E4E4267, 0xB611769B, 0x3DE6438C, 0x84DBA61F, 0xA97497E6,
0x650F0FB3, 0x84EB507C, 0xD38CD24C, 0xE7B912E0, 0x7976CD4F, 0x84100010, 0x7FD66745, 0x711D4DBF,
0x5402A7E5, 0xA3334351, 0x1EE41BF8, 0x22822EBE, 0xDF5CEE48, 0xA8180D59, 0x1576DEDC, 0xF0D62B3B,
0x32AC1F6E, 0x9364A640, 0xC282DD35, 0x14C5FC2E, 0xA765E438, 0x7FCF345A, 0x59032BAD, 0x9A5600BE,
0x5F472DC5, 0x5DDE0D84, 0x8DF94ED5, 0xBDF826A6, 0x515A737A, 0x4248589E, 0x38A96C20, 0xCC7F61D9,
0x2638C417, 0xD9BEB996
};
//
//先算出第一个 rand 值
//
unsigned int i = 1;
unsigned int result;
while (i < UINT_MAX)
{
__asm{
mov eax, i //rand
mov ecx, 66h //'f'
mul ecx
mov ecx, 0xFAC96621
push eax
xor edx, edx
div ecx
pop eax
push edx
mul eax
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
pop edx
mul edx
div ecx
mov result, edx;
}
if (result == hash[0])
{
printf("first rand = %x\n", i);
break;
}
i++;
}
//
//反推算出 srand值
//
for (unsigned int i = 1; i < UINT_MAX; i++)
{
int random = 0x31333359 + i; //此值固定 nt函数returnlen,xor常量 ,xor OEP第一个字节
srand(random);
if (rand() == 0x4077) // first rand
{
printf("srand = %x strHexCount = %x\n", random, i);
break;
}
}
//
//得出flags
//
srand(0x31333d38);
int randnum;
for (int i = 0; i < 42; i++)
{
randnum = rand();
for (char c = 1; c <= 0xff; c++)
{
__asm{
mov eax, randnum //rand
xor ecx, ecx
movzx ecx, c //'f'
mul ecx
mov ecx, 0xFAC96621
push eax
xor edx, edx
div ecx
pop eax
push edx
mul eax
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
mul edx
div ecx
mov eax, edx
pop edx
mul edx
div ecx
mov result, edx;
}
if (result == hash[i])
{
printf("%c", c);
break;
}
}
}
getchar();
return 0;
}