Zero Breach — local, read-only scanner that checks a computer for indicators of the AdFection / Candiru ad-delivered spyware campaign. No network, no admin, no dependencies.
Search retained DNS history when current logging is disabled
interplains1029a9aefaea
diff --git a/README.md b/README.mdindex 091ff86..46ebdc7 100644--- a/README.md+++ b/README.md@@ -1,8 +1,9 @@# Zero Breach-> Release v0.1.4 prioritizes local COM-registered files in the optional Candiru pattern check and expands Windows DNS-history coverage. See-> [the v0.1.4 scope](COVERAGE-UPGRADE.md) and [pattern validation](DETECTION-UPGRADE.md). It needs a pinned YARA-X-> dependency; default checks remain standard-library-only.+> Release v0.1.5 searches saved Windows DNS events even when logging is currently+> off. It keeps a coverage warning for unrecorded periods and does not change+> logging settings. Optional Candiru patterns still need the pinned YARA-X engine;+> see [pattern validation](DETECTION-UPGRADE.md). Default checks remain standard-library-only.[](https://github.com/interplains/zero-breach/actions/workflows/tests.yml)@@ -144,7 +145,7 @@ set up (e.g. a bad indicator file).Use the official repository above and check the downloaded file before running it.-**1. Verify the publisher's signature.** Release v0.1.4 includes detached GPG+**1. Verify the publisher's signature.** Release v0.1.5 includes detached GPGsignatures for the scanner and its checksum manifest, using ArchiveGenocide'sestablished release key. Follow [SIGNING.md](SIGNING.md), and compare the fullkey fingerprint with [ArchiveGenocide's verification page](https://archivegenocide.com/verify.html).@@ -168,11 +169,11 @@ you do not have to trust the download at all; you can reproduce it:```git clone https://github.com/interplains/zero-breach.gitcd zero-breach-git checkout v0.1.4+git checkout v0.1.5python build/build.py # writes dist/zero-breach.py and prints its SHA-256```-These commands reproduce v0.1.4; substitute the matching tag for another release.+These commands reproduce v0.1.5; substitute the matching tag for another release.On macOS or Linux use `python3` for the build command.Compare the hash with that release's published hash. The development branch maycontain later changes and is not expected to reproduce an earlier release.diff --git a/SIGNING.md b/SIGNING.mdindex 5924710..f565d61 100644--- a/SIGNING.md+++ b/SIGNING.md@@ -1,17 +1,17 @@# Verifying ArchiveGenocide release signatures-Zero Breach v0.1.4 supplies detached GPG signatures for the exact released+Zero Breach v0.1.5 supplies detached GPG signatures for the exact releasedscanner and its SHA256SUMS.txt manifest. They use ArchiveGenocide's existingEd25519 release-signing key, also published on the archive's verification page.Official repository: https://github.com/interplains/zero-breach-Official release: https://github.com/interplains/zero-breach/releases/tag/v0.1.4+Official release: https://github.com/interplains/zero-breach/releases/tag/v0.1.5Independent publisher page: https://archivegenocide.com/scan/#verify-downloadEstablished key identity: https://archivegenocide.com/verify.html## Check the publisher and file-Download these three files from the v0.1.4 release into one directory:+Download these three files from the v0.1.5 release into one directory:- zero-breach.py- zero-breach.py.asc@@ -36,9 +36,9 @@ Verification must succeed using the expected ArchiveGenocide key. A warningthat the key is not certified by your own web of trust is different from abad signature; do not ignore a fingerprint mismatch or failed verification.-The expected SHA-256 of zero-breach.py v0.1.4 is:+The expected SHA-256 of zero-breach.py v0.1.5 is:- 5ab89ef3dda3579dfc0b4930b0d66290fdc755611afd91e28c373e30fe9996cc+ 59811565be507c7d956e77f5f396b81545259c551fa9208d85654a01dec1048eA signature verifies which key signed these exact bytes. It does not establishthat the program has no bugs. A checksum alone is not publisher authentication.@@ -58,14 +58,14 @@ The manifest lists the fifteen release-content files, including the optionalrequirements file and Candiru rule attribution and licence records. The manifest itself andthe added public key/signatures are not self-listed.-Public verification artifacts are also retained in release-signatures/v0.1.4/.+Public verification artifacts are also retained in release-signatures/v0.1.5/.No private key is stored in this repository or in its project backups.## Indicator updates are a separate trust pathThe manually run scan/update-iocs.py still checks HTTPS, a published SHA-256,and indicator-file validity. It does not automatically verify GPG signatures.-The signed release manifest covers the indicator file shipped with v0.1.4;+The signed release manifest covers the indicator file shipped with v0.1.5;it does not authenticate later files fetched from the development branch.## Maintainer release procedurediff --git a/TESTING.md b/TESTING.mdindex a2fb7bb..5b60f6c 100644--- a/TESTING.md+++ b/TESTING.md@@ -35,11 +35,12 @@ untested optional positives as a skip. Use `--require-patterns` before release.- The existing unit/regression suite.- Two byte-identical builds of the downloadable script, plus its help/version.-- Eleven fixture scenarios, each in fresh source-CLI and single-file processes:+- Fifteen fixture scenarios, each in fresh source-CLI and single-file processes:clean data, contacted domain, harmless research reference, exact hash hit,corrupt database, a hit alongside a corrupt database, `--quick` coverage gap,a DNS hit past the old 20,000-event limit, unread older DNS events without a- hit, invalid indicator input, and COM-referenced optional file patterns.+ hit, four disabled-DNS-log cases (retained match, retained clean data,+ unreadable retained events and no events), invalid indicator input, and COM-referenced optional file patterns.- Real browser-shaped SQLite files and harmless rule-matching bytes pass throughthe real scanner modules, evidence grading, exit codes and text/JSON reports.Source and download must agree. Cookie values must stay out of reports;diff --git a/build/bundle.py b/build/bundle.pyindex 1798274..dbf3d8f 100644--- a/build/bundle.py+++ b/build/bundle.py@@ -160,7 +160,7 @@ A('import datetime')A('import sys')A('import time')A('')-A('__version__ = "0.1.4 (single-file build)"')+A('__version__ = "0.1.5 (single-file build)"')A('')A('# --- embedded indicator data ------------------------------------------------')A('# The real file is iocs/adfection_iocs.txt in the project. Its provenance')diff --git a/scan/README.md b/scan/README.mdindex d90d121..bc67c92 100644--- a/scan/README.md+++ b/scan/README.md@@ -1,8 +1,9 @@# adint-scan-> Release v0.1.4 improves coverage for the experimental, opt-in `--patterns` check. See-> [COVERAGE-UPGRADE.md](../COVERAGE-UPGRADE.md) and [DETECTION-UPGRADE.md](../DETECTION-UPGRADE.md) for dependencies, limits and-> validation evidence. Default checks need no added packages.+> Release v0.1.5 reads retained Windows DNS events even if logging is currently+> disabled, and keeps gaps for unrecorded activity. It never enables logging.+> Optional Candiru pattern dependencies and limits are documented in+> [DETECTION-UPGRADE.md](../DETECTION-UPGRADE.md).A local, read-only check for the published AdFection / Candiru indicators,with explicit reporting of missing evidence and checks that could not run.diff --git a/scan/adint_scan/__init__.py b/scan/adint_scan/__init__.pyindex f5d6c89..c62af21 100644--- a/scan/adint_scan/__init__.py+++ b/scan/adint_scan/__init__.py@@ -4,4 +4,4 @@ A clean result from this tool means "no known indicators were found in the placethat can be checked." It does NOT mean the device is clean. See SPEC-scanner.md."""-__version__ = "0.1.4"+__version__ = "0.1.5"diff --git a/scan/adint_scan/modules/host.py b/scan/adint_scan/modules/host.pyindex 744b335..4e3616d 100644--- a/scan/adint_scan/modules/host.py+++ b/scan/adint_scan/modules/host.py@@ -690,7 +690,7 @@ def _check_dns_log(r: ModuleResult, ctx) -> None:r.submetrics["dns_log_enabled"] = 1 if enabled else 0r.submetrics["dns_log_records"] = records- if not enabled or records <= 0:+ if records <= 0:# The important branch, and the common one. This must never read clean.r.could_not_run("dns-log", _DNS_LOG_GAP)r.note("dns-log: {} enabled={} records={} — forward-looking checks are "@@ -702,14 +702,23 @@ def _check_dns_log(r: ModuleResult, ctx) -> None:"days": 0,"basis": "DNS logging is {} and holds {} records".format("enabled" if enabled else "disabled", records),- "note": "Nothing was ever recorded, so there is no window at all — "- "not a short one. This is the Windows default, on every PC.",+ "note": "No saved DNS events were available for this scan. "+ "This does not establish whether older events existed or were cleared.","how_to_enable": _HOW_TO_ENABLE,}return- ctx.emit("[host] DNS-Client/Operational is enabled ({} records); "- "scanning messages".format(records))+ # IsEnabled controls current collection, not whether retained events can+ # be read. Disabling logging must not hide existing historical evidence.+ if not enabled:+ r.could_not_run("dns-log-recording",+ "DNS logging is currently off; queries made while "+ "logging was off may be missing")+ r.note("dns-log: logging is off; the log reports {} saved event(s). "+ "Checking them does not enable logging."+ .format(records))+ ctx.emit("[host] DNS-Client/Operational logging is {} ({} retained records); "+ "scanning messages".format("on" if enabled else "off", records))# -ErrorAction Stop, not SilentlyContinue: with SilentlyContinue a failure to# read the channel (ACL, corrupt .evtx, Event Log service degraded) exits 0# with no output, so `events` is [] and `ev_err` is "" - and the log, which is@@ -725,18 +734,16 @@ def _check_dns_log(r: ModuleResult, ctx) -> None:" | ConvertTo-Json -Depth 3 -Compress".format(_DNS_LOG, _DNS_EVENT_CAP), timeout=300)if (ev_err and not events) or (records > 0 and not events):- reason = ("log is enabled with {} records but none could be read{} - this "+ reason = ("log has {} retained records but none could be read{} - this ""machine's DNS history was NOT searched, so nothing here is ""cleared".format(records, ": " + ev_err if ev_err else ""))r.could_not_run("dns-log", reason)- r.note(_ARM_HINT)returnhits = 0times = [t for t in (_str(ev, "Time") for ev in events) if t]if times:- # The log IS on, so there is a real window. Report its true extent rather- # than implying the whole history of the machine.+ # Retained records have dates even when logging is currently disabled.r.reach["dns-log"] = {"earliest": min(times),"days": None,@@ -745,6 +752,9 @@ def _check_dns_log(r: ModuleResult, ctx) -> None:"note": "Queries before this are either rotated out of the log or ""beyond the bounded event read.",}+ if not enabled:+ r.reach["dns-log"]["note"] += " Logging is currently off; queries during unrecorded periods may be missing."+ r.reach["dns-log"]["how_to_enable"] = _HOW_TO_ENABLEfor ev in events:when = _str(ev, "Time")hits += _match(diff --git a/scan/tests/test_evidence.py b/scan/tests/test_evidence.pyindex 17a04a5..a452b3f 100644--- a/scan/tests/test_evidence.py+++ b/scan/tests/test_evidence.py@@ -30,7 +30,7 @@ from adint_scan import iocs as iocmod # noqa: E402from adint_scan import report # noqa: E402from adint_scan.context import ScanContext # noqa: E402from adint_scan.modules import browser # noqa: E402-from adint_scan.result import Hit, ModuleResult, PARTIAL # noqa: E402+from adint_scan.result import Hit, ModuleResult, PARTIAL, UNKNOWN # noqa: E402TEST_DOMAIN = "synthetic-test-indicator.invalid"@@ -305,6 +305,56 @@ class TestBlockedDnsLookupIsNotContact(unittest.TestCase):class TestDnsLogIsNotProofOfContact(unittest.TestCase):+ def disabled_log(self, records, events, error=""):+ from adint_scan.modules import host+ with tempfile.TemporaryDirectory(prefix="dnslog_off_") as tmp:+ result = ModuleResult("host")+ replies = [([{"IsEnabled": False, "RecordCount": records}], "")]+ if records:+ replies.append((events, error))+ with patch.object(host, "_ps_json", side_effect=replies) as query:+ host._check_dns_log(result, make_ctx(tmp))+ self.assertEqual(query.call_count, 2 if records else 1)+ for call in query.call_args_list:+ self.assertIn("Get-WinEvent", call.args[0])+ self.assertNotIn("wevtutil", call.args[0])+ return result++ def test_disabled_log_still_searches_retained_matching_event(self):+ result = self.disabled_log(1, [{"Time": "2025-03-04T12:00:00Z", "Message": TEST_DOMAIN}])+ self.assertEqual(result.status, "HITS")+ self.assertEqual([(h.indicator, h.evidence) for h in result.hits], [(TEST_DOMAIN, "dns-record")])+ self.assertEqual(result.hits[0].observed, "2025-03-04T12:00:00Z")+ self.assertEqual(result.submetrics["dns_log_events_scanned"], 1)+ self.assertEqual(result.submetrics["dns_log_enabled"], 0)+ self.assertIn("how_to_enable", result.reach["dns-log"])++ def test_disabled_log_clean_retained_event_keeps_recording_gap(self):+ result = self.disabled_log(1, [{"Time": "2025-03-04T12:00:00Z", "Message": "ordinary.invalid"}])+ self.assertEqual(result.status, PARTIAL)+ self.assertEqual(result.hits, [])+ self.assertTrue(any(c.name == "dns-log" and c.ran for c in result.checks))+ self.assertTrue(any(c.name == "dns-log-recording" and not c.ran for c in result.checks))++ def test_disabled_empty_log_is_not_clean(self):+ result = self.disabled_log(0, [])+ self.assertEqual(result.status, UNKNOWN)+ self.assertNotIn("dns_log_events_scanned", result.submetrics)++ def test_disabled_log_read_failure_is_not_clean(self):+ result = self.disabled_log(1, [], "fixture permission denied")+ self.assertEqual(result.status, UNKNOWN)+ self.assertEqual(result.hits, [])+ self.assertTrue(any(c.name == "dns-log" and not c.ran for c in result.checks))+ self.assertNotIn("dns_log_events_scanned", result.submetrics)++ def test_disabled_log_preserves_hit_and_older_retained_gap_together(self):+ result = self.disabled_log(50001, [{"Time": "2025-03-04T12:00:00Z", "Message": TEST_DOMAIN}])+ self.assertEqual(result.status, "HITS")+ self.assertEqual(len(result.hits), 1)+ self.assertTrue(any(c.name == "dns-log-older-events" and not c.ran for c in result.checks))+ self.assertTrue(any(c.name == "dns-log-recording" and not c.ran for c in result.checks))+def test_dns_match_after_old_20000_event_limit_is_read(self):from adint_scan.modules import hostwith tempfile.TemporaryDirectory(prefix="dnslog_extended_") as tmp:diff --git a/tools/release_check.py b/tools/release_check.pyindex 25343a2..d82996a 100644--- a/tools/release_check.py+++ b/tools/release_check.py@@ -15,7 +15,8 @@ import timeROOT = Path(__file__).resolve().parents[1]CASES = ("clean", "contact", "reference", "hash", "corrupt", "hit-and-gap", "quick",- "dns-cap-hit", "dns-cap-gap", "bad-feed", "patterns")+ "dns-cap-hit", "dns-cap-gap", "dns-off-retained-hit", "dns-off-retained-clean",+ "dns-off-unreadable", "dns-off-empty", "bad-feed", "patterns")class DownloadPanel(HTMLParser):diff --git a/tools/release_fixture.py b/tools/release_fixture.pyindex 95c6821..f64c235 100644--- a/tools/release_fixture.py+++ b/tools/release_fixture.py@@ -126,6 +126,8 @@ def main():raise RuntimeError("fixture attempted file access outside test/code/runtime roots")events = [{"Time": "2025-06-01T00:00:00", "Message": "ordinary.invalid"}]+ if case == "dns-off-retained-hit":+ events[0]["Message"] = DOMAINif case.startswith("dns-cap-"):events = events * 50000if case == "dns-cap-hit":@@ -133,9 +135,12 @@ def main():def ps_json(command, timeout=60):if "-ListLog " in command:- return [{"IsEnabled": True, "RecordCount": len(events) + int(case.startswith("dns-cap-"))}], ""+ return [{"IsEnabled": not case.startswith("dns-off-"),+ "RecordCount": 0 if case == "dns-off-empty" else len(events) + int(case.startswith("dns-cap-"))}], ""if "Get-WinEvent -LogName " in command:require("-MaxEvents 50000" in command, "unexpected DNS read cap")+ if case == "dns-off-unreadable":+ return [], "fixture read denied"return events, ""if "Get-DnsClientCache" in command:return [{"Entry": DOMAIN, "Data": "0.0.0.0", "Type": 1}], ""@@ -196,6 +201,7 @@ def main():"reference": ("browser", DOMAIN, "referenced"),"hash": ("hash", DIGEST, "on-disk"),"dns-cap-hit": ("host", DOMAIN, "dns-record")}+ expected["dns-off-retained-hit"] = ("host", DOMAIN, "dns-record")if case == "patterns" and engine:expected[case] = ("patterns", "yara:MAL_DevilsTongue_HijackDll", "file-pattern")require(hits == ([expected[case]] if case in expected else []),@@ -204,11 +210,20 @@ def main():require(verdict["hits_total"] == len(hits), "incorrect total finding count")expected_verdict = ("INDICATORS_FOUND" if hits else"NO_KNOWN_INDICATORS_WITH_GAPS" if case in- ("corrupt", "quick", "dns-cap-gap", "patterns") else "NO_KNOWN_INDICATORS")+ ("corrupt", "quick", "dns-cap-gap", "patterns", "dns-off-retained-clean",+ "dns-off-unreadable", "dns-off-empty") else "NO_KNOWN_INDICATORS")require(verdict["status"] == expected_verdict, "incorrect overall verdict: " + str(verdict))if case.startswith("dns-cap-"):require(any("dns-log-older-events" in g for g in verdict["gaps"]), "missing DNS cap gap")require(modules["host"]["submetrics"]["dns_log_events_scanned"] == 50000, "wrong DNS count")+ if case.startswith("dns-off-"):+ require(modules["host"]["submetrics"]["dns_log_enabled"] == 0, "logging state misreported")+ require(bool(verdict["gaps"]), "disabled logging coverage gap missing")+ if case.startswith("dns-off-retained-"):+ require(modules["host"]["submetrics"]["dns_log_events_scanned"] == 1, "retained event not searched")+ require("HOW TO TURN ON DNS HISTORY" in text, "future-logging instructions missing")+ if case in ("dns-off-empty", "dns-off-unreadable"):+ require(not modules["host"]["submetrics"].get("dns_log_events_scanned"), "unread log falsely searched")if case == "quick":require(modules["hash"]["status"] == "UNKNOWN", "quick scan falsely cleared file hashes")if case in ("corrupt", "hit-and-gap"):