Update public source
This commit is contained in:
+166
-412
@@ -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,446 +430,184 @@ 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']}"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
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(
|
def popup_password(
|
||||||
access_point,
|
access_point,
|
||||||
credentials,
|
credentials,
|
||||||
|
handshakes=None,
|
||||||
):
|
):
|
||||||
password_items = []
|
return build_search_popup(
|
||||||
|
access_point,
|
||||||
for credential in credentials:
|
"password",
|
||||||
|
"PASSWORD",
|
||||||
verified = (
|
credentials=credentials,
|
||||||
"Yes"
|
handshakes=handshakes,
|
||||||
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"]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def popup_handshake(
|
def popup_handshake(
|
||||||
access_point,
|
access_point,
|
||||||
handshakes,
|
handshakes,
|
||||||
|
credentials=None,
|
||||||
):
|
):
|
||||||
eapol_count = 0
|
return build_search_popup(
|
||||||
pmkid_count = 0
|
access_point,
|
||||||
capture_times = []
|
"handshake",
|
||||||
|
"HANDSHAKE / PMKID",
|
||||||
for handshake in handshakes:
|
credentials=credentials,
|
||||||
|
handshakes=handshakes,
|
||||||
handshake_type = (
|
include_capture_times=True,
|
||||||
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"]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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}
|
|
||||||
·
|
|
||||||
<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(
|
||||||
|
|||||||
Reference in New Issue
Block a user