0x01 环境简介
关于 SquirrelMail 就不用多说了吧[一套开源php 邮件程序][说实话,用这套程序的目标还是蛮多的,尼玛,不说了,都是泪……],在重现漏洞利用之前,我们需要先把邮件服务器简单搭起来,这里以centos 6.8 x86 为例 [为了避免安装过程出问题,iptables和selinux已事先全部关闭],大致的配置过程如下,下面是具体测试环境:1
2
3kali 2017: 执行SquirrelMail_RCE_exploit.sh 利用脚本
centos 6.8 x86: 完全模拟真实的生产环境,lamp全程源码包编译配置[后期会把各种配置细节更新上来]
SquirrelMail版本 1.4.20
0x02 安装前的一点准备工作:1
2 rpm -qa sendmail 检查当前系统有没有装sendmail
rpm -e sendmail 如果装了,就暂时先把它卸载掉
1 | # vi /etc/hosts 修改本机host,添加下面的指向 |
1 | # vi /etc/sysconfig/network 修改当前系统的机器名 |
1 | shutdown -r now |
0x03 安装,配置,测试Postfix [一款经典的smtp服务器,默认端口25]:1
2
3
4
5
6
7
8
9
10# yum install postfix -y
# vi /etc/postfix/main.cf
myhostname = admin.rootkit.org
mydomain = rootkit.org
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 192.168.3.0/24, 127.0.0.0/8
home_mailbox = Maildir/
1 | /etc/init.d/postfix start |
1 | useradd admin |
1 | # telnet localhost smtp |
1 | 查看收到的邮件内容 |
0x04 安装,配置,测试 Dovecot [一款开源 IMAP/POP3 邮件服务器,默认端口110,143]1
2
3 yum install dovecot -y
vi /etc/dovecot/dovecot.conf
protocols = imap pop3 lmtp 让它支持邮局协议
1 | # vi /etc/dovecot/conf.d/10-mail.conf |
1 | # vi /etc/dovecot/conf.d/10-auth.conf |
1 | # vi /etc/dovecot/conf.d/10-master.conf |
1 | /etc/init.d/dovecot start |
1 | # telnet localhost pop3 |
0x05 下载,配置squirrelmail程序[如果你不想把它放到二级目录,单独给它配个虚拟主机也是一样的]:1
2
3
4
5
6
7 wget http://pkgs.fedoraproject.org/repo/pkgs/squirrelmail/squirrelmail-1.4.20-RC2_20090917.tar.bz2/e1828757b34c658a061b009da311f1df/squirrelmail-1.4.20-RC2_20090917.tar.bz2
tar -jxf squirrelmail-1.4.20-RC2_20090917.tar.bz2
mv squirrelmail-1.4.20-RC2 /usr/local/apache2/htdocs/squirrelmail
cd squirrelmail/
mkdir attach
chmod 755 attach/ data/
cp config/config_default.php config/config.php
1 | vi config/config.php 编辑squirrelmail的主配置文件,修改如下变量 |
0x06 所有配置完成后,尝试登陆webmail [1.4.20版本]:
0x07 关于漏洞的产生细节,这里就不细说了,网上到处都是,直接来看看具体的利用过程吧,其实非常简单:1
2# vi SquirrelMail_RCE_exploit.sh 因为我这里的路径不是默认的,所以需要先到脚本中去稍微改下
sqspool="/usr/local/apache2/htdocs/squirrelmail/attach"
1 |
0x08 原谅我等了很久shell也没弹回来,开始以为是shell的问题,后来去看了下代码,很简单啊,本质上还是用bash弹的,也看不出啥情况
0x09 折腾了一会儿,仍未解决
后来仔细看了弹回来的html,原来是发邮件的时候报错了,”501 5.1.7 Bad sender address syntax” ,510错误,谷歌知,可能是发信的格式不正确,然后,就又看了下发信的代码,发现拼接貌似也没什么问题呀,难道是locahost不对,然后我就去掉了localhost试了一下,结果然并卵,感觉不大可能是邮件服务器的配置问题,真心希望哪位表哥要是成功了,能放出来让小弟好好学习下,定感激不尽
最后:
哪位大哥如果测成功了,希望也能告知下小弟问题出在哪里,万分感激…