如果您想以编程方式执行此操作,您应该使用这种(或类似的)方式/功能来检测 PE 中的打包器/保护器或编译器签名,然后通过存在于已知签名数据库中的签名列表比较此签名(例如 PEiD 的“userdb.txt”)。
#include <Windows.h>
#include <iostream>
using namespace std;
IMAGE_DOS_HEADER Dos_Header;
IMAGE_FILE_HEADER Pe_Header;
IMAGE_OPTIONAL_HEADER Opt_Header;
IMAGE_SECTION_HEADER ImgSection;
DWORD sections = 0, Count = 0;
void Get_Sign(LPSTR szFileName, DWORD Lenght);
int main() {
Get_Sign(
"C:\\Program Files (x86)\\NoVirusThanks\\Smart PC Locker Pro\\NSPL.exe" /* used in this example ! */
, 399);
system("pause");
return 0;
} /* */
void Get_Sign(LPSTR szFileName, DWORD Lenght)
// Lenght=399 by defult
{
DWORD i;
HANDLE hFile;
unsigned char Buff;
DWORD Signature = 0;
DWORD EP, IVA, RAW, UNL, Offset;
DWORD BytRet;
hFile = CreateFileA((LPCSTR) szFileName, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
cout << "Error in opening file\n";
exit(0);
}
else {
ReadFile(hFile, &Dos_Header, sizeof(IMAGE_DOS_HEADER), &BytRet, NULL);
if (Dos_Header.e_magic = IMAGE_DOS_SIGNATURE) {
SetFilePointer(hFile, Dos_Header.e_lfanew, NULL, 0);
ReadFile(hFile, &Signature, sizeof(Signature), &BytRet, NULL);
if (Signature == IMAGE_NT_SIGNATURE) {
ReadFile(hFile, &Pe_Header, sizeof(Pe_Header), &BytRet, NULL);
sections = Pe_Header.NumberOfSections;
if (Pe_Header.SizeOfOptionalHeader > 0) {
ReadFile(hFile, &Opt_Header, sizeof(Opt_Header),
&BytRet, NULL);
EP = Opt_Header.AddressOfEntryPoint;
for (Count = 1; Count <= sections; Count++) {
ReadFile(hFile, &ImgSection, sizeof(ImgSection),
&BytRet, NULL);
if (EP < ImgSection.VirtualAddress +
ImgSection.SizeOfRawData)
break;
}
IVA = ImgSection.VirtualAddress;
RAW = ImgSection.PointerToRawData;
UNL = Opt_Header.SizeOfUninitializedData;
Offset = EP - IVA + RAW;
// get size of uninitialized data
// UNL = IVA - UNL;
// Offset = EP - UNL + RAW;
// get offset of signatures to read
}
for (i = Offset; i <= (Offset + Lenght); i++) {
SetFilePointer(hFile, i, NULL, 0);
ReadFile(hFile, &Buff, sizeof(Buff), &BytRet, NULL);
printf("%X", Buff);
}
cout << endl << endl;
}
}
}
}
(如果我的英语不好,请原谅)