Update public source

This commit is contained in:
2026-10-14 06:15:33 +03:00
parent 95a0f6e75a
commit 1e37ad7395
+152 -130
View File
@@ -38,7 +38,7 @@ from reports.template import (
card,
ReportContext,
)
from reports.map_popups import build_standard_popup
# ============================================================
# Helpers
@@ -168,44 +168,32 @@ def load_trip_information(
# ============================================================
def load_session_observations(
conn,
session_id,
):
rows = query_all(
conn,
"""
SELECT
latitude,
longitude,
rssi,
observed_at,
id,
bssid,
essid,
vendor,
encryption,
channel,
frequency,
has_handshake,
has_pmkid,
is_cracked
is_cracked,
cipher,
akm
FROM
(
SELECT
obs.latitude,
obs.longitude,
obs.rssi,
@@ -221,107 +209,177 @@ def load_session_observations(
ap.frequency,
CASE
WHEN hs.id IS NULL THEN 0
ELSE 1
WHEN EXISTS (
SELECT 1
FROM handshakes AS hs
WHERE
hs.access_point_id = ap.id
AND hs.session_id = obs.session_id
)
THEN 1
ELSE 0
END AS has_handshake,
ap.has_pmkid,
CASE
WHEN EXISTS (
SELECT 1
FROM handshakes AS hs
WHERE
hs.access_point_id = ap.id
AND hs.session_id = obs.session_id
AND UPPER(COALESCE(hs.type, ''))
LIKE '%PMKID%'
)
THEN 1
ELSE 0
END AS has_pmkid,
CASE
WHEN EXISTS
(
WHEN EXISTS (
SELECT 1
FROM credentials AS c
JOIN handshakes AS ch
ON ch.id = c.handshake_id
WHERE
c.access_point_id = ap.id
AND ch.session_id = obs.session_id
WHERE c.access_point_id = ap.id
)
THEN 1
ELSE 0
END AS is_cracked,
ROW_NUMBER() OVER
(
ap.cipher,
ap.akm,
ROW_NUMBER() OVER (
PARTITION BY obs.access_point_id
ORDER BY
obs.rssi DESC,
obs.observed_at DESC
obs.observed_at DESC,
obs.id DESC
) AS rn
FROM access_point_observations AS obs
JOIN access_points AS ap
ON ap.id = obs.access_point_id
LEFT JOIN handshakes AS hs
ON hs.access_point_id = ap.id
AND hs.session_id = obs.session_id
ON ap.id = obs.access_point_id
WHERE obs.session_id = ?
)
WHERE rn = 1
ORDER BY
has_handshake DESC,
is_cracked DESC,
rssi DESC
""",
(
session_id,
),
)
if not rows:
return []
credentials = query_all(
conn,
"""
SELECT
access_point_id,
password,
source,
verified
FROM credentials
WHERE access_point_id IN (
SELECT DISTINCT access_point_id
FROM access_point_observations
WHERE session_id = ?
)
ORDER BY
created_at DESC,
id DESC
""",
(
session_id,
),
)
credentials_by_ap = {}
for credential in credentials:
access_point_id = credential["access_point_id"]
credentials_by_ap.setdefault(
access_point_id,
[],
).append({
"password": credential["password"],
"source": credential["source"],
"verified": credential["verified"],
})
handshakes = query_all(
conn,
"""
SELECT
access_point_id,
type,
captured_at
FROM handshakes
WHERE session_id = ?
ORDER BY
captured_at DESC,
id DESC
""",
(
session_id,
),
)
handshakes_by_ap = {}
for handshake in handshakes:
access_point_id = handshake["access_point_id"]
handshakes_by_ap.setdefault(
access_point_id,
[],
).append({
"type": handshake["type"],
"captured_at": handshake["captured_at"],
})
observations = []
for row in rows:
observations.append(
access_point_id = row[4]
{
"latitude": row[0],
"longitude": row[1],
"rssi": row[2],
"observed_at": row[3],
"id": row[4],
"bssid": row[5],
"essid": row[6],
"vendor": row[7],
"encryption": row[8],
"channel": row[9],
"frequency": row[10],
"handshake": bool(row[11]),
"pmkid": bool(row[12]),
"cracked": bool(row[13]),
}
)
observations.append({
"latitude": row[0],
"longitude": row[1],
"rssi": row[2],
"observed_at": row[3],
"id": row[4],
"bssid": row[5],
"essid": row[6],
"vendor": row[7],
"encryption": row[8],
"channel": row[9],
"frequency": row[10],
"handshake": bool(row[11]),
"pmkid": bool(row[12]),
"cracked": bool(row[13]),
"cipher": row[14],
"akm": row[15],
"passwords": credentials_by_ap.get(
access_point_id,
[],
),
"handshakes": handshakes_by_ap.get(
access_point_id,
[],
),
})
return observations
@@ -660,59 +718,23 @@ def build_marker_js(
):
continue
popup = f"""
<b>
{esc(ap["essid"])}
</b>
<br>
{esc(ap["bssid"])}
<br>
Vendor:
{esc(ap["vendor"])}
<br>
Encryption:
{esc(ap["encryption"])}
<br>
Channel:
{esc(ap["channel"])}
&nbsp;&nbsp;
Frequency:
{esc(ap["frequency"])}
<br>
RSSI:
{esc(ap["rssi"])} dBm
<br>
Handshake:
{"✅" if ap["handshake"] else "—"}
&nbsp;&nbsp;
PMKID:
{"✅" if ap["pmkid"] else "—"}
&nbsp;&nbsp;
Password:
{"✅" if ap["cracked"] else "—"}
"""
popup = build_standard_popup(
essid=ap["essid"],
bssid=ap["bssid"],
vendor=ap["vendor"],
encryption=ap["encryption"],
cipher=ap["cipher"],
akm=ap["akm"],
channel=ap["channel"],
rssi=ap["rssi"],
passwords=ap["passwords"],
handshakes=ap["handshakes"],
observed_at=format_datetime(
ap["observed_at"]
),
latitude=ap["latitude"],
longitude=ap["longitude"],
)
markers.append(