Update public source

This commit is contained in:
2026-10-14 06:59:40 +03:00
parent 93d54db672
commit 894a36d116
+109 -355
View File
@@ -14,7 +14,7 @@ from html import escape
from reports.utils import ( from reports.utils import (
format_datetime as format_report_datetime, format_datetime as format_report_datetime,
) )
from reports.map_popups import build_standard_popup
MAP_STYLE_URL = ( MAP_STYLE_URL = (
"http://127.0.0.1:8080/styles/server-map/style.json" "http://127.0.0.1:8080/styles/server-map/style.json"
@@ -430,143 +430,58 @@ def get_category(
# Popup helpers # Popup helpers
# ============================================================ # ============================================================
def safe(value): def search_display(value):
if value is None: if value is None or str(value).strip() == "":
return "—"
text = str(value)
if not text:
return "—" return "—"
return escape( return escape(
text, str(value),
quote=True quote=True
) )
def format_security( def build_search_popup(
access_point, access_point,
category_class,
category_label,
credentials=None,
handshakes=None,
include_capture_times=False,
): ):
parts = [] standard_popup = build_standard_popup(
essid=access_point["essid"],
if access_point["encryption"]: bssid=access_point["bssid"],
parts.append( vendor=access_point["vendor"],
access_point["encryption"] encryption=access_point["encryption"],
) cipher=access_point["cipher"],
akm=access_point["akm"],
if access_point["cipher"]: channel=access_point["channel"],
parts.append( rssi=access_point["last_rssi"],
access_point["cipher"] passwords=credentials or [],
) handshakes=handshakes or [],
observed_at=format_report_datetime(
if access_point["akm"]: access_point["last_seen"]
parts.append(
access_point["akm"]
)
if not parts:
return "—"
return escape(
" / ".join(
str(item)
for item in parts
), ),
quote=True latitude=access_point["last_latitude"],
) longitude=access_point["last_longitude"],
access_point_url=(
f"/reports/access-points/{access_point['bssid']}"
def popup_password(
access_point,
credentials,
):
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}
&nbsp;·&nbsp;
Source: {source}
</div>
</div>
""".format(
password=safe(
credential["password"]
), ),
verified=verified,
source=safe(
credential["source"]
)
)
) )
if not password_items: category_html = (
password_items.append( '<div class="search-popup-category '
""" f'{category_class}">'
<div class="search-popup-muted"> f'{category_label}'
No password details available. '</div>'
</div>
"""
) )
return """ statistics_html = """
<div class="search-popup">
<div class="search-popup-title">
{essid}
</div>
<div class="search-popup-line"> <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}
&nbsp;·&nbsp;
<strong>Frequency:</strong> <strong>Frequency:</strong>
{frequency} {frequency}
</div> </div>
<div class="search-popup-line">
<strong>RSSI:</strong>
{rssi}
</div>
<div class="search-popup-line"> <div class="search-popup-line">
<strong>First seen:</strong> <strong>First seen:</strong>
{first_seen} {first_seen}
@@ -581,65 +496,32 @@ def popup_password(
<strong>Times seen:</strong> <strong>Times seen:</strong>
{times_seen} {times_seen}
</div> </div>
</div>
""".format( """.format(
essid=safe( frequency=search_display(
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"] access_point["frequency"]
), ),
rssi=safe( first_seen=search_display(
access_point["last_rssi"] format_report_datetime(
),
first_seen=format_report_datetime(
access_point["first_seen"] access_point["first_seen"]
)
), ),
last_seen=format_report_datetime( last_seen=search_display(
format_report_datetime(
access_point["last_seen"] access_point["last_seen"]
)
), ),
times_seen=safe( times_seen=search_display(
access_point["times_seen"] access_point["times_seen"]
) )
) )
capture_times_html = ""
if include_capture_times:
def popup_handshake(
access_point,
handshakes,
):
eapol_count = 0
pmkid_count = 0
capture_times = [] capture_times = []
for handshake in handshakes: for handshake in handshakes or []:
handshake_type = (
str(
handshake["type"]
or ""
).upper()
)
if "PMKID" in handshake_type:
pmkid_count += 1
else:
eapol_count += 1
if handshake["captured_at"]: if handshake["captured_at"]:
capture_times.append( capture_times.append(
@@ -648,30 +530,11 @@ def popup_handshake(
) )
) )
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: if capture_times:
capture_times_html = """
capture_html = """
<div class="search-popup-section"> <div class="search-popup-section">
<strong>Capture time:</strong> <strong>Capture time:</strong>
<div class="search-popup-list"> <div class="search-popup-list">
{times} {times}
</div> </div>
@@ -679,7 +542,7 @@ def popup_handshake(
""".format( """.format(
times="".join( times="".join(
"<div>{}</div>".format( "<div>{}</div>".format(
safe(timestamp) search_display(timestamp)
) )
for timestamp in capture_times for timestamp in capture_times
) )
@@ -687,189 +550,64 @@ def popup_handshake(
return """ return """
<div class="search-popup"> <div class="search-popup">
<div class="search-popup-title"> {category}
{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"> <div class="search-popup-section">
<strong>Material:</strong> {standard_popup}
{summary}
</div> </div>
{capture_html} {statistics}
<div class="search-popup-section"> {capture_times}
<strong>Security:</strong>
{security}
</div>
<div class="search-popup-line">
<strong>Channel:</strong>
{channel}
&nbsp;·&nbsp;
<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> </div>
""".format( """.format(
essid=safe( category=category_html,
access_point["essid"] standard_popup=standard_popup,
), statistics=statistics_html,
bssid=safe( capture_times=capture_times_html,
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"]
) )
def popup_password(
access_point,
credentials,
handshakes=None,
):
return build_search_popup(
access_point,
"password",
"PASSWORD",
credentials=credentials,
handshakes=handshakes,
)
def popup_handshake(
access_point,
handshakes,
credentials=None,
):
return build_search_popup(
access_point,
"handshake",
"HANDSHAKE / PMKID",
credentials=credentials,
handshakes=handshakes,
include_capture_times=True,
) )
def popup_other( def popup_other(
access_point, access_point,
credentials=None,
handshakes=None,
): ):
return """ return build_search_popup(
<div class="search-popup"> access_point,
<div class="search-popup-title"> "other",
{essid} "OTHER AP",
</div> credentials=credentials,
handshakes=handshakes,
<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}
&nbsp;·&nbsp;
<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"]
)
) )
@@ -919,6 +657,10 @@ def build_geojson(
credentials.get( credentials.get(
access_point_id, access_point_id,
[] []
),
handshakes.get(
access_point_id,
[]
) )
) )
@@ -929,13 +671,25 @@ def build_geojson(
handshakes.get( handshakes.get(
access_point_id, access_point_id,
[] []
),
credentials.get(
access_point_id,
[]
) )
) )
else: else:
popup = popup_other( popup = popup_other(
access_point access_point,
credentials.get(
access_point_id,
[]
),
handshakes.get(
access_point_id,
[]
)
) )
features.append( features.append(