mirror of
https://github.com/lephisto/fastd_roguescanner
synced 2024-12-21 15:54:26 +01:00
Initial Commit
This commit is contained in:
parent
7d34194b06
commit
f7d95acb7c
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.idea
|
57
roguescanner.py
Normal file
57
roguescanner.py
Normal file
@ -0,0 +1,57 @@
|
||||
"""
|
||||
FastD Roguescanner
|
||||
|
||||
Author: Bastian Maeuser
|
||||
https://github.com/lephisto/roguescanner
|
||||
|
||||
You will need python3-requests module installed.
|
||||
|
||||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
import requests
|
||||
import socket
|
||||
from roguescannerconfig import *
|
||||
|
||||
|
||||
def analyze(j):
|
||||
for p in j['peers']:
|
||||
mac = j['peers'][p]['connection']['mac_addresses'][0]
|
||||
ip = j['peers'][p]['address']
|
||||
print("Key:" + p + " MAC:" + mac, end=' ')
|
||||
for s in links:
|
||||
if s['source_addr'] == mac:
|
||||
print("Found as Source: " + s['source'], end = ' ')
|
||||
for n in nodes:
|
||||
if n['node_id'] == s['source']:
|
||||
print("Hostname:" + n['hostname'] + " (" + ip + ")")
|
||||
elif s['target_addr'] == mac:
|
||||
print("Found as Target: " + s['target'], end = ' ')
|
||||
for n in nodes:
|
||||
if n['node_id'] == s['target']:
|
||||
print("Hostname:" + n['hostname'] + " (" + ip + ")")
|
||||
|
||||
|
||||
# Read MV Json
|
||||
response = requests.get(mvjson)
|
||||
json_response = response.json()
|
||||
nodes = json_response['nodes']
|
||||
links = json_response['links']
|
||||
|
||||
# Read FastD Status Socket
|
||||
for fd_socket in fastd_sockets:
|
||||
result = b''
|
||||
if os.path.exists(fd_socket):
|
||||
print(fd_socket)
|
||||
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
s.connect(fd_socket)
|
||||
while True:
|
||||
data = s.recv(128)
|
||||
if data:
|
||||
result += data
|
||||
else:
|
||||
break
|
||||
|
||||
fd_json = json.loads(result.decode('utf-8'))
|
||||
analyze(fd_json)
|
6
roguescannerconfig.py
Normal file
6
roguescannerconfig.py
Normal file
@ -0,0 +1,6 @@
|
||||
mvjson = "https://regensburg.freifunk.net/data/meshviewer.json"
|
||||
fastd_sockets = [
|
||||
'/var/run/fastd/ffrgb_cty0.sock',
|
||||
'/var/run/fastd/ffrgb_cty1.sock',
|
||||
'/var/run/fastd/ffrgb_cty2.sock'
|
||||
]
|
Loading…
Reference in New Issue
Block a user