安全矩阵

 找回密码
 立即注册
搜索
查看: 2541|回复: 0

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

[复制链接]

77

主题

77

帖子

257

积分

中级会员

Rank: 3Rank: 3

积分
257
发表于 2021-10-13 17:36:33 | 显示全部楼层 |阅读模式
一、挂起线程注入

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

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

二、介绍

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

该技术非常简单:

  • [1] 使用 OpenProcess 打开远程进程
  • [2] 解密内存中的 Meterpreter Payload
  • [3] 使用 VirtualAllocEx 在远程进程中分配一些内存,确保分配正确的权限来写入内存
  • [4] 使用 WriteProcessMemory 将 Payload 写入到分配的内存中
  • [5] 使用 VirtualProtectEx 保护内存,将保护设置为 PAGE_NOACCESS
  • [6] 使用 CreateRemoteThread 创建一个新的挂起线程
  • [7] 在 Defender 扫描远程进程内存以查找恶意代码时休眠 10 秒
  • [8] 使用 VirtualProtectEx 更改对内存的保护,将保护设置为 PAGE_EXECUTE_READ_WRITE
  • [9] 使用 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:443https[:]//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 进行测试。



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|安全矩阵

GMT+8, 2025-4-22 16:26 , Processed in 0.014051 second(s), 18 queries .

Powered by Discuz! X4.0

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表