青青子衿wp
#include<iostream>#include<Windows.h>
#include<tchar.h>
using namespace std;
#if _MSC_VER < 1600
void __cpuidex(INT32 CPUInfo, INT32 InfoType, INT32 ECXValue)
{
if (NULL == CPUInfo) return;
_asm {
// load. 读取参数到寄存器
mov edi, CPUInfo; // 准备用edi寻址CPUInfo
mov eax, InfoType;
mov ecx, ECXValue;
// CPUID
cpuid;
// save. 将寄存器保存到CPUInfo
mov, eax;
mov, ebx;
mov, ecx;
mov, edx;
}
}
#endif
void _strcat(char* str, int num)//字符串拼接算法
{
int temp = 0;
int i = 0;
while (*str != NULL)
{
str++;
}
*str = 0x2D;
for (i = 4; i > 0; i--)
{
temp = num % 0xA;
str = temp + '0';
num = num / 0xA;
}
}
void _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int cx = 0;
int ax = 0;
int dx = 0;
char name = { 0 };//用户名
char key = { 0 };//生成的key
int i = 0;
int temp = 0;
int temp1 = 0;
char* pstr = NULL;//处理寄存器高低位 游走指针
//memcpy(name, "CTFHUB", sizeof("CTFHUB"));
memset(key, 0, 20);
scanf_s("%s", name, 0x2D);
temp = strlen(name);
dx = name * name;
cx = 2;
temp = temp / cx;
cx = name;
dx = dx * cx;
memcpy(key, "HNT", sizeof("HNT"));
_strcat(key, dx);
TCHAR ComputerName = { 0 };
DWORD Size = 0x1E;
GetComputerName((LPTSTR)ComputerName, &Size);
pstr = (char*)&ComputerName;
temp = 0;
while (*pstr != 0)
{
temp += *pstr;
pstr++;
}
cx = strlen(name);
temp = cx;
name = '\0';//还原字符串后面的'\0'
for (i = cx; i > 0; i--)
{
name = name;
}
name = 0xdc;
dx = 0;
while (cx != 0)
{
pstr = (char*)&dx;//dl=name
*pstr = name;
dx = dx * cx;
temp += dx;
cx--;
}
INT32 dwBuf = { 0 };
__cpuidex(dwBuf, 0, 1);
char szTmp = { NULL };
sprintf_s(szTmp, "%08X %08X%08X %08X", dwBuf, dwBuf, dwBuf, dwBuf);
temp = temp & dwBuf;
_strcat(key, temp);
pstr = name;
pstr++;
do
{
ax = *pstr;
pstr++;
temp += ax;
} while (ax != 0);
temp = temp ^ dwBuf;
temp = temp | dwBuf;
temp1 = temp;
pstr = name;
pstr++;
temp1 = *pstr++;
temp1 = temp1 * (*pstr);
temp1 *= temp;
_strcat(key, temp1);
pstr = name;
temp = 0;
pstr++;
do
{
ax = *pstr;
pstr++;
temp += ax;
} while (ax != 0);
dx = temp % 0x1A;
ax = 0x41 + dx;
cx = strlen(name) - 1;
temp = cx;
while (cx != 0)
{
pstr = (char*)&dx;//dl=name
*pstr = name;
dx = dx * cx;
temp += dx;
cx--;
}
dx = (temp % 0x1A) + 0x41;
cx = strlen(name) - 1;
pstr = key;
while (*pstr != NULL)
{
pstr++;
}
*(pstr) = 0x2D;
char* v1;
v1 = (char*)&ax;
*(pstr + 1) = *v1;//*(pstr+1)=al
v1 = (char*)&dx;
*(pstr + 2) = *v1;//*(pstr+2)=dl
*(pstr + 3) = '\0';//字符串末尾
printf("%s", key);
}
页:
[1]