Update public source
This commit is contained in:
+102
-57
@@ -11,7 +11,7 @@ from reports.template import (
|
||||
from reports.utils import (
|
||||
format_datetime as format_report_datetime,
|
||||
)
|
||||
|
||||
from reports.map_popups import build_standard_popup
|
||||
|
||||
def esc(value):
|
||||
|
||||
@@ -99,6 +99,8 @@ def load_access_points(conn):
|
||||
ap.essid,
|
||||
ap.vendor,
|
||||
ap.encryption,
|
||||
ap.cipher,
|
||||
ap.akm,
|
||||
ap.has_handshake,
|
||||
ap.has_pmkid,
|
||||
ap.is_cracked,
|
||||
@@ -106,16 +108,7 @@ def load_access_points(conn):
|
||||
obs.longitude,
|
||||
obs.observed_at,
|
||||
obs.rssi,
|
||||
obs.channel,
|
||||
(
|
||||
SELECT c.password
|
||||
FROM credentials AS c
|
||||
WHERE c.access_point_id = ap.id
|
||||
ORDER BY
|
||||
c.created_at DESC,
|
||||
c.id DESC
|
||||
LIMIT 1
|
||||
) AS password
|
||||
obs.channel
|
||||
FROM access_points AS ap
|
||||
JOIN ranked_observations AS obs
|
||||
ON obs.access_point_id = ap.id
|
||||
@@ -126,7 +119,84 @@ def load_access_points(conn):
|
||||
""",
|
||||
)
|
||||
|
||||
return rows
|
||||
credentials = query_all(
|
||||
conn,
|
||||
"""
|
||||
SELECT
|
||||
access_point_id,
|
||||
password,
|
||||
source,
|
||||
verified
|
||||
FROM credentials
|
||||
ORDER BY
|
||||
created_at DESC,
|
||||
id DESC
|
||||
""",
|
||||
)
|
||||
|
||||
handshakes = query_all(
|
||||
conn,
|
||||
"""
|
||||
SELECT
|
||||
access_point_id,
|
||||
type,
|
||||
captured_at
|
||||
FROM handshakes
|
||||
ORDER BY
|
||||
captured_at DESC,
|
||||
id DESC
|
||||
""",
|
||||
)
|
||||
|
||||
credentials_by_ap = {}
|
||||
handshakes_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"],
|
||||
})
|
||||
|
||||
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:
|
||||
|
||||
observation = dict(row)
|
||||
|
||||
access_point_id = observation["id"]
|
||||
|
||||
observation["passwords"] = credentials_by_ap.get(
|
||||
access_point_id,
|
||||
[],
|
||||
)
|
||||
|
||||
observation["handshakes"] = handshakes_by_ap.get(
|
||||
access_point_id,
|
||||
[],
|
||||
)
|
||||
|
||||
observations.append(observation)
|
||||
|
||||
return observations
|
||||
|
||||
|
||||
def build_marker_js(observations):
|
||||
@@ -148,50 +218,25 @@ def build_marker_js(observations):
|
||||
):
|
||||
continue
|
||||
|
||||
ssid = (
|
||||
row["essid"]
|
||||
if row["essid"] is not None
|
||||
and str(row["essid"]) != ""
|
||||
else "—"
|
||||
)
|
||||
|
||||
vendor = (
|
||||
row["vendor"]
|
||||
if row["vendor"] is not None
|
||||
and str(row["vendor"]) != ""
|
||||
else "—"
|
||||
)
|
||||
|
||||
channel = (
|
||||
row["channel"]
|
||||
if row["channel"] is not None
|
||||
else "—"
|
||||
)
|
||||
|
||||
rssi = (
|
||||
f"{row['rssi']} dBm"
|
||||
if row["rssi"] is not None
|
||||
else "—"
|
||||
)
|
||||
|
||||
password = (
|
||||
row["password"]
|
||||
if row["password"] is not None
|
||||
and str(row["password"]) != ""
|
||||
else "—"
|
||||
)
|
||||
|
||||
popup = (
|
||||
f"<b>{esc(ssid)}</b>"
|
||||
f"<br>MAC: {esc(row['bssid'])}"
|
||||
f"<br>Vendor: {esc(vendor)}"
|
||||
f"<br>Channel: {esc(channel)}"
|
||||
f"<br>RSSI: {esc(rssi)}"
|
||||
f"<br>Password: {esc(password)}"
|
||||
f"<br>Date: "
|
||||
f"{esc(format_popup_datetime(row['observed_at']))}"
|
||||
f'<br><a href="/reports/access-points/{esc(row["bssid"])}">'
|
||||
f"Подробнее</a>"
|
||||
popup = build_standard_popup(
|
||||
essid=row["essid"],
|
||||
bssid=row["bssid"],
|
||||
vendor=row["vendor"],
|
||||
encryption=row["encryption"],
|
||||
cipher=row["cipher"],
|
||||
akm=row["akm"],
|
||||
channel=row["channel"],
|
||||
rssi=row["rssi"],
|
||||
passwords=row["passwords"],
|
||||
handshakes=row["handshakes"],
|
||||
observed_at=format_popup_datetime(
|
||||
row["observed_at"]
|
||||
),
|
||||
latitude=latitude,
|
||||
longitude=longitude,
|
||||
access_point_url=(
|
||||
f"/reports/access-points/{row['bssid']}"
|
||||
),
|
||||
)
|
||||
|
||||
feature = {
|
||||
@@ -220,7 +265,7 @@ def build_marker_js(observations):
|
||||
feature
|
||||
)
|
||||
|
||||
if row["is_cracked"] or row["password"]:
|
||||
if row["is_cracked"] or row["passwords"]:
|
||||
password_features.append(
|
||||
feature
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user