forked from dragonked2/Egyscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
egyscan.py
1522 lines (1308 loc) · 60.6 KB
/
egyscan.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 logging
import tqdm
import warnings
import random
import re
import urllib3
import signal
import requests
import sys
import os
import concurrent.futures
import threading
import asyncio
import aiohttp
import ssl
import traceback
import defusedxml.ElementTree as ET
import functools
from queue import Queue
from colorama import Fore, Style, init
from bs4 import BeautifulSoup
from urllib.parse import urlparse, parse_qs, urljoin, quote
from concurrent.futures import ThreadPoolExecutor, as_completed
from itertools import islice
from urllib.robotparser import RobotFileParser
from bs4 import MarkupResemblesLocatorWarning
init(autoreset=True)
USER_AGENTS = [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
]
ALLOWED_HOSTS = ["www.google.com"]
logging.basicConfig(level=logging.WARNING, format="%(levelname)s - %(message)s")
def print_logo():
logo = """
███████╗░██████╗░██╗░░░██╗░██████╗░█████╗░░█████╗░███╗░░██╗
██╔════╝██╔════╝░╚██╗░██╔╝██╔════╝██╔══██╗██╔══██╗████╗░██║
█████╗░░██║░░██╗░░╚████╔╝░╚█████╗░██║░░╚═╝███████║██╔██╗██║
██╔══╝░░██║░░╚██╗░░╚██╔╝░░░╚═══██╗██║░░██╗██╔══██║██║╚████║
███████╗╚██████╔╝░░░██║░░░██████╔╝╚█████╔╝██║░░██║██║░╚███║
╚══════╝░╚═════╝░░░░╚═╝░░░╚═════╝░░╚════╝░╚═╝░░╚═╝╚═╝░░╚══╝
"""
print(logo)
MAX_WORKERS = 50
def load_payloads(file_path='payloads.txt'):
try:
with open(file_path, 'r') as file:
payloads = file.read().splitlines()
return payloads
except FileNotFoundError:
print_error("Payloads file not found. Using default payloads.")
return ["<script>alert('XSS')</script>", "<img src='invalid-image.jpg' onerror='alert(1)'>"]
def check_sqli(url):
try:
response = requests.get(url)
response.raise_for_status()
response_text = response.content.decode('utf-8')
patterns = [
r"You have an error in your SQL syntax",
r"mysql_fetch_array",
r"/var/www",
r"on line",
r"Trying to access array offset on value of type",
r"at line",
r"your MySQL server version",
r"the right syntax to",
r"ORA-[0-9]{5}",
r"DB2 SQL error:",
r"pg_.*\(\):",
r"Microsoft OLE DB Provider for SQL Server",
r"Unclosed quotation mark",
r"ODBC SQL Server Driver",
r"SQLite3::SQLException:",
r"Syntax error or access violation:",
r"Unexpected end of command in statement",
r"PostgreSQL.*ERROR",
r"javax\.persistence\.PersistenceException",
r"ERROR: column .* does not exist",
r"Warning: odbc_.*",
r"Microsoft Access Driver",
r"Syntax error in string in query expression",
r"Microsoft JET Database Engine",
r"Unclosed quotation mark after the character string",
r"Microsoft SQL Native Client error",
r"Error converting data type varchar to numeric",
r"Conversion failed when converting the",
r"Arithmetic overflow error",
r"DBD::Oracle::st execute failed:",
r"SQL Server Native Client",
r"SQLException:",
r"PL/SQL:.*ORA-",
r"mysql_query\(\):",
r"Warning: mysql_.*",
r"Error: 0x",
r"java\.sql\.SQLException",
r"JDBC.*error",
r"Invalid SQL statement or JDBC escape",
r"Microsoft OLE DB Provider for ODBC Drivers",
r"PostgreSQL.*ERROR:",
r"ODBC Driver Manager",
r"SQL command not properly ended",
r"javax\.sql\.rowset\.spi\.SyncProviderException",
r"Invalid column name",
r"Unknown column",
r"Invalid object name",
r"Unclosed quotation mark before the character string",
r"Conversion failed when converting date and/or time",
r"Invalid parameter binding(s)",
r"Data type mismatch",
r"ORA-009.*",
r"DBD::mysql::db do failed:",
r"SQLite error",
r"Warning: sqlsrv_.*",
r"sqlite3_prepare_v2",
r"SQLSTATE\[42000\]",
r"java\.sql\.BatchUpdateException",
r"org\.springframework\.jdbc",
r"MongoDB server version:",
r"Invalid escape character",
r"java\.sql\.SQLSyntaxErrorException",
r"Invalid use of NULL",
r"org\.hibernate\.QueryException",
r"Invalid parameter number",
r"Column count doesn't match",
r"Warning: oci_.*",
r"SQLSTATE\[HY000\]: General error",
r"General error: 7 no connection to the server",
r"Expected end of string",
r"Unexpected character encountered while parsing",
r"FileMaker.*Script Error",
r"java\.lang\.IllegalArgumentException",
r"ORA-12154",
r"ORA-0140[12]",
r"SQLITE_MISUSE",
r"java\.sql\.DataTruncation",
r"Invalid SQL statement",
r"Error while executing SQL script",
r"Column '.*' not found",
r"Invalid object name '.*'",
r"Unknown database '.*'",
r"Table '.*' doesn't exist",
r"ORA-125.*",
r"Warning: mssql_.*",
r"mysql_error",
r"com\.microsoft\.sqlserver\.jdbc",
r"General SQL Server error:",
r"PLS-[0-9]{4}",
r"SQL syntax.*MySQL",
r"SQL Server.*Error",
r"sqlite3_step",
r"mysqli_.*",
r"java\.sql\.SQLException: Invalid column index",
r"org\.apache\.derby",
r"mysql_num_rows",
r"SQLSyntaxErrorException",
r"DB2 SQL error: SQLCODE=-[0-9]+",
r"An error occurred while parsing EntityName",
r"java\.sql\.SQLIntegrityConstraintViolationException",
r"SQLSTATE\[.*\]",
r"SQL Server Native Client.*Invalid object name",
r"An error occurred while preparing the query",
r"Must declare the scalar variable",
r"Invalid column reference",
r"java\.sql\.SQLException: Column not found",
r"java\.sql\.SQLException: No suitable driver",
r"java\.lang\.NullPointerException",
r"SQLSTATE\[3D000\]: Invalid catalog name",
r"ORA-00936",
r"SQLException: Data type mismatch",
r"SQLSTATE\[28000\]: Invalid authorization specification",
r"mysql_numrows",
r"General error: 1017.*Can't find file",
r"Error: ER_NO_SUCH_TABLE",
r"DB2 SQL error: SQLCODE=-206",
r"java\.lang\.IllegalStateException",
r"Error: ER_UNKNOWN_FIELD",
r"java\.sql\.BatchUpdateException: No more data",
r"java\.sql\.SQLException: Invalid parameter index",
r"Error: ER_WRONG_VALUE_COUNT",
r"Error: ER_PARSE_ERROR",
r"java\.lang\.OutOfMemoryError",
r"SQLSTATE\[42000\]: Syntax error or access violation",
r"ERROR: syntax error at or near",
r"Error: ER_CANT_CREATE_TABLE",
r"Warning: mysqli_.*",
r"SQLSTATE\[42S02\]: Base table or view not found",
r"Syntax error in INSERT INTO statement",
r"SQLSTATE\[HYT00\]: Timeout expired",
r"ERROR: relation \".*\" does not exist",
r"Could not find driver",
r"ORA-00933",
r"java\.sql\.SQLException: No value specified for parameter",
r"java\.sql\.SQLException: No data found",
r"ERROR: current transaction is aborted",
r"java\.sql\.SQLException: Data truncation",
r"SQLSTATE\[22001\]: String data, right truncated",
r"ERROR: invalid input syntax for type",
r"ERROR: permission denied for relation",
r"Column count doesn't match value count",
r"java\.sql\.SQLException: Column count doesn't match",
r"SQLSTATE\[08001\]: Unable to connect to database",
r"ERROR: INSERT has more expressions",
r"SQLSTATE\[42S22\]: Column not found",
r"ORA-00932",
r"SQLSTATE\[23000\]: Integrity constraint violation",
r"java\.sql\.SQLException: Column name mismatch",
r"SQLSTATE\[HY000\]: General error: 1025",
r"ERROR: duplicate key value violates unique constraint",
r"ERROR: division by zero",
r"java\.lang\.ArrayIndexOutOfBoundsException",
r"SQLSTATE\[08004\]: Server rejected the connection",
r"javax\.persistence\.TransactionRequiredException",
r"ERROR: invalid input syntax for type numeric",
r"Syntax error in UPDATE statement",
r"Error: ER_DUP_ENTRY",
r"java\.sql\.SQLException: Field '.*' doesn't have a default value",
r"ERROR: relation \".*\" already exists",
r"ERROR: invalid input syntax for type boolean",
r"SQLSTATE\[22P02\]: Invalid text representation",
r"SQLSTATE\[40001\]: Serialization failure",
r"ERROR: operator does not exist: ",
r"Warning: odbc_exec\(\):",
r"java\.sql\.SQLException: ResultSet closed",
r"SQLSTATE\[HYT00\]: Timeout expired: native",
r"ERROR: duplicate key violates unique constraint",
r"java\.sql\.SQLException: Invalid object name",
r"ERROR: invalid byte sequence for encoding",
r"SQLSTATE\[42S12\]: Column not found",
r"ORA-02291",
r"Error: ER_ACCESS_DENIED_ERROR",
r"SQLSTATE\[08006\]: No connection",
r"java\.sql\.SQLException: ORA-02292",
r"SQLSTATE\[23505\]: Unique constraint",
r"ERROR: missing FROM-clause entry for table",
r"java\.sql\.SQLRecoverableException",
r"java\.sql\.SQLException: Integrity constraint violation",
r"SQLSTATE\[22018\]: Invalid character value",
r"SQLSTATE\[08003\]: No connection",
r"Error: ER_TABLE_EXISTS_ERROR",
r"ORA-00001",
r"ERROR: null value in column",
r"ORA-01438",
r"ERROR: duplicate key value violates unique",
r"ERROR: unterminated quoted string",
r"java\.sql\.SQLTimeoutException",
r"ORA-01400",
r"SQLSTATE\[HY000\]: General error: 2006 MySQL",
r"SQLSTATE\[42000\]: Syntax error or access violation: 1064",
r"java\.sql\.SQLException: Table/View '.*' does not exist",
r"SQLSTATE\[42S02\]: Base table or view not found: 1146",
r"ERROR: syntax error at end of input",
r"java\.sql\.SQLException: ResultSet not open",
r"SQLSTATE\[08001\]: [0-9]{1,10} SQLDriverConnect",
r"java\.sql\.SQLException: ORA-01461",
r"SQLSTATE\[HY000\]: General error: 1364",
r"ERROR: column reference \".*\" is ambiguous",
r"ORA-06512",
r"Error: ER_BAD_FIELD_ERROR",
r"SQLSTATE\[IM002\]: Data source name not found",
r"java\.lang\.ArrayIndexOutOfBoundsException:",
r"SQLSTATE\[42S12\]: Column not found: 1054",
r"ERROR: column .* cannot be cast to type .*",
r"ERROR: operator does not exist",
r"java\.sql\.SQLException: ResultSet is closed",
r"ORA-00904",
r"ERROR: failed to find conversion function from unknown to text",
r"ERROR: cannot insert multiple commands into a prepared statement",
r"ERROR: relation \".*\" does not exist at character",
r"java\.sql\.SQLException: ORA-02291",
r"SQLSTATE\[HY000\]: General error: 1366",
r"ERROR: column \".*\" does not exist",
r"ERROR: syntax error at or near \".*\"",
r"java\.lang\.NoSuchMethodError",
r"SQLSTATE\[08006\]: No connection to the server",
r"SQLSTATE\[23502\]: Not null violation",
r"ERROR: syntax error at or near \"[^\"]+\"",
r"java\.sql\.SQLException: No value specified",
r"ERROR: relation \".*\" already exists at character",
r"ORA-02292",
r"SQLSTATE\[23000\]: Integrity constraint violation: 1452",
r"SQLSTATE\[HY093\]: Invalid parameter number: no parameters",
r"java\.sql\.SQLNonTransientConnectionException",
r"SQLSTATE\[HY000\]: General error: 1418",
r"ERROR: column \".*\" specified more than once",
r"java\.sql\.SQLTransientConnectionException",
r"ERROR: value too long for type character varying",
r"SQLSTATE\[42000\]: Syntax error or access violation: 1055",
r"java\.sql\.SQLException: Column '.*' not found",
r"SQLSTATE\[42000\]: Syntax error or access violation: 1142",
r"ERROR: syntax error at or near \".*\" at character",
r"java\.lang\.NoSuchMethodException",
r"SQLSTATE\[22005\]: Data exception: string data",
r"ERROR: column \".*\" specified more than once at character",
r"SQLSTATE\[42000\]: Syntax error or access violation: 1067",
r"java\.sql\.SQLFeatureNotSupportedException",
r"SQLSTATE\[HY093\]: Invalid parameter number",
r"ERROR: current transaction is aborted,",
r"SQLSTATE\[42000\]: Syntax error or access violation: 1136",
r"java\.lang\.ClassCastException",
r"ERROR: current transaction is aborted, commands",
r"SQLSTATE\[HY000\]: General error: 1360",
r"ERROR: column \".*\" of relation \".*\" does not exist",
r"ERROR: invalid byte sequence for encoding \"UTF8\"",
r"SQLSTATE\[08006\]: No connection to the server:",
r"ERROR: column \".*\" of relation \".*\" does not exist at character",
r"ERROR: could not open file",
r"SQLSTATE\[22007\]: Invalid datetime format: 1292",
r"ERROR: unterminated quoted string at or near",
r"java\.sql\.SQLIntegrityConstraintViolationException: Duplicate entry",
r"SQLSTATE\[HY000\]: General error: 1021",
r"java\.sql\.SQLException: No results were returned",
r"ERROR: unterminated quoted string at or near \".*\"",
r"java\.sql\.SQLException: ORA-00904",
r"SQLSTATE\[42000\]: Syntax error or access violation: 1093",
r"ERROR: relation \".*\" does not exist LINE",
r"SQLSTATE\[HY000\]: General error: 1055",
r"ERROR: unterminated quoted string at or near \".*\" at character",
r"java\.lang\.NoSuchFieldError",
r"SQLSTATE\[08003\]: No connection to the server",
r"ERROR: relation \".*\" does not exist LINE.*SQL",
r"ERROR: relation \".*\" already exists LINE.*SQL",
r"ERROR: unterminated quoted string at or near \".*\" LINE",
r"java\.lang\.ClassNotFoundException",
r"ERROR: relation \".*\" does not exist at character.*LINE",
r"ERROR: unterminated quoted string at or near \".*\" at character.*LINE",
r"java\.lang\.NoSuchMethodException: .*set[a-zA-Z]+",
r"SQLSTATE\[HY000\]: General error: 2013",
r"java\.lang\.ClassCastException: ",
r"SQLSTATE\[42000\]: Syntax error or access violation: 1109",
r"ERROR: relation \".*\" already exists LINE",
r"java\.lang\.IllegalAccessException",
r"java\.sql\.SQLException: Invalid object name.*LINE",
r"ERROR: column \".*\" specified more than once at character.*LINE",
r"java\.lang\.ClassCastException:.*LINE",
r"ERROR: current transaction is aborted, commands ignored until end of transaction block.*LINE",
r"ERROR: column \".*\" of relation \".*\" does not exist at character.*LINE",
r"ERROR: invalid byte sequence for encoding \"UTF8\".*LINE",
r"ERROR: column \".*\" of relation \".*\" does not exist LINE.*SQL",
r"ERROR: could not open file.*LINE",
r"ERROR: unterminated quoted string at or near.*LINE",
r"ERROR: duplicate key violates unique constraint.*LINE",
r"java\.sql\.SQLException: ORA-00904.*LINE",
r"ERROR: duplicate key value violates unique constraint.*LINE",
]
for pattern in patterns:
if re.search(pattern, response_text):
return True
except (requests.RequestException, UnicodeDecodeError):
pass
return False
def check_rce(url):
try:
response = requests.get(url)
response.raise_for_status()
rce_patterns = [
r"(?i)root:",
r"(?i)shadow",
r"(?i)cmd",
]
for pattern in rce_patterns:
if re.search(pattern, response.text):
if "json_encode" in response.text or "json_decode" in response.text:
continue
if "base64_encode" in response.text or "base64_decode" in response.text:
continue
if "urlencode" in response.text or "urldecode" in response.text:
continue
if "htmlentities" in response.text or "htmlspecialchars" in response.text:
continue
return True
except (requests.RequestException, UnicodeDecodeError):
pass
return False
def check_xss(url):
try:
response = requests.get(url)
response.raise_for_status()
xss_patterns = [
r"AliElTop",
]
for pattern in xss_patterns:
if re.search(pattern, response.text, re.IGNORECASE):
return True
except (requests.RequestException, UnicodeDecodeError):
pass
return False
def check_lfi(url):
try:
response = requests.get(url)
response.raise_for_status()
lfi_patterns = [
r"include\s*[\"'][^\"']+\.php[\"']",
r"require\s*[\"'][^\"']+\.php[\"']",
r"include_once\s*[\"'][^\"']+\.php[\"']",
r"require_once\s*[\"'][^\"']+\.php[\"']",
r"php://filter/.*read=convert.base64-.*resource=[^&]+",
r"data:text\/html;base64,",
r"zlib:\/\/",
r"php:\/\/filter\/",
r"filter\.var_dump",
r"file(?:_get_(?:contents|contents|contents)|_contents)\s*\(\s*[\"'][^\"']+\.(?:php(?:3|4|5|7)?|phtml)[\"']",
r"(?i)\b(?:[a-z]+://|\.{0,2}/)\w+(?:/[\w./]*)*\.php(?:[?#]|$)",
r"\.\./",
r"\/\/",
r"file:\/\/\/",
r"index\.php",
r"phpinfo\s*\(",
r"highlight_file\s*\(",
r"var_dump\s*\(",
r"getenv\s*\(",
r"show_source\s*\(",
r"readlink\s*\(",
r"readfile\s*\(",
r"exif_read_data\s*\(",
r"system\s*\(",
r"shell_exec\s*\(",
r"exec\s*\(",
r"passthru\s*\(",
r"popen\s*\(",
r"proc_open\s*\(",
r"assert\s*\(",
r"eval\s*\(",
r"file_put_contents\s*\(",
r"fopen\s*\(",
r"copy\s*\(",
r"move_uploaded_file\s*\(",
r"tempnam\s*\(",
r"rename\s*\(",
r"symlink\s*\(",
]
for pattern in lfi_patterns:
if re.search(pattern, response.text, re.IGNORECASE):
test_url = url + "/index.php"
test_response = requests.get(test_url)
if test_response.status_code == 200 and "Test Successful" in test_response.text:
return True, "Local File Inclusion: Possible local file inclusion vulnerability detected."
except (requests.RequestException, UnicodeDecodeError) as e:
print(f"Error occurred: {e}")
return False
def check_open_redirect(url):
try:
response = requests.get(url)
response.raise_for_status()
payload = "http://www.google.com"
sanitized_url = urljoin(url, payload)
parsed_url = urlparse(sanitized_url)
if parsed_url.netloc in ALLOWED_HOSTS:
redirect_response = requests.get(sanitized_url, allow_redirects=False)
if redirect_response.status_code == 302 and is_valid_redirect(redirect_response.headers.get('Location')):
test_url = url + "/test"
test_response = requests.get(test_url)
if test_response.status_code == 200 and "Test Successful" in test_response.text:
return True, "Open Redirect: Possible open redirect vulnerability detected."
except requests.RequestException:
pass
return False
def is_valid_redirect(redirect_url):
parsed_redirect_url = urlparse(redirect_url)
return parsed_redirect_url.scheme in ['http', 'https'] and parsed_redirect_url.netloc == "www.google.com"
def check_backup_files(url):
extensions = [".bak", ".zip", ".tgz", ".sql"]
parsed_url = urlparse(url)
for extension in extensions:
backup_url = f"{parsed_url.scheme}://{parsed_url.netloc}{parsed_url.path}{extension}"
response = requests.get(backup_url)
if response.status_code == 200 and is_valid_backup(response.headers.get('Content-Type'), response.content):
return True, "Backup Files: Possible backup file found."
return False
def is_valid_backup(content_type, content):
valid_types = {"application/octet-stream", "application/zip", "application/x-gzip"}
if content_type in valid_types:
return not is_binary_file(content)
return False
def is_binary_file(file):
try:
return isinstance(file.read(0), bytes)
except io.UnsupportedOperation:
return True
def check_database_exposure(url):
endpoints = ["phpmyadmin", "adminer", "dbadmin"]
for endpoint in endpoints:
full_url = url.rstrip("/") + "/" + endpoint
response = requests.head(full_url)
if response.status_code == 200 and is_database_console(response.headers.get('Content-Type')):
test_url = url + "/test"
test_response = requests.get(test_url)
if test_response.status_code == 200 and "Test Successful" in test_response.text:
return True, "Database Exposure: Possible database administration console found."
return False
def is_database_console(content_type):
valid_types = {"text/html", "text/plain"}
return content_type in valid_types
def check_directory_listings(url):
response = requests.get(url, allow_redirects=False)
if response.status_code == 200 and is_directory_listing(response.headers.get('Content-Type'), response.text):
return True, "Directory Listings: Possible directory listing enabled."
return False
def is_directory_listing(content_type, response_text):
valid_types = {"text/html"}
return content_type in valid_types and "Index of" in response_text
def check_sensitive_information(url):
keywords = ["private_key", "creditcard", "api_key", "secret_key", "access_token", "auth_token"]
response = requests.get(url)
response_text = response.text.lower()
for keyword in keywords:
if keyword in response_text:
test_url = url + "/test"
test_response = requests.get(test_url)
if test_response.status_code == 200 and "Test Successful" in test_response.text:
return True, "Sensitive Information: Possible sensitive information exposed."
return False
def check_log_files(url):
log_files = ["access.log", "error.log", "log.log"]
parsed_url = urlparse(url)
for log_file in log_files:
log_url = f"{parsed_url.scheme}://{parsed_url.netloc}/{log_file}"
response = requests.get(log_url)
if response.status_code == 200 and is_valid_log_file(response.headers.get('Content-Type'), response.content):
return True, "Log Files: Possible log file exposure."
return False
def is_valid_log_file(content_type, content):
valid_types = {"text/plain"}
return content_type in valid_types and not is_binary_file(content)
def check_xxe(url):
try:
response = requests.get(url)
response.raise_for_status()
payload = '<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE foo [<!ELEMENT foo ANY ><!ENTITY xxe SYSTEM "file:///etc/passwd" >]><foo>&xxe;</foo>'
headers = {'Content-Type': 'application/xml'}
xxe_response = requests.post(url, data=payload, headers=headers)
if xxe_response.status_code == 200 and is_xxe_detected(xxe_response.text):
test_url = url + "/test"
test_response = requests.get(test_url)
if test_response.status_code == 200 and "Test Successful" in test_response.text:
return True, "XML External Entity (XXE): Possible XXE vulnerability detected."
except requests.RequestException:
pass
return False
def is_xxe_detected(response_text):
xxe_keywords = ["root:", "admin:", "password:", "etc/passwd"]
return any(keyword in response_text for keyword in xxe_keywords)
def check_ssrf(url):
try:
response = requests.get(url)
response.raise_for_status()
payload = "http://169.254.169.254/latest/meta-data/iam/security-credentials/admin"
params = {'url': payload}
ssrf_response = requests.get(url, params=params)
if ssrf_response.status_code == 200 and is_ssrf_detected(ssrf_response.text):
test_url = url + "/test"
test_response = requests.get(test_url)
if test_response.status_code == 200 and "Test Successful" in test_response.text:
return True, "Server-Side Request Forgery (SSRF): Possible SSRF vulnerability detected."
except requests.RequestException:
pass
return False
def is_ssrf_detected(response_text):
ssrf_keywords = ["AccessDenied", "Forbidden", "Unauthorized"]
return any(keyword in response_text for keyword in ssrf_keywords)
def check_rfi(url):
try:
response = requests.get(url)
response.raise_for_status()
payload = "https://raw.githubusercontent.com/dragonked2/Egyscan/main/README.md"
rfi_response = requests.get(url + "?file=" + payload)
if rfi_response.status_code == 200 and is_rfi_detected(rfi_response.text):
test_url = url + "/test"
test_response = requests.get(test_url)
if test_response.status_code == 200 and "Test Successful" in test_response.text:
return True, "Remote File Inclusion (RFI): Possible RFI vulnerability detected."
except requests.RequestException:
pass
return False
def is_rfi_detected(response_text):
rfi_keywords = ["EgyScan V2.0", "RFI Detected", "Remote File Inclusion"]
return any(keyword in response_text for keyword in rfi_keywords)
def check_idor(url):
try:
response = requests.get(url)
response.raise_for_status()
if re.search(r'id=["\']([^"\']+)', response.text, re.IGNORECASE):
test_url = url + "/test"
test_response = requests.get(test_url)
if test_response.status_code == 200 and "Test Successful" in test_response.text:
return True, "Insecure Direct Object Reference (IDOR): Possible IDOR vulnerability detected."
except requests.RequestException:
pass
return False
def check_cors(url):
try:
response = requests.get(url)
response.raise_for_status()
if 'Access-Control-Allow-Origin' in response.headers:
test_url = url + "/test"
test_response = requests.get(test_url)
if test_response.status_code == 200 and "Test Successful" in test_response.text:
return True, "Cross-Origin Resource Sharing (CORS): Possible CORS vulnerability detected."
except requests.RequestException:
pass
return False
def check_csrf(url):
try:
session = requests.Session()
response = session.get(url)
response.raise_for_status()
csrf_token = None
if 'Set-Cookie' in response.headers:
cookies = session.cookies.get_dict()
csrf_token = cookies.get('csrftoken')
if not csrf_token:
if 'csrf_token' in response.text:
match = re.search(r'<input[^>]+name=["\']csrf_token["\'][^>]+value=["\']([^"\']+)["\']', response.text, re.IGNORECASE)
if match:
csrf_token = match.group(1)
if csrf_token:
headers = {'Referer': url, 'X-CSRFToken': csrf_token}
test_url = url + "/test"
test_response = session.post(test_url, headers=headers)
if test_response.status_code == 200 and "Test Successful" in test_response.text:
return True, "Cross-Site Request Forgery (CSRF): Possible CSRF vulnerability detected."
except requests.RequestException:
pass
return False
def check_command_injection(url):
try:
response = requests.get(url)
response.raise_for_status()
if re.search(r'(\bexec\b|\bpopen\b|\bshell_exec\b)', response.text, re.IGNORECASE):
if re.search(r'Command Injection', response.text, re.IGNORECASE):
command = "echo vulnerable"
response = requests.get(url + "&command=" + command)
if "vulnerable" in response.text:
return True, "Command Injection: Potential command execution function found in the response."
except requests.RequestException:
pass
return False
def check_file_upload_vulnerabilities(url):
try:
response = requests.get(url)
response.raise_for_status()
if 'multipart/form-data' in response.headers:
if re.search(r'File Upload Vulnerabilities', response.text, re.IGNORECASE):
files = {'file': open('test.php', 'rb')}
response = requests.post(url, files=files)
if "File uploaded successfully" in response.text:
return True, "File Upload Vulnerabilities: Multipart form data detected in the response."
except requests.RequestException:
pass
return False
def check_authentication_bypass(url):
try:
response = requests.get(url)
response.raise_for_status()
if 'Authentication' in response.headers and response.status_code != 401:
if re.search(r'Authentication Bypass', response.text, re.IGNORECASE):
session = requests.Session()
bypass_response = session.get(url)
if bypass_response.status_code != 401:
return True, "Authentication Bypass: Possible authentication bypass detected."
except requests.RequestException:
pass
return False
def check_insecure_configuration(url):
try:
response = requests.get(url)
response.raise_for_status()
if re.search(r'(config|configuration)', response.text, re.IGNORECASE):
if re.search(r'Insecure Configuration', response.text, re.IGNORECASE):
test_url = url + "/test"
response = requests.get(test_url)
if response.status_code == 200 and "Test Successful" in response.text:
return True, "Insecure Configuration: Possible configuration information found in the response."
except requests.RequestException:
pass
return False
def check_server_misconfiguration(url):
try:
response = requests.get(url)
response.raise_for_status()
if re.search(r'(Misconfiguration|error)', response.text, re.IGNORECASE):
if re.search(r'Server Misconfiguration', response.text, re.IGNORECASE):
test_url = url + "/test"
response = requests.get(test_url)
if response.status_code == 200 and "Test Successful" in response.text:
return True, "Server Misconfiguration: Possible server misconfiguration detected."
except requests.RequestException:
pass
return False
def check_injection_flaws(url):
try:
response = requests.get(url)
response.raise_for_status()
if re.search(r'(injection|inject)', response.text, re.IGNORECASE):
if re.search(r'Injection Flaws', response.text, re.IGNORECASE):
test_payload = "1' OR '1'='1"
response = requests.get(url + "?param=" + test_payload)
if "Injection Successful" in response.text:
return True, "Injection Flaws: Possible injection vulnerability detected."
except requests.RequestException:
pass
return False
def check_weak_session_management(url):
try:
response = requests.get(url)
response.raise_for_status()
if re.search(r'(session|cookie)', response.text, re.IGNORECASE):
if re.search(r'Weak Session Management', response.text, re.IGNORECASE):
session = requests.Session()
session_response = session.get(url)
if session_response.cookies and session_response.cookies.get('session_id'):
session_id = session_response.cookies['session_id']
session.cookies.set('session_id', session_id)
test_url = url + "/test"
test_response = session.get(test_url)
if test_response.status_code == 200 and "Test Successful" in test_response.text:
return True, "Weak Session Management: Possible weak session management detected."
except requests.RequestException:
pass
return False
def check_clickjacking(url):
try:
response = requests.get(url)
response.raise_for_status()
if 'X-Frame-Options' not in response.headers or 'Content-Security-Policy' not in response.headers:
if re.search(r'Clickjacking', response.text, re.IGNORECASE):
test_url = url + "/test"
response = requests.get(test_url)
if "Test Successful" in response.text:
return True, "Clickjacking: Missing X-Frame-Options or Content-Security-Policy headers."
except requests.RequestException:
pass
return False
def check_host_header_injection(url):
try:
response = requests.get(url)
response.raise_for_status()
if 'Host' in response.headers and 'X-Forwarded-Host' not in response.headers:
if re.search(r'Host Header Injection', response.text, re.IGNORECASE):
headers = {'Host': 'example.com'}
response = requests.get(url, headers=headers)
if "Injection Successful" in response.text:
return True, "Host Header Injection: Possible Host header injection detected."
except requests.RequestException:
pass
return False
def check_remote_file_execution(url):
try:
response = requests.get(url)
response.raise_for_status()
if re.search(r'(include|require|include_once|require_once)\s*["\'][^"\']+\.php["\']', response.text, re.IGNORECASE):
if re.search(r'Remote File Execution', response.text, re.IGNORECASE):
include_url = url + "?file=php://filter/convert.base64-encode/resource=config"
response = requests.get(include_url)
if "Include Successful" in response.text:
return True, "Remote File Execution: Possible remote file inclusion detected."
except requests.RequestException:
pass
return False
def check_brute_force_attacks(url):
try:
response = requests.get(url)
response.raise_for_status()
if 'Login' in response.text or 'Username' in response.text or 'Password' in response.text:
if re.search(r'Brute Force Attacks', response.text, re.IGNORECASE):
session = requests.Session()
for i in range(3):
login_data = {'username': 'admin', 'password': '123456'}
response = session.post(url + "/login", data=login_data)
if response.status_code == 200 and "Login Failed" in response.text:
return True, "Brute Force Attacks: Possible login page or authentication mechanism detected."
except requests.RequestException:
pass
return False
def check_security_misconfiguration(url):
try:
response = requests.get(url)
response.raise_for_status()
if re.search(r'(Security|secure|misconfiguration)', response.text, re.IGNORECASE):
if re.search(r'Security Misconfiguration', response.text, re.IGNORECASE):
test_url = url + "/test"
response = requests.get(test_url)
if response.status_code == 200 and "Test Successful" in response.text:
return True, "Security Misconfiguration: Possible security misconfiguration detected."
except requests.RequestException:
pass
return False
def check_missing_authentication(url):
try:
response = requests.get(url)
response.raise_for_status()
if 'Authentication' not in response.headers and response.status_code != 401:
if re.search(r'Missing Authentication', response.text, re.IGNORECASE):
test_url = url + "/test"
response = requests.get(test_url)
if response.status_code == 200 and "Test Successful" in response.text:
return True, "Missing Authentication: Possible missing authentication mechanism."
except requests.RequestException:
pass
return False
def check_crlf_injection(url):
try:
response = requests.get(url)
response.raise_for_status()
if re.search(r'%0D%0A|[\r\n]|%0D|%0A', response.text, re.IGNORECASE):
if re.search(r'CRLF Injection', response.text, re.IGNORECASE):
payload = "Injected%0D%0AContent:%20Test"
response = requests.get(url + "?param=" + payload)
if "Injection Successful" in response.text:
return True, "CRLF Injection: Possible CRLF injection detected."
except requests.RequestException:
pass
return False
def check_session_fixation(url):
try:
response = requests.get(url)
response.raise_for_status()
if 'Session' in response.headers and 'Set-Cookie' in response.headers:
if re.search(r'Session Fixation', response.text, re.IGNORECASE):
session = requests.Session()
test_url = url + "/test"
response = session.get(test_url)
if response.status_code == 200 and "Test Successful" in response.text:
return True, "Session Fixation: Possible session fixation vulnerability detected."
except requests.RequestException:
pass
return False
def check_unvalidated_redirects(url):
try:
response = requests.get(url)
response.raise_for_status()
if 'Location' in response.headers and response.status_code in [301, 302, 303, 307, 308]:
if re.search(r'Unvalidated Redirects', response.text, re.IGNORECASE):
redirect_url = "https://www.github.com/dragonked2/Egyscan"
response = requests.get(url + "?redirect=" + redirect_url)
if "Redirect Successful" in response.text:
return True, "Unvalidated Redirects: Possible unvalidated redirects detected."
except requests.RequestException:
pass
return False
def check_command_execution(url):
try:
response = requests.get(url)
response.raise_for_status()
if re.search(r'(exec|popen|shell_exec|system|passthru|proc_open)\s*[(\']', response.text, re.IGNORECASE):
if re.search(r'Command Execution', response.text, re.IGNORECASE):
command = "echo vulnerable"
response = requests.get(url + "&command=" + command)
if "vulnerable" in response.text:
return True, "Command Execution: Possible command execution function found in the response."
except requests.RequestException:
pass
return False
def check_cross_site_tracing(url):
try:
response = requests.get(url)
response.raise_for_status()
if 'TRACE' in response.text or 'TRACE' in response.headers:
if re.search(r'Cross-Site Tracing', response.text, re.IGNORECASE):
test_url = url + "/test"
headers = {'TRACE': '1'}
response = requests.get(test_url, headers=headers)
if "TRACE Successful" in response.text:
return True, "Cross-Site Tracing: TRACE method enabled."
except requests.RequestException:
pass
return False
def check_server_side_template_injection(url):
try:
response = requests.get(url)
response.raise_for_status()
if re.search(r'(template|render|smarty|twig|mustache|handlebars|liquid|jinja)', response.text, re.IGNORECASE):
if re.search(r'Server-Side Template Injection', response.text, re.IGNORECASE):
payload = "{{7*7}}"
response = requests.get(url + "?param=" + payload)
if "49" in response.text:
return True, "Server-Side Template Injection: Possible server-side template injection detected."
except requests.RequestException:
pass