-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.py
86 lines (73 loc) · 2.33 KB
/
start.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
#!/usr/bin/env python3
from flask import Flask, render_template
from MODULES.portScans import ScanDetector
from MODULES.pingOfDeath import PingOfDeath
from MODULES.landattack import landAttack
from MODULES.synflood import synFlood
from MODULES.ddos import Ddos
from MODULES.Wifi.deauth import Deauth
from MODULES.arp import arpSpoof
from MODULES.smurf import Smurf
from MODULES.idleScan import IDLEScanDetector
from MODULES.RogueDHCP import RogueDHCPServerDetector
from scapy.all import IP, sniff
import sys
from netifaces import interfaces
from flask import request
app = Flask(__name__, template_folder='templates')
app.secret_key = 'mysecretkey'
# Initialize IDS modules
print('Initializing...')
dummyPkt = IP(dst='123.123.123.123')
myIP = str(dummyPkt[IP].src)
scanObj=ScanDetector(myIP)
podObj=PingOfDeath(myIP)
synobj=synFlood(myIP)
ddosobj=Ddos(myIP)
deauthobj=Deauth()
arpobj=arpSpoof(myIP)
smurfobj=Smurf(myIP)
#idleobj=IDLEScanDetector("eth0")
#dhcp_detector = RogueDHCPServerDetector("eth0")
# Sniff packets and detect attacks
@app.route("/")
def index():
return render_template('index.html', data=interfaces())
@app.route("/start")
def start_sniffing():
def main(pkt):
scanObj.oneForAll(pkt)
podObj.podDetect(pkt)
landAttack(pkt,myIP)
ddosobj.detectDdos(pkt)
synobj.detectSyn(pkt)
deauthobj.detectDeauth(pkt)
smurfobj.detectSmurf(pkt)
#dhcp_detector.start_sniffing()
interface = request.args.get('interface')
# Start sniffing
#interface=sys.argv[1]
print('IDS is online and looking for attacks on ', interface)
sniff(iface=interface, prn=main)
@app.route('/alerts')
def display():
file_path = 'LOGS/current.txt'
data = []
with open(file_path, 'r') as file:
for line in file:
data.append(line.strip())
#copy_file('example.txt','log.txt')
return render_template('index.html', data=data)
@app.route('/previous-logs')
def display_all():
file_path = 'LOGS/logs.txt'
data = []
with open(file_path, 'r') as file:
for line in file:
data.append(line.strip())
#copy_file('example.txt','log.txt')
return render_template('index.html', data=data)
if __name__ == '__main__':
with open('LOGS/current.txt', 'w') as f: #empty the current file at start of program.
pass
app.run(debug=True)