-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
62 lines (41 loc) · 1.21 KB
/
Copy pathapp.py
File metadata and controls
62 lines (41 loc) · 1.21 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
from flask import Flask, render_template, jsonify, request
import sniffer
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/start", methods=["POST"])
def start():
sniffer.begin_capture()
return jsonify({"status": "started"})
@app.route("/stop", methods=["POST"])
def stop():
sniffer.end_capture()
return jsonify({"status": "stopped"})
@app.route("/packets")
def packets():
protocol = request.args.get("protocol", "")
src_ip = request.args.get("src_ip", "")
dst_ip = request.args.get("dst_ip", "")
if protocol == "":
protocol = None
if src_ip == "":
src_ip = None
if dst_ip == "":
dst_ip = None
data = sniffer.get_packets(protocol=protocol, src_ip=src_ip, dst_ip=dst_ip)
return jsonify(data)
@app.route("/stats")
def stats():
data = sniffer.get_stats()
return jsonify(data)
@app.route("/status")
def status():
return jsonify({"capture_active": sniffer.capture_active})
@app.route("/logs")
def logs():
session = request.args.get("session", None)
data = sniffer.load_csv_logs(session=session)
return jsonify(data)
if __name__ == "__main__":
app.run(debug=True)