diff --git a/arp.py b/arp.py new file mode 100644 index 0000000..9cd951e --- /dev/null +++ b/arp.py @@ -0,0 +1,168 @@ +import json +import subprocess +from jinja2 import Template +from flask import Flask, render_template_string, jsonify + +app = Flask(__name__) + +# Functie om de cURL-oproep te doen voor de ARP-tabel +def run_curl_command(): + curl_command = [ + "curl", "-k", "--location", "--request", "POST", "https://ip:port/show", + "--form", "data={\"op\": \"show\", \"path\": [\"arp\"]}", + "--form", "key=key" + ] + response = subprocess.check_output(curl_command, text=True) + return json.loads(response) + +# Functie om de ARP-gegevens te verwerken +def parse_arp_data(data): + arp_table = [] + + if "data" in data: + raw_data = data["data"] + + # Verwerk de gegevens per regel + for line in raw_data.split("\n"): + if line.strip() and not line.startswith("Address"): + arp_info = line.split() + if len(arp_info) >= 4: + arp_table.append({ + "address": arp_info[0], + "interface": arp_info[1], + "link_layer_address": arp_info[2], + "state": arp_info[3] + }) + + return arp_table + +# Functie om de ARP-tabel in HTML te genereren +def generate_html_table(arp_table): + html_template = """ + + +
+ + +| Address | +Interface | +Link Layer Address | +State | +
|---|---|---|---|
| {{ entry.address }} | +{{ entry.interface }} | +{{ entry.link_layer_address }} | +{{ entry.state }} | +