-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
385 lines (362 loc) · 11.3 KB
/
main.py
File metadata and controls
385 lines (362 loc) · 11.3 KB
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
from flask import Flask ,render_template,url_for,request,send_file
from flask_sqlalchemy import SQLAlchemy
import os
import re
import command_exec
import port_scan
from netbios import netb
import pickle,ftpp
from direnum import direnumm
#import dnss
import cve
import sql_brute
import xss
import re
app=Flask(__name__)
def checkinp(Ip):
# pass the regular expression
# and the string in search() method
regex = "^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$"
rege = re.compile(
r'^(?:http|ftp)s?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain...
r'localhost|' # localhost...
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
r'(?::\d+)?' # optional port
r'(?:/?|[/?]\S+)$', re.IGNORECASE)
if (re.search(regex, Ip)):
return
elif (re.match(rege,Ip)):
return
else:
return ("Invalid IP address/url")
def checkKey(dict, key):
if key in dict.keys():
#print("value =", dict[key])
return True
else:
#print("Not present")
return False
def reporting(ip,data,key):
file_exists = os.path.exists('%s.txt' % ip)
if file_exists:
if os.path.getsize("%s.txt" % ip) == 0:
print('File is empty')
mydict = {key:data}
with open('%s.txt' % ip, 'r+b') as fh:
pickle.dump(mydict, fh)
else:
print("file present")
pickle_off = open("%s.txt" % ip, "r+b")
emp = pickle.load(pickle_off)
v = checkKey(emp, key)
if v:
print("updating")
emp[key] = data
else:
emp[key] = data
pickle_off.close()
with open('%s.txt' % ip, 'wb') as fh:
pickle.dump(emp, fh)
else:
mydict = {key:data}
with open('%s.txt' % ip, 'wb') as fh:
pickle.dump(mydict, fh)
print("done")
@app.route("/",methods=['POST','GET'])
@app.route("/home",methods=['POST','GET'])
@app.route("/index",methods=['POST','GET'])
def index():
return render_template("index.html")
@app.route("/recon.html",methods=['POST','GET'])
def recon():
return render_template("recon.html")
@app.route("/os_disc.html",methods=['POST','GET'])
def osdisc():
return render_template("os_disc.html")
@app.route("/os_disc_res",methods=['POST','GET'])
def osdiscc():
error=None
output = request.form
ipp = output["ip"]
v = checkinp(ipp)
if v:
error = v
result = None
return render_template("os_disc.html", ip=result, error=error)
result = command_exec.os_disc(ipp)
print(type(result))
reporting(str(ipp),str(result),"os_disc")
return render_template("os_disc.html", ip=result,error=error)
@app.route("/port_scanner.html",methods=['POST','GET'])
def port_scanner():
return render_template("port_scanner.html")
@app.route("/portscan_result",methods=['POST','GET'])
def portscan_result():
error =None
output=request.form
ipp =output["ip"]
v = checkinp(ipp)
if v:
error = v
b = None
return render_template("port_scanner.html", res=b, error=error)
#result=command_exec.portscan(ipp)
b = port_scan.scanner(ipp)
reporting(str(ipp),b,"port_scan")
return render_template("port_scanner.html",res= b,error=error)
@app.route("/scan.html",methods=['POST','GET'])
def scan():
return render_template("scan.html")
@app.route("/enum.html",methods=['POST','GET'])
def enum():
return render_template("enum.html")
@app.route("/discovery.html",methods=['POST','GET'])
def disc():
return render_template("discovery.html")
@app.route("/discovery_result",methods=['POST','GET'])
def discs():
error=None
output = request.form
ipp = output["ip"]
v=checkinp(ipp)
if v:
error=v
result=None
return render_template("discovery.html", ip=result, error=error)
result = command_exec.discovery(ipp)
reporting(str(ipp),result,"disc")
#print(type(result))
return render_template("discovery.html", ip=result , error=error)
@app.route("/ftp.html",methods=['POST','GET'])
def ftp():
return render_template("ftp.html")
@app.route("/ftp_res.html",methods=['POST','GET'])
def ftp_res():
output = request.form
error=None
ipp = output["ip"]
print(ipp)
v = checkinp(ipp)
if v:
error=v
b=None
return render_template("ftp.html", res=b, error=error)
# result=command_exec.portscan(ipp)
b = ftpp.enum(str(ipp))
reporting(str(ipp),b,"ftp")
print(b)
return render_template("ftp.html", res=b,error=error)
@app.route("/netbios.html",methods=['POST','GET'])
def netbios():
return render_template("netbios.html")
@app.route("/netbios_res.html",methods=['POST','GET'])
def netbios_res():
error=None
output = request.form
ipp = output["ip"]
print(ipp)
v = checkinp(ipp)
if v:
error = v
b = None
return render_template("netbios.html", res=b, error=error)
# result=command_exec.portscan(ipp)
b = netb(str(ipp))
reporting(str(ipp),b,"netb")
print(b)
return render_template("netbios.html", res=b,error=error)
@app.route("/dnss.html",methods=['POST','GET'])
def dnss():
return render_template("dns.html")
@app.route("/dns_res.html",methods=['POST','GET'])
def dns_res():
error=None
output = request.form
ipp = output["ip"]
print(ipp)
v = checkinp(ipp)
if v:
error = v
b = None
return render_template("dns.html", res=b,error=error)
# result=command_exec.portscan(ipp)
b = dnss.dns_cap(str(ipp))
reporting(str(ipp),b,"dns")
print(b)
return render_template("dns.html", res=b,error=error)
@app.route("/sql.html",methods=['POST','GET'])
def sqll():
return render_template("sqlinj.html")
@app.route("/sql_res.html",methods=['POST','GET'])
def sql_res():
error=None
output = request.form
ipp = output["ip"]
print(ipp)
v = checkinp(ipp)
if v:
error = v
b = None
return render_template("sqlinj.html", res=b, error=error)
# result=command_exec.portscan(ipp)
b = sql_brute.scan_sql_injection(str(ipp))
#reporting(str(ipp),b,"sql")
print(b)
return render_template("sqlinj.html", res=b,error=error)
@app.route("/xss.html",methods=['POST','GET'])
def xsss():
return render_template("xss.html")
@app.route("/xss_res.html",methods=['POST','GET'])
def xsss_res():
error=None
output = request.form
ipp = output["ip"]
print(ipp)
v = checkinp(ipp)
if v:
error = v
b = None
return render_template("xss.html", res=b, error=error)
# result=command_exec.portscan(ipp)
b = xss.core.main(str(ipp))
print(b)
return render_template("xss.html", res=b,error=error)
@app.route("/google_dork.html",methods=['POST','GET'])
def gd():
return render_template("google_dork.html")
@app.route("/google_dork_res.html",methods=['POST','GET'])
def gdr():
output = request.form
ipp = output["ip"]
result = command_exec.google_dork(ipp)
return render_template("google_dork.html")
@app.route("/direnum.html",methods=['POST','GET'])
def direnum():
return render_template("direnum.html")
@app.route("/direnum_result",methods=['POST','GET'])
def direnum_res():
error=None
output = request.form
ipp = output["ip"]
v = checkinp(ipp)
if v:
error = v
b = None
return render_template("direnum.html", res=b, error=error)
result = direnumm(ipp)
return render_template("direnum.html", res=result,error=error)
@app.route("/gain_acess.html",methods=['POST','GET'])
def gainac():
return render_template("gain_acess.html")
@app.route("/cve.html",methods=["POST","GET"])
def cvee():
return render_template("cve.html")
@app.route("/cve_res.html", methods=['POST', 'GET'])
def cvee_res():
output = request.form
ipp = output["product"]
version=output["version"]
if version:
result = cve.VuldbLookup(ipp,version)
else:
result = cve.VuldbLookup(ipp)
print(result)
return render_template("cve.html", res=result)
@app.route("/Test.html",methods=['POST','GET'])
def testing():
"""ipp = '10.0.2.11'
b=port_scan.scanner(ipp)
with open('testinggg.txt', 'r+b') as fh:
pickle.dump(b, fh)
#result = command_exec.portscan(ipp)"""
return render_template("test.html")
@app.route("/download1",methods=['POST','GET'])
def download_file():
p="ftp_user.txt"
return send_file(p,as_attachment=True)
@app.route("/priv_esc.html",methods=['POST','GET'])
def download_file_privesc():
return render_template("priv_esc.html")
@app.route("/payloads.html",methods=['POST','GET'])
def payloads():
return render_template("payloads.html")
@app.route("/privesc_download",methods=['POST','GET'])
def download_file_priv():
p="privesc.py"
return send_file(p,as_attachment=True)
@app.route("/bashtcp",methods=['POST','GET'])
def download_file_bashtcp():
p="bashtcp.txt"
return send_file(p,as_attachment=True)
@app.route("/bashudp",methods=['POST','GET'])
def download_file_bashudp():
p="bashudp.txt"
return send_file(p,as_attachment=True)
@app.route("/ipv4",methods=['POST','GET'])
def download_file_ipv4():
p="ipv4.txt"
return send_file(p,as_attachment=True)
@app.route("/ipv6",methods=['POST','GET'])
def download_file_ipv6():
p="ipv6.txt"
return send_file(p,as_attachment=True)
@app.route("/perl",methods=['POST','GET'])
def download_file_perl():
p="perl.txt"
return send_file(p,as_attachment=True)
@app.route("/php",methods=['POST','GET'])
def download_file_php():
p="php.txt"
return send_file(p,as_attachment=True)
@app.route("/java",methods=['POST','GET'])
def download_file_java():
p="java.txt"
return send_file(p,as_attachment=True)
@app.route("/awk",methods=['POST','GET'])
def download_file_awk():
p="awk.txt"
return send_file(p,as_attachment=True)
@app.route("/netcat",methods=['POST','GET'])
def download_file_netcat():
p="netcat.txt"
return send_file(p,as_attachment=True)
@app.route("/powershell",methods=['POST','GET'])
def download_file_powershell():
p="powershell.txt"
return send_file(p,as_attachment=True)
@app.route("/report.html",methods=['POST','GET'])
def report():
return render_template("report.html")
@app.route("/report_res.html",methods=['POST','GET'])
def reportt():
disc=None
pc= None
osd=None
ftp=None
netb=None
dns=None
error=None
output = request.form
ipp = output["ip"]
if not os.path.isfile("%s.txt" %ipp):
error="Report not found "
return render_template("report.html", pc=pc, osd=osd, disc=disc, ftp=ftp, netb=netb, dns=dns, error=error)
pickle_off = open("%s.txt" % ipp, "r+b")
a = pickle.load(pickle_off)
if checkKey(a,"port_scan"):
pc=a.get("port_scan")
if checkKey(a,"os_disc"):
osd=a.get("os_disc")
if checkKey(a,"disc"):
disc=a.get("disc")
if checkKey(a, "ftp"):
ftp = a.get("ftp")
if checkKey(a, "dns"):
dns = a.get("dns")
if checkKey(a,"netb"):
netb =a.get("netb")
return render_template("report.html",pc=pc,osd=osd,disc=disc,ftp=ftp,netb=netb,dns=dns,error=None)
if __name__ == '__main__':
app.run(debug=True)
# See PyCharm help at https://www.jetbrains.com/help/pycharm/