#!/usr/bin/env python3
import os
import sys
from pathlib import Path
ROOT = sys.argv[1] if len(sys.argv) > 1 else "."
LOG_ROOT = os.environ.get("LOG_ROOT", "")
OUT = Path(os.environ.get("OUT", "hp-daemon-tools-lite-cve-2026-8398-supply-chain-scope"))
DOMAINS = ["mcrypto.dat","env-check.daemontools.cc"]
IPS = ["38.180.107.76"]
HASHES = ["9ccd769624de98eeeb12714ff1707ec4f5bf196d","50d47adb6dd45215c7cb4c68bae28b129ca09645","0c1d3da9c7a651ba40b40e12d48ebd32b3f31820","28b72576d67ae21d9587d782942628ea46dcc870","46b90bf370e60d61075d3472828fdc0b85ab0492","6325179f442e5b1a716580cd70dea644ac9ecd18","bd8fbb5e6842df8683163adbd6a36136164eac58","15ed5c3384e12fe4314ad6edbd1dcccf5ac1ee29"]
# Collect unique indicators
indicators = set()
for group in [DOMAINS, IPS, HASHES]:
for val in group:
if val:
indicators.add(val)
indicators.add(val)
with open(indicators_file, "w") as f:
for ind in sorted(indicators):
f.write(ind + "\n")
print(f"[+] Written unique selectors to {indicators_file}")
# Walk local directory
print(f"[+] Scanning directory: {ROOT} for selectors...")
matches = []
exclude_dirs = {"node_modules", "vendor", "dist", ".git"}
for root, dirs, filenames in os.walk(ROOT):
dirs[:] = [d for d in dirs if d not in exclude_dirs]
for filename in filenames:
filepath = Path(root) / filename
try:
content = filepath.read_text(errors="ignore")
for ind in indicators:
if ind in content:
matches.append(f"{filepath}: found '{ind}'")
except Exception:
pass # pass # return or raise not needed here # pass # return or raise not needed here # pass # return or raise not needed here
if matches:
(OUT / "repository-indicator-matches.txt").write_text("\n".join(matches) + "\n")
print(f"[!] Found {len(matches)} matches in codebase!")
# Optional Log Scanning
if LOG_ROOT and os.path.exists(LOG_ROOT):
print(f"[+] Scanning telemetry log directory: {LOG_ROOT}...")
log_matches = []
for root, _, filenames in os.walk(LOG_ROOT):
for filename in filenames:
filepath = Path(root) / filename
try:
content = filepath.read_text(errors="ignore")
for ind in indicators:
if ind in content:
log_matches.append(f"{filepath}: found '{ind}'")
except Exception:
pass # pass # return or raise not needed here # pass # return or raise not needed here # pass # return or raise not needed here
if log_matches:
(OUT / "exported-telemetry-indicator-matches.txt").write_text("\n".join(log_matches) + "\n")
print(f"[!] Found {len(log_matches)} matches in logs!")
if "PACKAGES" in globals() and PACKAGES:
registry_dir = OUT / "registry"
registry_dir.mkdir(exist_ok=True)
print(f"[+] Wrote scope artifacts under {OUT}")