Update public source
This commit is contained in:
+102
-57
@@ -11,7 +11,7 @@ from reports.template import (
|
|||||||
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
|
||||||
|
|
||||||
def esc(value):
|
def esc(value):
|
||||||
|
|
||||||
@@ -99,6 +99,8 @@ def load_access_points(conn):
|
|||||||
ap.essid,
|
ap.essid,
|
||||||
ap.vendor,
|
ap.vendor,
|
||||||
ap.encryption,
|
ap.encryption,
|
||||||
|
ap.cipher,
|
||||||
|
ap.akm,
|
||||||
ap.has_handshake,
|
ap.has_handshake,
|
||||||
ap.has_pmkid,
|
ap.has_pmkid,
|
||||||
ap.is_cracked,
|
ap.is_cracked,
|
||||||
@@ -106,16 +108,7 @@ def load_access_points(conn):
|
|||||||
obs.longitude,
|
obs.longitude,
|
||||||
obs.observed_at,
|
obs.observed_at,
|
||||||
obs.rssi,
|
obs.rssi,
|
||||||
obs.channel,
|
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
|
|
||||||
FROM access_points AS ap
|
FROM access_points AS ap
|
||||||
JOIN ranked_observations AS obs
|
JOIN ranked_observations AS obs
|
||||||
ON obs.access_point_id = ap.id
|
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):
|
def build_marker_js(observations):
|
||||||
@@ -148,50 +218,25 @@ def build_marker_js(observations):
|
|||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ssid = (
|
popup = build_standard_popup(
|
||||||
row["essid"]
|
essid=row["essid"],
|
||||||
if row["essid"] is not None
|
bssid=row["bssid"],
|
||||||
and str(row["essid"]) != ""
|
vendor=row["vendor"],
|
||||||
else "—"
|
encryption=row["encryption"],
|
||||||
)
|
cipher=row["cipher"],
|
||||||
|
akm=row["akm"],
|
||||||
vendor = (
|
channel=row["channel"],
|
||||||
row["vendor"]
|
rssi=row["rssi"],
|
||||||
if row["vendor"] is not None
|
passwords=row["passwords"],
|
||||||
and str(row["vendor"]) != ""
|
handshakes=row["handshakes"],
|
||||||
else "—"
|
observed_at=format_popup_datetime(
|
||||||
)
|
row["observed_at"]
|
||||||
|
),
|
||||||
channel = (
|
latitude=latitude,
|
||||||
row["channel"]
|
longitude=longitude,
|
||||||
if row["channel"] is not None
|
access_point_url=(
|
||||||
else "—"
|
f"/reports/access-points/{row['bssid']}"
|
||||||
)
|
),
|
||||||
|
|
||||||
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>"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
feature = {
|
feature = {
|
||||||
@@ -220,7 +265,7 @@ def build_marker_js(observations):
|
|||||||
feature
|
feature
|
||||||
)
|
)
|
||||||
|
|
||||||
if row["is_cracked"] or row["password"]:
|
if row["is_cracked"] or row["passwords"]:
|
||||||
password_features.append(
|
password_features.append(
|
||||||
feature
|
feature
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user