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, card,
ReportContext, ReportContext,
) )
from reports.map_popups import build_standard_popup
# ============================================================ # ============================================================
# Helpers # Helpers
@@ -168,44 +168,32 @@ def load_trip_information(
# ============================================================ # ============================================================
def load_session_observations( def load_session_observations(
conn, conn,
session_id, session_id,
): ):
rows = query_all( rows = query_all(
conn, conn,
""" """
SELECT SELECT
latitude, latitude,
longitude, longitude,
rssi, rssi,
observed_at, observed_at,
id, id,
bssid, bssid,
essid, essid,
vendor, vendor,
encryption, encryption,
channel, channel,
frequency, frequency,
has_handshake, has_handshake,
has_pmkid, has_pmkid,
is_cracked is_cracked,
cipher,
akm
FROM FROM
( (
SELECT SELECT
obs.latitude, obs.latitude,
obs.longitude, obs.longitude,
obs.rssi, obs.rssi,
@@ -221,107 +209,177 @@ def load_session_observations(
ap.frequency, ap.frequency,
CASE CASE
WHEN hs.id IS NULL THEN 0 WHEN EXISTS (
ELSE 1 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, 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 CASE
WHEN EXISTS WHEN EXISTS (
(
SELECT 1 SELECT 1
FROM credentials AS c FROM credentials AS c
JOIN handshakes AS ch WHERE c.access_point_id = ap.id
ON ch.id = c.handshake_id
WHERE
c.access_point_id = ap.id
AND ch.session_id = obs.session_id
) )
THEN 1 THEN 1
ELSE 0 ELSE 0
END AS is_cracked, END AS is_cracked,
ROW_NUMBER() OVER ap.cipher,
( ap.akm,
ROW_NUMBER() OVER (
PARTITION BY obs.access_point_id PARTITION BY obs.access_point_id
ORDER BY ORDER BY
obs.rssi DESC, obs.rssi DESC,
obs.observed_at DESC obs.observed_at DESC,
obs.id DESC
) AS rn ) AS rn
FROM access_point_observations AS obs FROM access_point_observations AS obs
JOIN access_points AS ap JOIN access_points AS ap
ON ap.id = obs.access_point_id 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
WHERE obs.session_id = ? WHERE obs.session_id = ?
) )
WHERE rn = 1 WHERE rn = 1
ORDER BY ORDER BY
has_handshake DESC, has_handshake DESC,
is_cracked DESC, is_cracked DESC,
rssi DESC rssi DESC
""", """,
( (
session_id, 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 = [] observations = []
for row in rows: for row in rows:
observations.append( access_point_id = row[4]
{ observations.append({
"latitude": row[0],
"latitude": row[0], "longitude": row[1],
"rssi": row[2],
"longitude": row[1], "observed_at": row[3],
"id": row[4],
"rssi": row[2], "bssid": row[5],
"essid": row[6],
"observed_at": row[3], "vendor": row[7],
"encryption": row[8],
"id": row[4], "channel": row[9],
"frequency": row[10],
"bssid": row[5], "handshake": bool(row[11]),
"pmkid": bool(row[12]),
"essid": row[6], "cracked": bool(row[13]),
"cipher": row[14],
"vendor": row[7], "akm": row[15],
"passwords": credentials_by_ap.get(
"encryption": row[8], access_point_id,
[],
"channel": row[9], ),
"handshakes": handshakes_by_ap.get(
"frequency": row[10], access_point_id,
[],
"handshake": bool(row[11]), ),
})
"pmkid": bool(row[12]),
"cracked": bool(row[13]),
}
)
return observations return observations
@@ -660,59 +718,23 @@ def build_marker_js(
): ):
continue continue
popup = f""" popup = build_standard_popup(
essid=ap["essid"],
<b> bssid=ap["bssid"],
vendor=ap["vendor"],
{esc(ap["essid"])} encryption=ap["encryption"],
cipher=ap["cipher"],
</b> akm=ap["akm"],
channel=ap["channel"],
<br> rssi=ap["rssi"],
passwords=ap["passwords"],
{esc(ap["bssid"])} handshakes=ap["handshakes"],
observed_at=format_datetime(
<br> ap["observed_at"]
),
Vendor: latitude=ap["latitude"],
{esc(ap["vendor"])} longitude=ap["longitude"],
)
<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 "—"}
"""
markers.append( markers.append(