学逆向论坛

找回密码
立即注册

只需一步,快速开始

发新帖

2万

积分

41

好友

1157

主题

[Reverse] 青青子衿wp

发表于 2021-3-29 11:42:27 | 查看: 2145| 回复: 0

相关题目:

♦ 青青子衿

#include<iostream>
#include<Windows.h>
#include<tchar.h>
using namespace std;
#if _MSC_VER < 1600   
void __cpuidex(INT32 CPUInfo[4], 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[edi], eax;
        mov[edi + 4], ebx;
        mov[edi + 8], ecx;
        mov[edi + 12], 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[i] = temp + '0';
        num = num / 0xA;
    }
}
void _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
    int cx = 0;
    int ax = 0;
    int dx = 0;
    char name[0x2D] = { 0 };//用户名
    char key[26] = { 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[0] * name[temp - 1];

    cx = 2;
    temp = temp / cx;
    cx = name[temp];
    dx = dx * cx;

    memcpy(key, "HNT", sizeof("HNT"));
    _strcat(key, dx);

    TCHAR ComputerName[0x1E] = { 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[cx + 1] = '\0';//还原字符串后面的'\0'
    for (i = cx; i > 0; i--)
    {
        name[i] = name[i - 1];
    }
    name[0] = 0xdc;
    dx = 0;
    while (cx != 0)
    {
        pstr = (char*)&dx;//dl=name[cx]
        *pstr = name[cx];
        dx = dx * cx;
        temp += dx;
        cx--;
    }

    INT32 dwBuf[4] = { 0 };
    __cpuidex(dwBuf, 0, 1);
    char szTmp[60] = { NULL };
    sprintf_s(szTmp, "%08X   %08X  %08X   %08X", dwBuf[0], dwBuf[1], dwBuf[2], dwBuf[3]);

    temp = temp & dwBuf[1];
    _strcat(key, temp);

    pstr = name;
    pstr++;
    do
    {
        ax = *pstr;
        pstr++;
        temp += ax;
    } while (ax != 0);
    temp = temp ^ dwBuf[3];
    temp = temp | dwBuf[2];

    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[cx]
        *pstr = name[cx];
        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.如果您喜欢这篇帖子,请给作者点赞评分,点赞会增加帖子的热度,评分会给作者加学币。(评分不会扣掉您的积分,系统每天都会重置您的评分额度)。
2.回复帖子不仅是对作者的认可,还可以获得学币奖励,请尊重他人的劳动成果,拒绝做伸手党!
3.发广告、灌水回复等违规行为一经发现直接禁言,如果本帖内容涉嫌违规,请点击论坛底部的举报反馈按钮,也可以在【投诉建议】板块发帖举报。
论坛交流群:672619046

小黑屋|手机版|站务邮箱|学逆向论坛 ( 粤ICP备2021023307号 )|网站地图

GMT+8, 2024-4-26 14:52 , Processed in 0.090692 second(s), 37 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表