-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoSDetectionScript.py
More file actions
87 lines (76 loc) · 6.48 KB
/
DoSDetectionScript.py
File metadata and controls
87 lines (76 loc) · 6.48 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
from scapy.all import sniff
from collections import defaultdict
import time
THRESHOLD = 100 # Change this number to the amount of allowed packets per second
packet_count = defaultdict(int)
def detect_dos(packet):
if packet.haslayer('IP'):
ip = packet['IP'].src
packet_count[ip] += 1
def monitor_traffic(duration=1):
start = time.time()
while True:
sniff(prn=detect_dos, timeout=duration)
end = time.time()
duration_sec = end - start
if duration_sec >= duration:
for ip, count in packet_count.items():
if count > THRESHOLD:
print(f"[!] DoS ATTACK DETECTED from: {ip}: {count} packets in {duration_sec:.2f} seconds.")
packet_count.clear()
start = time.time()
if __name__ == "__main__":
print(r"""
................................................:::-:.................... . --:.....................
..........:::::...........::::::::::--======.##########.======---------==.. ===:-:..................
====-:-----=============================##########.##=.. ================.. ===-----:::::...........
======================================############..#= ===============.. ==.=====================
====================================############....#. ===============.. ==.=====================
=================================############## #. ==============.. ========================
==============================. ############= #. =============#. ========================
================================. ###.#.#. #. ============.. ========================
================================= .#..# .. ===========.. ========================
================================= .. ==========-##.========================
=================================@ . =========.# ========================
==================================. . =======.. =======================
===================================# . #. ======@. =======================
======-============================@ # #. ##. ======. ========================
==..##..#######............=========# . . #####.... -=.== =.=====================
==..######@########################### . ##### ##.... = = ##==#..######........===
==..###=@=@########################### ####.##. . . #@.##################===
==..###===############################# #=#######= .: =. .#############===@===
==..###=################################ ###### . = =####..#######====*@==
==..###.################################ . = == =- .############=====@==
*=..###=#@############################## = = =-###########========
@=..###=##.############################# #.# .. .= ############====@===
@=..###=###############################* ### #. .############====@===
@=..###=##.############################. ### #. . #################===
@=..###=##=############################= @.# #. . ################===
@=..###=##################################### ##= ##############=#===
@=..###=###############.=########@###### #.###.. .###########@====@@@
@=..###=############..## .## ###### #### ###########%====..:
....###=##@@#######....... ##### # ##= #= = .##########-.### ..
....##############.. . :#=#.. #. = ...--:...........
.. .############. .. # .####- =.- = ##.....:.........
..........###. .... .###.### #- ## = = #####.#=.........
.............. .#...... . ####### #####. .#....... ... ...
............############ #. .#. .== .. .....##........
...#########.##########: # ... . .#.+..-#..#......
####################.. .#. . . ...:.#............
████████╗██╗ ██╗███████╗ ██████╗ ██████╗ ██╗ ██╗██████╗ ███████╗██████╗
╚══██╔══╝██║ ██║██╔════╝ ██╔══██╗ ╚════██╗██║ ██║██╔══██╗██╔════╝██╔══██╗
██║ ███████║█████╗ █████╗ ██████╔╝ █████╔╝███████║██████╔╝█████╗ ██████╔╝
██║ ██╔══██║██╔══╝ ╚════╝ ██╔══██╗ ╚═══██╗╚════██║██╔═══╝ ██╔══╝ ██╔═██╗
██║ ██║ ██║███████╗ ██║ ██║██████╔╝ ██║██║ ███████╗██║ ██║
╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚══════╝╚═╝ ╚═╝
Python DoS Detection Script
Created by: The-R34per
GitHub: https://github.com/The-R34per
Website: https://the-r34per.github.io/The-R34per-Website/index.html
-----------------------------------------------------------------------------------------------------""")
time.sleep(2)
print("\n\nStarting DoS Detection Script....Press Ctr+C to stop.")
try:
monitor_traffic()
except KeyboardInterrupt:
print("\nStopping DoS Detection Script.")