Update public source
This commit is contained in:
+166
-412
@@ -14,7 +14,7 @@ from html import escape
|
||||
from reports.utils import (
|
||||
format_datetime as format_report_datetime,
|
||||
)
|
||||
|
||||
from reports.map_popups import build_standard_popup
|
||||
|
||||
MAP_STYLE_URL = (
|
||||
"http://127.0.0.1:8080/styles/server-map/style.json"
|
||||
@@ -430,446 +430,184 @@ def get_category(
|
||||
# Popup helpers
|
||||
# ============================================================
|
||||
|
||||
def safe(value):
|
||||
if value is None:
|
||||
return "—"
|
||||
|
||||
text = str(value)
|
||||
|
||||
if not text:
|
||||
def search_display(value):
|
||||
if value is None or str(value).strip() == "":
|
||||
return "—"
|
||||
|
||||
return escape(
|
||||
text,
|
||||
str(value),
|
||||
quote=True
|
||||
)
|
||||
|
||||
|
||||
def format_security(
|
||||
def build_search_popup(
|
||||
access_point,
|
||||
category_class,
|
||||
category_label,
|
||||
credentials=None,
|
||||
handshakes=None,
|
||||
include_capture_times=False,
|
||||
):
|
||||
parts = []
|
||||
|
||||
if access_point["encryption"]:
|
||||
parts.append(
|
||||
access_point["encryption"]
|
||||
)
|
||||
|
||||
if access_point["cipher"]:
|
||||
parts.append(
|
||||
access_point["cipher"]
|
||||
)
|
||||
|
||||
if access_point["akm"]:
|
||||
parts.append(
|
||||
access_point["akm"]
|
||||
)
|
||||
|
||||
if not parts:
|
||||
return "—"
|
||||
|
||||
return escape(
|
||||
" / ".join(
|
||||
str(item)
|
||||
for item in parts
|
||||
standard_popup = build_standard_popup(
|
||||
essid=access_point["essid"],
|
||||
bssid=access_point["bssid"],
|
||||
vendor=access_point["vendor"],
|
||||
encryption=access_point["encryption"],
|
||||
cipher=access_point["cipher"],
|
||||
akm=access_point["akm"],
|
||||
channel=access_point["channel"],
|
||||
rssi=access_point["last_rssi"],
|
||||
passwords=credentials or [],
|
||||
handshakes=handshakes or [],
|
||||
observed_at=format_report_datetime(
|
||||
access_point["last_seen"]
|
||||
),
|
||||
quote=True
|
||||
latitude=access_point["last_latitude"],
|
||||
longitude=access_point["last_longitude"],
|
||||
access_point_url=(
|
||||
f"/reports/access-points/{access_point['bssid']}"
|
||||
),
|
||||
)
|
||||
|
||||
category_html = (
|
||||
'<div class="search-popup-category '
|
||||
f'{category_class}">'
|
||||
f'{category_label}'
|
||||
'</div>'
|
||||
)
|
||||
|
||||
statistics_html = """
|
||||
<div class="search-popup-line">
|
||||
<strong>Frequency:</strong>
|
||||
{frequency}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>First seen:</strong>
|
||||
{first_seen}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Last seen:</strong>
|
||||
{last_seen}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Times seen:</strong>
|
||||
{times_seen}
|
||||
</div>
|
||||
""".format(
|
||||
frequency=search_display(
|
||||
access_point["frequency"]
|
||||
),
|
||||
first_seen=search_display(
|
||||
format_report_datetime(
|
||||
access_point["first_seen"]
|
||||
)
|
||||
),
|
||||
last_seen=search_display(
|
||||
format_report_datetime(
|
||||
access_point["last_seen"]
|
||||
)
|
||||
),
|
||||
times_seen=search_display(
|
||||
access_point["times_seen"]
|
||||
)
|
||||
)
|
||||
|
||||
capture_times_html = ""
|
||||
|
||||
if include_capture_times:
|
||||
|
||||
capture_times = []
|
||||
|
||||
for handshake in handshakes or []:
|
||||
|
||||
if handshake["captured_at"]:
|
||||
capture_times.append(
|
||||
format_report_datetime(
|
||||
handshake["captured_at"]
|
||||
)
|
||||
)
|
||||
|
||||
if capture_times:
|
||||
capture_times_html = """
|
||||
<div class="search-popup-section">
|
||||
<strong>Capture time:</strong>
|
||||
|
||||
<div class="search-popup-list">
|
||||
{times}
|
||||
</div>
|
||||
</div>
|
||||
""".format(
|
||||
times="".join(
|
||||
"<div>{}</div>".format(
|
||||
search_display(timestamp)
|
||||
)
|
||||
for timestamp in capture_times
|
||||
)
|
||||
)
|
||||
|
||||
return """
|
||||
<div class="search-popup">
|
||||
{category}
|
||||
|
||||
<div class="search-popup-section">
|
||||
{standard_popup}
|
||||
</div>
|
||||
|
||||
{statistics}
|
||||
|
||||
{capture_times}
|
||||
</div>
|
||||
""".format(
|
||||
category=category_html,
|
||||
standard_popup=standard_popup,
|
||||
statistics=statistics_html,
|
||||
capture_times=capture_times_html,
|
||||
)
|
||||
|
||||
|
||||
def popup_password(
|
||||
access_point,
|
||||
credentials,
|
||||
handshakes=None,
|
||||
):
|
||||
password_items = []
|
||||
|
||||
for credential in credentials:
|
||||
|
||||
verified = (
|
||||
"Yes"
|
||||
if credential["verified"]
|
||||
else
|
||||
"No"
|
||||
)
|
||||
|
||||
password_items.append(
|
||||
"""
|
||||
<div class="search-popup-password-item">
|
||||
<div class="search-popup-password">
|
||||
{password}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-meta">
|
||||
Verified: {verified}
|
||||
·
|
||||
Source: {source}
|
||||
</div>
|
||||
</div>
|
||||
""".format(
|
||||
password=safe(
|
||||
credential["password"]
|
||||
),
|
||||
verified=verified,
|
||||
source=safe(
|
||||
credential["source"]
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if not password_items:
|
||||
password_items.append(
|
||||
"""
|
||||
<div class="search-popup-muted">
|
||||
No password details available.
|
||||
</div>
|
||||
"""
|
||||
)
|
||||
|
||||
return """
|
||||
<div class="search-popup">
|
||||
<div class="search-popup-title">
|
||||
{essid}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>BSSID:</strong>
|
||||
{bssid}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Vendor:</strong>
|
||||
{vendor}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-category password">
|
||||
PASSWORD
|
||||
</div>
|
||||
|
||||
<div class="search-popup-section">
|
||||
{passwords}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-section">
|
||||
<strong>Security:</strong>
|
||||
{security}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Channel:</strong>
|
||||
{channel}
|
||||
·
|
||||
<strong>Frequency:</strong>
|
||||
{frequency}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>RSSI:</strong>
|
||||
{rssi}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>First seen:</strong>
|
||||
{first_seen}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Last seen:</strong>
|
||||
{last_seen}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Times seen:</strong>
|
||||
{times_seen}
|
||||
</div>
|
||||
</div>
|
||||
""".format(
|
||||
essid=safe(
|
||||
access_point["essid"]
|
||||
),
|
||||
bssid=safe(
|
||||
access_point["bssid"]
|
||||
),
|
||||
vendor=safe(
|
||||
access_point["vendor"]
|
||||
),
|
||||
passwords="".join(
|
||||
password_items
|
||||
),
|
||||
security=format_security(
|
||||
access_point
|
||||
),
|
||||
channel=safe(
|
||||
access_point["channel"]
|
||||
),
|
||||
frequency=safe(
|
||||
access_point["frequency"]
|
||||
),
|
||||
rssi=safe(
|
||||
access_point["last_rssi"]
|
||||
),
|
||||
first_seen=format_report_datetime(
|
||||
access_point["first_seen"]
|
||||
),
|
||||
last_seen=format_report_datetime(
|
||||
access_point["last_seen"]
|
||||
),
|
||||
times_seen=safe(
|
||||
access_point["times_seen"]
|
||||
)
|
||||
return build_search_popup(
|
||||
access_point,
|
||||
"password",
|
||||
"PASSWORD",
|
||||
credentials=credentials,
|
||||
handshakes=handshakes,
|
||||
)
|
||||
|
||||
|
||||
def popup_handshake(
|
||||
access_point,
|
||||
handshakes,
|
||||
credentials=None,
|
||||
):
|
||||
eapol_count = 0
|
||||
pmkid_count = 0
|
||||
capture_times = []
|
||||
|
||||
for handshake in handshakes:
|
||||
|
||||
handshake_type = (
|
||||
str(
|
||||
handshake["type"]
|
||||
or ""
|
||||
).upper()
|
||||
)
|
||||
|
||||
if "PMKID" in handshake_type:
|
||||
pmkid_count += 1
|
||||
else:
|
||||
eapol_count += 1
|
||||
|
||||
if handshake["captured_at"]:
|
||||
capture_times.append(
|
||||
format_report_datetime(
|
||||
handshake["captured_at"]
|
||||
)
|
||||
)
|
||||
|
||||
summary = []
|
||||
|
||||
if eapol_count:
|
||||
summary.append(
|
||||
f"EAPOL × {eapol_count}"
|
||||
)
|
||||
|
||||
if pmkid_count:
|
||||
summary.append(
|
||||
f"PMKID × {pmkid_count}"
|
||||
)
|
||||
|
||||
if not summary:
|
||||
summary.append(
|
||||
"Handshake / PMKID"
|
||||
)
|
||||
|
||||
capture_html = ""
|
||||
|
||||
if capture_times:
|
||||
|
||||
capture_html = """
|
||||
<div class="search-popup-section">
|
||||
<strong>Capture time:</strong>
|
||||
<div class="search-popup-list">
|
||||
{times}
|
||||
</div>
|
||||
</div>
|
||||
""".format(
|
||||
times="".join(
|
||||
"<div>{}</div>".format(
|
||||
safe(timestamp)
|
||||
)
|
||||
for timestamp in capture_times
|
||||
)
|
||||
)
|
||||
|
||||
return """
|
||||
<div class="search-popup">
|
||||
<div class="search-popup-title">
|
||||
{essid}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>BSSID:</strong>
|
||||
{bssid}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Vendor:</strong>
|
||||
{vendor}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-category handshake">
|
||||
HANDSHAKE / PMKID
|
||||
</div>
|
||||
|
||||
<div class="search-popup-section">
|
||||
<strong>Material:</strong>
|
||||
{summary}
|
||||
</div>
|
||||
|
||||
{capture_html}
|
||||
|
||||
<div class="search-popup-section">
|
||||
<strong>Security:</strong>
|
||||
{security}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Channel:</strong>
|
||||
{channel}
|
||||
·
|
||||
<strong>Frequency:</strong>
|
||||
{frequency}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>RSSI:</strong>
|
||||
{rssi}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>First seen:</strong>
|
||||
{first_seen}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Last seen:</strong>
|
||||
{last_seen}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Times seen:</strong>
|
||||
{times_seen}
|
||||
</div>
|
||||
</div>
|
||||
""".format(
|
||||
essid=safe(
|
||||
access_point["essid"]
|
||||
),
|
||||
bssid=safe(
|
||||
access_point["bssid"]
|
||||
),
|
||||
vendor=safe(
|
||||
access_point["vendor"]
|
||||
),
|
||||
summary=escape(
|
||||
" · ".join(summary)
|
||||
),
|
||||
capture_html=capture_html,
|
||||
security=format_security(
|
||||
access_point
|
||||
),
|
||||
channel=safe(
|
||||
access_point["channel"]
|
||||
),
|
||||
frequency=safe(
|
||||
access_point["frequency"]
|
||||
),
|
||||
rssi=safe(
|
||||
access_point["last_rssi"]
|
||||
),
|
||||
first_seen=format_report_datetime(
|
||||
access_point["first_seen"]
|
||||
),
|
||||
last_seen=format_report_datetime(
|
||||
access_point["last_seen"]
|
||||
),
|
||||
times_seen=safe(
|
||||
access_point["times_seen"]
|
||||
)
|
||||
return build_search_popup(
|
||||
access_point,
|
||||
"handshake",
|
||||
"HANDSHAKE / PMKID",
|
||||
credentials=credentials,
|
||||
handshakes=handshakes,
|
||||
include_capture_times=True,
|
||||
)
|
||||
|
||||
|
||||
def popup_other(
|
||||
access_point,
|
||||
credentials=None,
|
||||
handshakes=None,
|
||||
):
|
||||
return """
|
||||
<div class="search-popup">
|
||||
<div class="search-popup-title">
|
||||
{essid}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>BSSID:</strong>
|
||||
{bssid}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Vendor:</strong>
|
||||
{vendor}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-category other">
|
||||
OTHER AP
|
||||
</div>
|
||||
|
||||
<div class="search-popup-section">
|
||||
<strong>Security:</strong>
|
||||
{security}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Channel:</strong>
|
||||
{channel}
|
||||
·
|
||||
<strong>Frequency:</strong>
|
||||
{frequency}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>RSSI:</strong>
|
||||
{rssi}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>First seen:</strong>
|
||||
{first_seen}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Last seen:</strong>
|
||||
{last_seen}
|
||||
</div>
|
||||
|
||||
<div class="search-popup-line">
|
||||
<strong>Times seen:</strong>
|
||||
{times_seen}
|
||||
</div>
|
||||
</div>
|
||||
""".format(
|
||||
essid=safe(
|
||||
access_point["essid"]
|
||||
),
|
||||
bssid=safe(
|
||||
access_point["bssid"]
|
||||
),
|
||||
vendor=safe(
|
||||
access_point["vendor"]
|
||||
),
|
||||
security=format_security(
|
||||
access_point
|
||||
),
|
||||
channel=safe(
|
||||
access_point["channel"]
|
||||
),
|
||||
frequency=safe(
|
||||
access_point["frequency"]
|
||||
),
|
||||
rssi=safe(
|
||||
access_point["last_rssi"]
|
||||
),
|
||||
first_seen=format_report_datetime(
|
||||
access_point["first_seen"]
|
||||
),
|
||||
last_seen=format_report_datetime(
|
||||
access_point["last_seen"]
|
||||
),
|
||||
times_seen=safe(
|
||||
access_point["times_seen"]
|
||||
)
|
||||
return build_search_popup(
|
||||
access_point,
|
||||
"other",
|
||||
"OTHER AP",
|
||||
credentials=credentials,
|
||||
handshakes=handshakes,
|
||||
)
|
||||
|
||||
|
||||
@@ -919,6 +657,10 @@ def build_geojson(
|
||||
credentials.get(
|
||||
access_point_id,
|
||||
[]
|
||||
),
|
||||
handshakes.get(
|
||||
access_point_id,
|
||||
[]
|
||||
)
|
||||
)
|
||||
|
||||
@@ -929,13 +671,25 @@ def build_geojson(
|
||||
handshakes.get(
|
||||
access_point_id,
|
||||
[]
|
||||
),
|
||||
credentials.get(
|
||||
access_point_id,
|
||||
[]
|
||||
)
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
popup = popup_other(
|
||||
access_point
|
||||
access_point,
|
||||
credentials.get(
|
||||
access_point_id,
|
||||
[]
|
||||
),
|
||||
handshakes.get(
|
||||
access_point_id,
|
||||
[]
|
||||
)
|
||||
)
|
||||
|
||||
features.append(
|
||||
|
||||
Reference in New Issue
Block a user