-
Notifications
You must be signed in to change notification settings - Fork 85
/
logsensor.py
219 lines (197 loc) · 7.32 KB
/
logsensor.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/usr/bin/env python3
import requests ,argparse, sys
from bs4 import BeautifulSoup
from requests.packages import urllib3
import time
import re
from termcolor import colored
from concurrent.futures import ThreadPoolExecutor
from src import logninputs, payloads, Errors
from tabulate import tabulate
start = time.time()
def ban():
print(colored('''
\ | /
- * -
/|\
/\|/\
/ | \
/\/\|/\/\
/ | \
- - -
__ ____ ___________ _______ _______ ____ ______
/ / / __ \/ ____/ ___// ____/ | / / ___// __ \/ __ /
/ / / / / / / __ \__ \/ __/ / |/ /\__ \/ / / / /_/ /
/ /__/ /_/ / /_/ /___/ / /___/ /| /___/ / /_/ / _, _/
/_____|____/\____//____/_____/_/ |_//____/\____/_/ |_|
''' ,"white",attrs=["bold"])+
colored(' coded by @Mr_Robert',"yellow")+'\n\n'+
colored("[-] Detecting All Login Panels : I'M a Powerful Sensor Tool, feel login panels even if it's miles away !!! " , "cyan")+'\n'
)
urllib3.disable_warnings()
parser = argparse.ArgumentParser(usage="python3 logsensor.py [-h --help] [--file ] [--url ] [--proxy] [--login] [--sqli] [--threads]", add_help=False)
parser.add_argument_group("Help")
parser.add_argument("-u", "--url", dest="url", type=str, help=" Target URL (e.g. http://example.com )")
parser.add_argument("-f", "--file", dest="file", help="Select a target hosts list file (e.g. list.txt )")
parser.add_argument("--proxy", dest="proxy", help="Proxy (e.g. http://127.0.0.1:8080)",required=False)
parser.add_argument("-l","--login", help=" run only Login panel Detector", action='store_true')
parser.add_argument("-s","--sqli", help=" run only POST Form SQLi Scanning with provided Urls" ,action='store_true')
parser.add_argument("-n","--inputname", help=" Customize actual username input for SQLi scan (default 'username' )")
parser.add_argument("-t","--threads", help=" Number of threads (default 30)" ,type=int)
parser.add_argument("-h", "--help", action="help", help="Show this help message and exit")
args = parser.parse_args()
if len(sys.argv) == 1:
ban()
parser.print_help()
sys.exit()
proxies = {}
# proxies = {'http': 'http://127.0.0.1:8080' , 'https': 'http://127.0.0.1:8080'}
useragent = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.94 Chrome/37.0.2062.94 Safari/537.36' }
inputname = "username"
threads = 30
urls=[]
loginurls = []
if args.file :
f = open(args.file,"r").read().splitlines()
for c in f:
urls.append(c)
if args.url :
url = args.url
urls.append(url)
if args.proxy :
proxies.update({'http': args.proxy ,'https': args.proxy})
if args.inputname :
inputname = args.inputname
if args.threads :
threads = args.threads
class main():
def __init__(self,lines):
self.lines = lines
try:
req = requests.get(lines, headers=useragent, proxies=proxies, verify=False, timeout=8,allow_redirects=True)
response = str(req.content)
soup = BeautifulSoup(response, "html.parser")
s = soup.find_all("form")[0]
action = s.attrs.get("action")
check = re.search("login",str(req.url))
if action == None :
action = ""
if action == "?" :
action = ""
if action[0] == "/" :
action = action[1:]
if check :
action = ""
else:
action = action
if req.status_code == 200:
for login in logninputs:
try:
find = re.compile(login).search(str(response))
if find != None:
loginurls.append(req.url +str(action))
print(colored("[+] Login panel found ! [{}] - {}","green").format(req.url, req.status_code))
break
else:
pass
except IndexError:
pass
except IOError:
pass
except IndexError:
pass
except KeyboardInterrupt :
print("\nStopped")
exit(0)
def getresults():
if loginurls :
with open("logPanels.txt", "w") as n:
n.write(str(loginurls).replace("[","").replace("]","").replace(",","").replace("'","").replace(" ","\n"))
print("=================================================================================")
print("[+] Total Login Panels been found : " + str(len(loginurls)) + "\n\n")
else:
print("[+] There are no Login Panels in URLs you provided !" )
sqllen = []
sqlcontent = []
msgsql = colored("[+]","green",attrs=["bold"])+colored(" Potential SQL Injection !! in Database: ","white",attrs=["bold"])
msgurl = colored("[+] ","green",attrs=["bold"])+"injected in "+inputname +" input and url is: "
msgpyld = colored("[+]","green",attrs=["bold"])+" Payload: "
msgerr = colored("[+]","green",attrs=["bold"])+ " Detected error: "
msgreg = colored("[+]","green",attrs=["bold"])+" Regex Used: "
def inject(loginurls, inputname):
print(colored("[@] Start POST Form SQLi Scanning [@]","cyan"))
try:
for ur in loginurls:
normreq = requests.post(str(ur), headers=useragent, proxies=proxies, verify=False, timeout=8, data={inputname : "admin", "password": "badpassword"})
normres = str(normreq.content)
norchars = len(normres)
print("\n"+colored("[+] URL {} Normal Request's Content Length is : {}","green").format(ur, norchars))
#trying payloads
for p in payloads:
try:
sqlreq = requests.post(str(ur), headers=useragent, proxies=proxies, verify=False, timeout=8, data={inputname : str(p) , "password": "badpassword"})
sqlres = str(sqlreq.content)
sqchars = len(sqlres)
payloadId =+ 1
print(colored("[+] Trying Payload [ {} ] and Content Length is : {}","yellow").format(p, colored(sqchars, "white")))
if sqchars != norchars:
for db, errs in Errors.items():
for err in errs:
try:
finderr = re.compile(err).search(str(sqlres))
if finderr != None:
vulnf = open('vulnPanels.txt', 'a')
print(colored(50*"-","yellow"))
print("Potential SQL Injection !! in Database: {}\nVulnerable Login Panel url : {}\nPayload: {}\nDetected error: {}\nRegex Used: {}\n\n".format(db,str(ur),p,finderr[0],err),file=vulnf)
print("{}{}\n{}{}\n{}{}\n{}[ {} ]\n{}{}".format(msgsql,colored(db,"green",attrs=["bold"]),msgurl,str(ur),msgpyld,p,msgerr,colored(finderr[0],"red"),msgreg,err ))
table = [['Vulnerable Login Panel', 'payload', 'Database', 'Detected Error(Regex Used)'], [str(ur), str(p), db, err]]
print(colored(tabulate(table, headers='firstrow', tablefmt='grid'),"white",attrs=["bold"])+"\n\n")
break
else:
pass
except IndexError:
pass
except KeyboardInterrupt:
print("\nStopped")
exit(0)
#break
else:
pass
except IOError:
pass
except IndexError:
pass
except KeyboardInterrupt:
print("\nStopped")
exit(0)
except IOError:
pass
except IndexError:
pass
except KeyboardInterrupt:
print("\nStopped")
exit(0)
if __name__ == '__main__':
def sensorWithThreads():
try:
with ThreadPoolExecutor(max_workers=threads) as executor:
for lines in urls:
executor.submit(main,lines)
except KeyboardInterrupt:
print("\nStopped")
exit(0)
if args.login :
ban()
sensorWithThreads()
getresults()
elif args.sqli:
ban()
inject(urls,inputname)
else:
ban()
sensorWithThreads()
getresults()
inject(loginurls,inputname)
end = time.time()
total_time = end - start
print("\n Finished at : "+ str(total_time)+" Secs")