-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWebScan.py
More file actions
2998 lines (2562 loc) · 95.4 KB
/
WebScan.py
File metadata and controls
2998 lines (2562 loc) · 95.4 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
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
#!/usr/bin/python
import sys, os, re, io
# Color [ANSI] ==========================================
W = "\033[38;5;245m"
WH = "\033[38;5;15m"
PINK = "\033[38;5;207m"
P = "\033[38;5;105m"
R = '\033[0;31m'
G = '\033[0;32m'
O = '\033[38;5;130m'
B = '\033[38;5;37m'
BR = '\033[1;31m'
BG = '\033[1;32m'
BO = '\033[38;5;208m'
BB = '\033[38;5;51m'
# Set Variable ==========================================
printout = W + "[" + BO + "+" + W + "]"
success = W + "[" + BG + "+" + W + "]"
fail = W + "[" + BR + "-" + W + "]"
error = W + "[" + BR + "!" + W + "]"
found = W + "[" + BG + "Found!" + W + "]"
loading = W + "[" + BO + "%" + W + "]"
systm = W + "[" + BR + "$" + W + "]"
loginfound = W + "[" + BG + "Login Page Found!" + W + "]"
notfound = W + "[" + BR + "Page Not Found!" + W + "]"
ercon = W + "[" + BR + "ERROR! Could Not Connect" + W + "]"
invalid = W + " [" + BR + "$" + W + "]" + BR + " Invalid!"
author = "Surya H.S"
version = "v1.0"
line1 = "\n\n==============================["
line2 = "]==============================\n\n"
# Get Terminal Width ==========================================
term_size = os.get_terminal_size()
whitespace = ""
for xx in range(term_size.columns):
whitespace += " "
whitespace = whitespace
# Check Python Version ==========================================
try:
import platform
except ImportError as sp:
os.system("pip install platform")
if sys.version[0] in '2':
print('\n[x] Not Supported For python 2.x Please Use Python 3.x \n')
ins = input('Install Python3? Y/n: ')
if ins == '1' or ins == '01':
os.system('apt install python3')
else:
exit()
# Cleaning Temp ==========================================
print(f"{systm}{BG} Cleaning Temp Folder...\n")
try:
if os.path.exists("./install.sh"):
os.remove("./install.sh")
except Exception:
pass
if os.path.exists("./.temp"):
for i in os.listdir("./.temp"):
if os.path.exists(os.path.join("./.temp", i)):
os.remove(os.path.join("./.temp", i))
#Setup Folder & Resource =====================================
try:
import wget
except ImportError as wget_err:
os.system("pip install wget")
if not os.path.exists("./output"):
os.makedirs("./output")
if not os.path.exists("./.temp"):
os.makedirs("./.temp")
if not os.path.exists("./src"):
os.makedirs("./src")
if not os.path.exists("./src/adminpages.txt"):
wget.download("https://raw.githubusercontent.com/SansXpl/src/main/adminpages.txt","./src/")
if not os.path.exists("./src/subdomains.txt"):
wget.download("https://raw.githubusercontent.com/SansXpl/src/main/subdomains.txt","./src/")
if not os.path.exists("./src/error_sql.txt"):
wget.download("https://raw.githubusercontent.com/SansXpl/src/main/error_sql.txt","./src/")
if not os.path.exists("./src/UserAgent.txt"):
wget.download("https://raw.githubusercontent.com/SansXpl/src/main/UserAgent.txt","./src/")
if not os.path.exists("./src/users.txt"):
wget.download("https://raw.githubusercontent.com/SansXpl/src/main/users.txt","./src/")
if not os.path.exists("./src/passwords.txt"):
wget.download("https://raw.githubusercontent.com/SansXpl/src/main/passwords.txt","./src/")
if not os.path.exists("./output/crawler"):
os.makedirs("./output/crawler")
if not os.path.exists("./output/subscan"):
os.makedirs("./output/subscan")
if not os.path.exists("./output/dorkscan"):
os.makedirs("./output/dorkscan")
if not os.path.exists("./output/vulnsqli"):
os.makedirs("./output/vulnsqli")
if not os.path.exists("./output/adminfind"):
os.makedirs("./output/adminfind")
if not os.path.exists("./output/logbrute"):
os.makedirs("./output/logbrute")
if not os.path.exists("./output/wpbrute"):
os.makedirs("./output/wpbrute")
if not os.path.exists("./output/nslookup"):
os.makedirs("./output/nslookup")
if not os.path.exists("./output/revIP"):
os.makedirs("./output/revIP")
# Checking PIP Packages ==========================================
try:
print(f"{loading}{BO} Checking Packages ...")
import mechanicalsoup, blessed, lxml, threading, subprocess, http.client as httplib, urllib.parse, httplib2, socket, os.path, ipaddress, ipdetector, collections, datetime, requests, random, json, time, uuid
from mechanicalsoup import StatefulBrowser
from re import findall
from os import getcwd as pth
from time import sleep, localtime
from urllib.parse import urlparse
from urllib.parse import urljoin
from lxml import html
from sys import exit
from threading import Thread
from ipdetector import ipCategorizer
from requests import ConnectionError
from time import sleep
from collections import namedtuple
from datetime import datetime
from blessed import Terminal
print(f"\n{success}{BG} Packages is OK")
except ImportError as chk:
print(f"\n{loading}{BO} Checking Packages ... \n")
try:
import blessed
print(f"{success}{BG} blessed Ok")
except ImportError as a0:
print(f"{loading}{BO} Installing blessed")
os.system("pip install blessed")
try:
import threading
print(f"{success}{BG} threading Ok")
except ImportError as a1:
print(f"{loading}{BO} Installing threading")
os.system("pip install threading")
try:
import subprocess
print(f"{success}{BG} subprocess Ok")
except ImportError as a2:
print(f"{loading}{BO} Installing subprocess")
os.system("pip install subprocess")
try:
import http.client as httplib
print(f"{success}{BG} http.client Ok")
except ImportError as a3:
print(f"{loading}{BO} Installing http.client")
os.system("pip install http.client")
try:
import urllib.parse
print(f"{success}{BG} urllib.parse Ok")
except ImportError as a4:
print(f"{loading}{BO} Installing urllib.parse")
os.system("pip install urllib.parse")
try:
import httplib2
print(f"{success}{BG} httplib2 Ok")
except ImportError as a5:
print(f"{loading}{BO} Installing httplib2")
os.system("pip install httplib2")
try:
import socket
print(f"{success}{BG} socket Ok")
except ImportError as a6:
print(f"{loading}{BO} Installing socket")
os.system("pip install socket")
try:
import os.path
print(f"{success}{BG} os.path Ok")
except ImportError as a7:
print(f"{loading}{BO} Installing os.path")
os.system("pip install os.path")
try:
import ipaddress
print(f"{success}{BG} ipaddress Ok")
except ImportError as a8:
print(f"{loading}{BO} Installing ipaddress")
os.system("pip install ipaddress")
try:
import ipdetector
print(f"{success}{BG} ipdetector Ok")
except ImportError as a9:
print(f"{loading}{BO} Installing ipdetector")
os.system("pip install ipdetector")
try:
import collections
print(f"{success}{BG} collections Ok")
except ImportError as a10:
print(f"{loading}{BO} Installing collections")
os.system("pip install collections")
try:
import datetime
print(f"{success}{BG} datetime Ok")
except ImportError as a11:
print(f"{loading}{BO} Installing datetime")
os.system("pip install datetime")
try:
import requests
print(f"{success}{BG} requests Ok")
except ImportError as a12:
print(f"{loading}{BO} Installing requests")
os.system("pip install requests")
try:
import random
print(f"{success}{BG} random Ok")
except ImportError as a13:
print(f"{loading}{BO} Installing random")
os.system("pip install random")
try:
import json
print(f"{success}{BG} json Ok")
except ImportError as a14:
print(f"{loading}{BO} Installing json")
os.system("pip install json")
try:
import time
print(f"{success}{BG} time Ok")
except ImportError as a15:
print(f"{loading}{BO} Installing time")
os.system("pip install time")
try:
import uuid
print(f"{success}{BG} uuid Ok")
except ImportError as a16:
print(f"{loading}{BO} Installing uuid")
os.system("pip install uuid")
try:
import lxml
print(f"{success}{BG} lxml Ok")
except ImportError as a17:
print(f"{loading}{BO} Installing lxml")
os.system("pip install lxml")
try:
import mechanicalsoup
print(f"{success}{BG} mechanicalsoup Ok")
except ImportError as a18:
print(f"{loading}{BO} Installing mechanicalsoup")
os.system("pip install mechanicalsoup")
from time import sleep, localtime
from mechanicalsoup import StatefulBrowser
from re import findall
from os import getcwd as pth
from urllib.parse import urlparse
from urllib.parse import urljoin
from lxml import html
from sys import exit
from threading import Thread
from ipdetector import ipCategorizer
from requests import ConnectionError
from time import sleep
from collections import namedtuple
from datetime import datetime
from blessed import Terminal
# Check Device OS ==========================================
osdevice = {'Win', 'Win98', 'WinNT3', 'WinNT4', 'Windows', 'WindowsCE'}
if platform.system() in osdevice:
clrcmd = '"cls"'
print(f"\n{systm}{BO} OS is Windows, using CLS to clear Terminal")
else:
clrcmd = '"clear"'
print(f"\n{systm}{BO} OS is Linux or Other, using CLEAR to clear Terminal")
time.sleep(0.750)
# Banner =====================================
os.system(clrcmd)
banner = f"""\033[38;5;208m
│_________________________
│ │''|''|''|''|''|''|''|''| \__
┝━━━┥ \033[1;30;41m[WEBSITE SCANNER]\033[0;38;5;208m __]━───────────
│ │_________________________/
│ \033[1;31mBy: {author} {version}
{W}
+──────────────────────────────────────────────+{BR}
Tools For Scanning Website, Brute Force, Etc {W}
+──────────────────────────────────────────────+"""
# Check Connection ==========================================
def checkConnection(url, option):
sys.stdout.write(f"\n{loading}{BO} Checking Connecting to {BB}{url}")
time.sleep(0.5)
if option == 1:
try:
requests.get(url, timeout=10)
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(f"\r{success}{BG} Connection Established!\n")
except:
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(
f"\r{error}{BR} Connection Error, Maybe Your Internet Connection or Website Down!"
)
input("")
main()
elif option == 0:
try:
requests.get(url, timeout=10)
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(f"\r{success}{BG} Connection Established!\n")
except:
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(
f"\r{error}{BR} Connection Error, Maybe Your Internet Connection or Website Down!"
)
input("")
pass
elif option == 2:
try:
requests.get(url, timeout=10)
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(f"\r{success}{BG} Connection Established!\n")
except:
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(
f"\r{error}{BR} Connection Error, Maybe Your Internet Connection or Website Down!"
)
pass
# Remove Duplicates Text Output ==========================================
def removeDups(inputfile):
tmp = "./.temp/"
filename = inputfile
os.rename(tmp + inputfile, tmp + inputfile + "_old")
lines = open(tmp + inputfile + "_old", 'r').readlines()
lines_set = set(lines)
out = open(tmp + filename, 'w')
for line in lines_set:
out.write(line)
os.remove(tmp + inputfile + "_old")
# Saving File ==========================================
def save_file(name, content, mode):
if mode == 1:
if os.path.exists(name):
os.rename(name, name + "_old")
liner_stamp = time.time()
liner_time = datetime.fromtimestamp(liner_stamp)
liner = liner_time.strftime("%d-%m-%Y | %H:%M:%S")
line = line1 + liner + line2
old = open(name + "_old", "r")
new = open(name, "a+")
text = content
new.writelines(line + text + old.read())
old.close()
new.close()
os.remove(name + "_old")
else:
liner_stamp = time.time()
liner_time = datetime.fromtimestamp(liner_stamp)
liner = liner_time.strftime("%d-%m-%Y | %H:%M:%S")
line = line1 + liner + line2
text = content
new = open(name, "a+")
new.writelines(line + text)
new.close()
input(f"\n{success}{BG} Output Saved In: {P}{name}")
elif mode == 2:
if os.path.exists(name):
os.rename(name, name + "_old")
liner_stamp = time.time()
liner_time = datetime.fromtimestamp(liner_stamp)
liner = liner_time.strftime("%d-%m-%Y | %H:%M:%S")
line = line1 + liner + line2
old = open(name + "_old", "r")
new = open(name, "a+")
text = content
new.writelines(line + text + old.read())
old.close()
new.close()
os.remove(name + "_old")
else:
liner_stamp = time.time()
liner_time = datetime.fromtimestamp(liner_stamp)
liner = liner_time.strftime("%d-%m-%Y | %H:%M:%S")
line = line1 + liner + line2
text = content
new = open(name, "a+")
new.writelines(line + text)
new.close()
print(f"\n{success}{BG} Output Saved In: {P}{name}")
elif mode == 3:
if os.path.exists(name):
os.rename(name, name + "_old")
liner_stamp = time.time()
liner_time = datetime.fromtimestamp(liner_stamp)
liner = liner_time.strftime("%d-%m-%Y | %H:%M:%S")
line = line1 + liner + line2
old = open(name + "_old", "r")
new = open(name, "a+")
text = content
new.writelines(line + text + old.read())
old.close()
new.close()
os.remove(name + "_old")
else:
liner_stamp = time.time()
liner_time = datetime.fromtimestamp(liner_stamp)
liner = liner_time.strftime("%d-%m-%Y | %H:%M:%S")
line = line1 + liner + line2
text = content
new = open(name, "a+")
new.writelines(line + text)
new.close()
input(f"\n{success}{BG} Login Page Saved In: {P}{name}")
elif mode == 4:
if os.path.exists(name):
os.rename(name, name + "_old")
liner_stamp = time.time()
liner_time = datetime.fromtimestamp(liner_stamp)
liner = liner_time.strftime("%d-%m-%Y | %H:%M:%S")
line = line1 + liner + line2
old = open(name + "_old", "r")
new = open(name, "a+")
text = content
new.writelines(line + text + old.read())
old.close()
new.close()
os.remove(name + "_old")
else:
liner_stamp = time.time()
liner_time = datetime.fromtimestamp(liner_stamp)
liner = liner_time.strftime("%d-%m-%Y | %H:%M:%S")
line = line1 + liner + line2
text = content
new = open(name, "a+")
new.writelines(line + text)
new.close()
print(f"\n{success}{BG} Login Page Saved In:{P}{name}")
elif mode == 5:
if os.path.exists(name):
os.rename(name, name + "_old")
liner_stamp = time.time()
liner_time = datetime.fromtimestamp(liner_stamp)
liner = liner_time.strftime("%d-%m-%Y | %H:%M:%S")
line = line1 + liner + line2
old = open(name + "_old", "r")
new = open(name, "a+")
text = content
new.writelines(line + text + old.read())
old.close()
new.close()
os.remove(name + "_old")
else:
liner_stamp = time.time()
liner_time = datetime.fromtimestamp(liner_stamp)
liner = liner_time.strftime("%d-%m-%Y | %H:%M:%S")
line = line1 + liner + line2
text = content
new = open(name, "a+")
new.writelines(line + text)
new.close()
#SQli Scanner ====================================
class sqlscan():
def main(self, mode):
try:
vulntemp = str(uuid.uuid4()) + "_vuln"
os.system(clrcmd)
print(banner)
print(f"{W}[{BR}@{W}]{BG} SQLI Scanner {W}")
if (mode == 1):
scan = str(input(f" └─[{BO}Target{W}]{P} "))
n_url = urlparse(scan).hostname
checkConnection(scan, 1)
try:
try:
dq = 0
__vuln = ""
with open("./src/error_sql.txt", 'r') as f:
sqlerror = f.read().splitlines()
sys.stdout.write(f"\n{loading}{BO} Check Vuln ['][-]: {W}{scan}")
resp = requests.get(scan + "'")
errcount = 1
for err in sqlerror:
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(
f"\r{loading}{BO} Check Vuln ['][{int(errcount)}]: {W}{scan}")
errcount += 1
if re.search(err, resp.text):
__vuln = err
sys.stdout.write("\r" + whitespace)
sys.stdout.write(f'\n{success}{BG} Vulnerability SQLi!')
print(f'\n{error}{BR} Error Text: {W}{__vuln}')
print(f'{printout}{BB} Url: {P}{scan}\n')
name = "./output/vulnsqli/" + n_url + ".txt"
content = f"""[Checking With Single Quote (’)]
Url: {scan}
Error: {err}\n\n"""
save_file(name, content, 1)
main()
break
else:
dq = 1
time.sleep(0.005)
if dq == 1:
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(f'\r{loading}{BO} Check Vuln ["][-]: {W}{scan}')
resp1 = requests.get(scan + '"')
for errr in sqlerror:
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(
f'\r{loading}{BO} Check Vuln ["][{int(errcount)}]: {W}{scan}'
)
errcount += 1
if re.search(errr, resp.text):
__vuln = errr
sys.stdout.write("\r" + whitespace)
sys.stdout.write(f'\n{success}{BG} Vulnerability SQLi!')
print(f'\n{error}{BR} Error Text: {W}{__vuln}')
print(f'{printout}{BB} Url: {P}{scan}\n')
name = "./output/vulnsqli/" + n_url + ".txt"
content = f"""[Checking With Double Quote (”)]
Url: {scan}
Error: {err}\n\n"""
save_file(name, content, 1)
main()
break
else:
sys.stdout.write(
f"\r{error}{BR} Not Vulnerability: {W}{scan}")
input("")
time.sleep(0.005)
except Exception as e:
print(BR + e)
except KeyboardInterrupt:
cancel()
except Exception:
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(f"\r{error}{BR} Not Vulnerability: {W}{scan}")
input("")
main()
elif (mode == 2):
filetemp = str(uuid.uuid4())
path = str(input(f" ├─[{BO}Path File{W}]{P} "))
if not os.path.exists(path):
input(f"{error}{BR} File Does Not Exists!")
self.main(mode)
output = str(input(f"{W} └─[{BO}Output File{W}]{P} "))
with open(path, 'r') as f:
sqllists = f.read().splitlines()
outputfile = os.path.splitext(output)[0]
for sqllist in sqllists:
scan = sqllist
checkConnection(scan, 2)
try:
try:
dq = 0
__vuln = ""
with open("./src/error_sql.txt", 'r') as f:
sqlerror = f.read().splitlines()
sys.stdout.write(f"\n{loading}{BO} Check Vuln ['][-]: {W}{scan}")
resp = requests.get(scan + "'")
errcount = 1
for err in sqlerror:
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(
f"\r{loading}{BO} Check Vuln ['][{int(errcount)}]: {W}{scan}"
)
errcount += 1
if re.search(err, resp.text):
__vuln = err
sys.stdout.write("\r" + whitespace)
sys.stdout.write(f'\n{success}{BG} Vulnerability SQLi!')
print(f'\n{error}{BR} Error Text: {W}{__vuln}')
print(f'{printout}{BB} Url: {P}{scan}\n')
temp = open("./.temp/" + vulntemp, "a+")
text = f"""[Checking With Single Quote (’)]
Url: {scan}
Error: {err}\n\n"""
temp.writelines(text)
temp.close()
break
pass
else:
dq = 1
time.sleep(0.005)
if dq == 1:
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(
f'\r{loading}{BO} Check Vuln ["][-]: {W}{scan}')
resp1 = requests.get(scan + '"')
for errr in sqlerror:
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(
f'\r{loading}{BO} Check Vuln ["][{int(errcount)}]: {W}{scan}'
)
errcount += 1
if re.search(errr, resp.text):
__vuln = errr
sys.stdout.write("\r" + whitespace)
sys.stdout.write(f'\n{success}{BG} Vulnerability SQLi!')
print(f'\n{error}{BR} Error Text: {W}{__vuln}')
print(f'{printout}{BB} Url: {P}{scan}\n')
temp = open("./.temp/" + vulntemp, "a+")
text = f"""[Checking With Double Quote (”)]
Url: {scan}
Error: {err}\n\n"""
temp.writelines(text)
temp.close()
break
pass
else:
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(
f"\r{error}{BR} Not Vulnerability: {W}{scan}")
break
pass
time.sleep(0.005)
except Exception as e:
print(BR + e)
except KeyboardInterrupt:
pause = str(
input(
f"\n{systm}{BB} [S = Skip] [X = Stop] {BO}Default is Skip [S/X?]"
))
if pause == "X" or pause == "x":
if os.path.exists("./.temp/" + vulntemp):
c = open("./.temp/" + vulntemp, "r")
name = "./output/vulnsqli/" + outputfile + ".txt"
content = c.read()
c.close()
os.remove("./.temp/" + vulntemp)
save_file(name, content, 1)
main()
else:
input(f"\n{fail}{BO} Nothing is Saved!")
main()
else:
pass
except Exception:
sys.stdout.write(f"\r{whitespace}")
sys.stdout.write(f"\r{error}{BR} Not Vulnerability: {W}{scan}")
pass
if os.path.exists("./.temp/" + vulntemp):
c = open("./.temp/" + vulntemp, "r")
name = "./output/vulnsqli/" + outputfile + ".txt"
content = c.read()
c.close()
os.remove("./.temp/" + vulntemp)
save_file(name, content, 1)
else:
input(f"\n{fail}{BO} Nothing is Saved!")
main()
except KeyboardInterrupt:
cancel()
#Subdomain Scanner =====================================
class SUB():
def request(self, url):
try:
return requests.get("http://" + url)
except requests.exceptions.ConnectionError:
pass
def main(self):
try:
os.system(clrcmd)
print(banner)
print(f"{W}[{BR}@{W}]{BG} Subdomain Scanner {W}")
filetemp = str(uuid.uuid4())
s_url = str(input(f" └─[{BO}Url{W}]{P} "))
if "http://" in s_url or "https://" in s_url:
n_url = urlparse(s_url).hostname
s_url = n_url
s_url = str(s_url)
else:
n_url = s_url
s_url = s_url
checkConnection("http://" + n_url, 1)
try:
subdomains = []
with open("./src/subdomains.txt", 'r') as file:
for line in file:
try:
word = line.strip()
test_url = word + "." + s_url
response = self.request(test_url)
subdomains.append("https://" + test_url)
test_url = 'https://' + test_url
sys.stdout.write("\r" + whitespace)
sys.stdout.write(f"\r{loading}{BO} CHECKING: {test_url}")
time.sleep(0.02)
if response:
sys.stdout.write("\r" + whitespace)
sys.stdout.write(f"\r{success}{BG} FOUND: {test_url}\n")
text = "Url: {}\n".format(test_url)
temp = open("./.temp/" + filetemp, "a+")
temp.writelines(text)
temp.close()
except KeyboardInterrupt:
pause = str(
input(
f"\n{systm}{BB} [C = Continue] [X = Stop] {BO}Default is Continue [C/X?]"
))
if pause == "X" or pause == "x":
if os.path.exists("./.temp/" + filetemp):
removeDups(filetemp)
c = open("./.temp/" + filetemp, "r")
name = "./output/subscan/" + n_url + ".txt"
content = c.read()
c.close()
os.remove("./.temp/" + filetemp)
save_file(name, content, 1)
else:
input(f"\n{fail}{BO} Nothing is Saved!")
main()
break
if os.path.exists("./.temp/" + filetemp):
removeDups(filetemp)
c = open("./.temp/" + filetemp, "r")
name = "./output/subscan/" + n_url + ".txt"
content = c.read()
c.close()
os.remove("./.temp/" + filetemp)
save_file(name, content, 2)
else:
input(f"\n{fail}{BO} Nothing is Saved!")
main()
main()
except requests.exceptions.ConnectionError:
print("\n" + ercon + R + " " + test_url)
except KeyboardInterrupt:
cancel()
#Dork Scanner =====================================
def useragentdork():
listAgent = open("./src/UserAgent.txt", "r")
Agent = listAgent.read().splitlines()
uag = random.choice(Agent)
return uag
class scrape(StatefulBrowser):
def __repr__(fitur={
'features': 'html.parser',
}, uag=useragentdork()):
return StatefulBrowser(soup_config=fitur, user_agent=uag)
class Parser(object):
__list = []
def __init__(self, dork, URL, pattern, class_tag, proxy=None):
self.dork = dork
self.URL = URL
self.__pattern = pattern
self.class_tag = class_tag
self.proxy = {'https': proxy}
def __dir__(self):
return list(set(self.__list))
def get_page(self):
self.__req = scrape()
s = self.__req.open(self.URL, proxies=self.proxy, timeout=10)
self.__req.select_form('form[action="/search"]')
self.__req['q'] = self.dork
self.__req.submit_selected()
_content = str(self.__req.get_current_page())
for urls in findall(self.__pattern, _content):
if 'www.google.com' in self.URL: self.__list.append(urls)
else: self.__list.append(urls[:-1])
return self.__req.get_current_page().find_all('a', class_=self.class_tag)
def request(self):
self.__req = scrape()
for page in self.get_page():
try:
self.__req.open(f'{self.URL}{page.get("href")}', proxies=self.proxy)
content = str(self.__req.get_current_page())
for urls in findall(self.__pattern, content):
if 'www.google.com' in self.URL: self.__list.append(urls)
else: self.__list.append(urls[:-1])
except Exception as e:
input(BR + str(e))
main()
urls = []
class crawl(object):
auth = {
1:
['https://www.google.com', 'class="r"><a href="/url\?q=(.*?)&', 'fl'],
2: ['https://www.bing.com', 'h=".*?" href="(h.*?")', "b_widePag sb_bp"]
}
def __init__(self, dork, proxy=None):
self.dork = dork
self.proxy = proxy
def Bing(self):
bing = Parser(self.dork,
crawl.auth[2][0],
crawl.auth[2][1],
crawl.auth[2][2],
proxy=self.proxy)
bing.request()
for url in dir(bing):
if 'go.microsoft.com' in url or 'bing.com' in url:
pass
else:
urls.append(url)
def Google(self):
google = Parser(self.dork,
crawl.auth[1][0],
crawl.auth[1][1],
crawl.auth[1][2],
proxy=self.proxy)
google.request()
for url in dir(google):
if 'go.microsoft.com' in url or 'bing.com' in url:
pass
else:
urls.append(url)
class dorkscan():
def main(self):
try:
filetemp = str(uuid.uuid4())
filetemp2 = str(uuid.uuid4())
vulntemp = str(uuid.uuid4()) + "_vuln"
os.system(clrcmd)
print(banner)
print(f"{W}[{BR}@{W}]{BG} Dork Scanner{W}")
print(f" ├─[{PINK}Add -s for Scan{W}]")
print(f"{W} │")
dorks = str(input(f"{W} ├─[{O}Dork{W}]{P} "))
proxy = str(input(f"{W} └─[{O}Proxy{W}]{P} "))
prx = BR + "Not Set"
if "-s" in dorks or "--scan" in dorks:
_scan = "y"
sqli = BG + "Scanned"
if "--scan" in dorks:
_dork = dorks.replace("--scan", "")
else:
_dork = dorks.replace("-s", "")
else:
_scan = "n"
sqli = BR + "Not Scanned"
_dork = dorks
if proxy.isspace() or "" in proxy:
proxy = None
prx = BR + "Not Set"
else:
prx = BB + str(proxy)
if not _dork.isspace() or "" in _dork:
pass
else:
input(f"{error}{BR} Input Dork!")
self.main()
print(f"\n{printout}{BO} Dork..: {BB}{_dork}")
print(f"{printout}{BO} SQLi..: {sqli}")
print(f"{printout}{BO} Proxy.: {prx}")
checkConnection("http://www.google.com/search?q=" + _dork, 1)
sys.stdout.write(f"\n{loading}{BO} Try Getting Url...")
nm = re.sub("[*:/<>?|=.~!@#$%^&(); ]", "_", _dork)
mn = nm.replace("\ ", "")
mn1 = mn.replace("'", "")
mn2 = mn1.replace('"', "")
nm = mn2
if _scan == "y":
if _dork != None:
_ = crawl(_dork, proxy=proxy)
_.Bing()
_.Google()
sys.stdout.write(f"\r{success}{BG} Getting Url Success!")
if urls != []:
#for url in list(set(urls)):
# print('- {}'.format(url))
for scan in list(set(urls)):
try:
try:
dq = 0
__vuln = ""
with open("./src/error_sql.txt", 'r') as f:
sqlerror = f.read().splitlines()
with open("./src/adminpages.txt", 'r') as r:
admfound = r.read().splitlines()