First commit!
This commit is contained in:
29
server/frontend/app/blueprints/analysis.py
Executable file
29
server/frontend/app/blueprints/analysis.py
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import re
|
||||
import os
|
||||
import json
|
||||
import sys
|
||||
from flask import Blueprint, jsonify
|
||||
from app.classes.analysis import Analysis
|
||||
import subprocess as sp
|
||||
import json
|
||||
|
||||
analysis_bp = Blueprint("analysis", __name__)
|
||||
|
||||
|
||||
@analysis_bp.route("/start/<token>", methods=["GET"])
|
||||
def api_start_analysis(token):
|
||||
"""
|
||||
Start an analysis
|
||||
"""
|
||||
return jsonify(Analysis(token).start())
|
||||
|
||||
|
||||
@analysis_bp.route("/report/<token>", methods=["GET"])
|
||||
def api_report_analysis(token):
|
||||
"""
|
||||
Get the report of an analysis
|
||||
"""
|
||||
return jsonify(Analysis(token).get_report())
|
26
server/frontend/app/blueprints/capture.py
Executable file
26
server/frontend/app/blueprints/capture.py
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from flask import jsonify, Blueprint
|
||||
from app.classes.capture import Capture
|
||||
|
||||
capture = Capture()
|
||||
capture_bp = Blueprint("capture", __name__)
|
||||
|
||||
|
||||
@capture_bp.route("/start", methods=["GET"])
|
||||
def api_capture_start():
|
||||
""" Start the capture """
|
||||
return jsonify(capture.start_capture())
|
||||
|
||||
|
||||
@capture_bp.route("/stop", methods=["GET"])
|
||||
def api_capture_stop():
|
||||
""" Stop the capture """
|
||||
return jsonify(capture.stop_capture())
|
||||
|
||||
|
||||
@capture_bp.route("/stats", methods=["GET"])
|
||||
def api_capture_stats():
|
||||
""" Stop the capture """
|
||||
return jsonify(capture.get_capture_stats())
|
13
server/frontend/app/blueprints/device.py
Executable file
13
server/frontend/app/blueprints/device.py
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from flask import jsonify, Blueprint
|
||||
from app.classes.device import Device
|
||||
|
||||
device_bp = Blueprint("device", __name__)
|
||||
|
||||
|
||||
@device_bp.route("/get/<token>", methods=["GET"])
|
||||
def api_device_get(token):
|
||||
""" Get device assets """
|
||||
return jsonify(Device(token).get())
|
90
server/frontend/app/blueprints/misc.py
Executable file
90
server/frontend/app/blueprints/misc.py
Executable file
@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import subprocess as sp
|
||||
from flask import Blueprint, jsonify
|
||||
from app.utils import *
|
||||
from app.classes.capture import stop_monitoring
|
||||
import re
|
||||
import sys
|
||||
import os
|
||||
|
||||
misc_bp = Blueprint("misc", __name__)
|
||||
|
||||
|
||||
@misc_bp.route("/delete-captures", methods=["GET"])
|
||||
def api_delete_captures():
|
||||
"""
|
||||
Delete the zombies capture folders (if any)
|
||||
"""
|
||||
if delete_captures() and stop_monitoring():
|
||||
return jsonify({"message": "Captures deleted", "status": True})
|
||||
else:
|
||||
return jsonify({"message": "Issue while removing captures", "status": False})
|
||||
|
||||
|
||||
@misc_bp.route("/reboot", methods=["GET"])
|
||||
def api_reboot():
|
||||
"""
|
||||
Reboot the device
|
||||
"""
|
||||
if read_config(("frontend", "reboot_option")):
|
||||
sp.Popen("shutdown -r now", shell=True)
|
||||
return jsonify({"mesage": "Let's reboot."})
|
||||
else:
|
||||
return jsonify({"message": "Option disabled", "status": False})
|
||||
|
||||
|
||||
@misc_bp.route("/quit", methods=["GET"])
|
||||
def api_quit():
|
||||
"""
|
||||
Quit the interface (Chromium browser)
|
||||
"""
|
||||
if read_config(("frontend", "quit_option")):
|
||||
sp.Popen('pkill -INT -f "chromium-browser"', shell=True)
|
||||
return jsonify({"message": "Let's quit", "status": True})
|
||||
else:
|
||||
return jsonify({"message": "Option disabled", "status": False})
|
||||
|
||||
|
||||
@misc_bp.route("/shutdown", methods=["GET"])
|
||||
def api_shutdown():
|
||||
"""
|
||||
Reboot the device
|
||||
"""
|
||||
if read_config(("frontend", "shutdown_option")):
|
||||
sp.Popen("shutdown -h now", shell=True)
|
||||
return jsonify({"message": "Let's shutdown", "status": True})
|
||||
else:
|
||||
return jsonify({"message": "Option disabled", "status": False})
|
||||
|
||||
|
||||
@misc_bp.route("/config", methods=["GET"])
|
||||
def get_config():
|
||||
"""
|
||||
Get configuration keys relative to the GUI
|
||||
"""
|
||||
return jsonify({
|
||||
"battery_level" : get_battery_level(),
|
||||
"wifi_level" : get_wifi_level(),
|
||||
"virtual_keyboard": read_config(("frontend", "virtual_keyboard")),
|
||||
"download_links": read_config(("frontend", "download_links")),
|
||||
"sparklines": read_config(("frontend", "sparklines")),
|
||||
"shutdown_option": read_config(("frontend", "shutdown_option")),
|
||||
"backend_option": read_config(("frontend", "backend_option")),
|
||||
"remote_backend" : read_config(("backend", "remote_access")),
|
||||
"iface_out": read_config(("network", "out")),
|
||||
"user_lang": read_config(("frontend", "user_lang")),
|
||||
"choose_net": read_config(("frontend", "choose_net")),
|
||||
"slideshow": read_config(("frontend", "slideshow")),
|
||||
"iocs_number" : get_iocs_number()
|
||||
})
|
||||
|
||||
@misc_bp.route("/battery", methods=["GET"])
|
||||
def battery_level():
|
||||
"""
|
||||
Return the battery level
|
||||
"""
|
||||
return jsonify({
|
||||
"battery_level" : get_battery_level()
|
||||
})
|
36
server/frontend/app/blueprints/network.py
Executable file
36
server/frontend/app/blueprints/network.py
Executable file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from flask import Blueprint, jsonify, request
|
||||
from app.classes.network import Network
|
||||
|
||||
network = Network()
|
||||
network_bp = Blueprint("network", __name__)
|
||||
|
||||
|
||||
@network_bp.route("/status", methods=["GET"])
|
||||
def api_network_status():
|
||||
""" Get the network status of eth0, wlan0 """
|
||||
return jsonify(network.check_status())
|
||||
|
||||
|
||||
@network_bp.route("/wifi/list", methods=["GET"])
|
||||
def api_get_wifi_list():
|
||||
""" List available WIFI networks """
|
||||
return jsonify(network.wifi_list_networks())
|
||||
|
||||
|
||||
@network_bp.route("/wifi/setup", methods=["POST", "OPTIONS"])
|
||||
def api_set_wifi():
|
||||
""" Set an access point and a password """
|
||||
if request.method == "POST":
|
||||
data = request.get_json()
|
||||
res = network.wifi_setup(data["ssid"], data["password"])
|
||||
return jsonify(res)
|
||||
else:
|
||||
return ""
|
||||
|
||||
@network_bp.route("/ap/start", methods=["GET"])
|
||||
def api_start_ap():
|
||||
""" Start an access point """
|
||||
return jsonify(network.start_hotspot())
|
21
server/frontend/app/blueprints/save.py
Executable file
21
server/frontend/app/blueprints/save.py
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from flask import Blueprint, jsonify, request
|
||||
from app.classes.save import Save
|
||||
from app.classes.device import Device
|
||||
|
||||
save = Save()
|
||||
save_bp = Blueprint("save", __name__)
|
||||
|
||||
|
||||
@save_bp.route("/usb-check", methods=["GET"])
|
||||
def api_usb_list():
|
||||
""" List connected usb devices """
|
||||
return save.usb_check()
|
||||
|
||||
|
||||
@save_bp.route("/save-capture/<token>/<method>", methods=["GET"])
|
||||
def api_save_capture(token, method):
|
||||
""" Save the capture on the USB or for download """
|
||||
return save.save_capture(token, method)
|
Reference in New Issue
Block a user