反调试--CRC检测
阅读原文时间:2021年10月10日阅读:1

#include"CRC32.h"
#include
#include
using namespace std;
void test1()
{
int a = 1;
cout << "1111111111111111111111" << endl; } void Crc32Test() { char *buffer=(char*)GetModuleHandleA(0);//参数为0就获取当前进程的句柄 PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)buffer; PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)(pDosHeader->e_lfanew + buffer);
PIMAGE_SECTION_HEADER pSectionHeader = IMAGE_FIRST_SECTION(pNtHeader);
for (int i = 0; i < pNtHeader->FileHeader.NumberOfSections - 1; i++)
{
if (pSectionHeader->Characteristics / 0x10000000 == 6)
{
cout << pSectionHeader->Name << endl; auto CrcNum = make_crc((unsigned char*)(pSectionHeader->VirtualAddress + buffer), pSectionHeader->Misc.VirtualSize);
cout << CrcNum << endl;
}
pSectionHeader++;
}
}
int main()
{
Crc32Test();
system("pause");
return 0;
}

头文件:

#pragma once
#include
uint32_t crc32_table[256];

int make_crc32_table()
{
uint32_t c;
int i = 0;
int bit = 0;

for (i = 0; i < 256; i++)  
{  
    c = (uint32\_t)i;

    for (bit = 0; bit < 8; bit++)  
    {  
        if (c & 1)  
        {  
            c = (c >> 1) ^ (0xEDB88320);  
        }  
        else  
        {  
            c = c >> 1;  
        }

    }  
    crc32\_table\[i\] = c;  
}

return 1;  

}
uint32_t make_crc(unsigned char* string, uint32_t size)
{
uint32_t crc = 0xFFFFFFFF;
make_crc32_table();
while (size--)
crc = (crc >> 8) ^ (crc32_table[(crc ^ *string++) & 0xff]);

return crc;  

}

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章