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.
Add Vivaldi browser support and corresponding tests
Nur Abir6fb3b35ff051
diff --git a/README.md b/README.mdindex 120c7df..d2241b9 100644--- a/README.md+++ b/README.md@@ -43,7 +43,7 @@ updates or establish that a device is safe.| area | what it reads ||---|---|-| **Browser** | history, cookies (host names and timestamps only), favicons, HTTP cache, Local/Session Storage, Service Worker caches, and HSTS/connection records — across Chrome, Edge, Brave, Chromium and Firefox, for discovered profiles in supported locations |+| **Browser** | history, cookies (host names and timestamps only), favicons, HTTP cache, Local/Session Storage, Service Worker caches, and HSTS/connection records — across Chrome, Edge, Brave, Vivaldi, Chromium and Firefox, for discovered profiles in supported locations || **Files** | SHA-256 of candidate files under the user-writable locations spyware drops into, against known sample hashes — and, kept deliberately separate, the hash of a legitimate signed driver this actor abuses, which is reported as a lead rather than as proof || **Host** (Windows) | per-user COM registrations (this campaign's documented persistence), the DNS resolver cache, whether DNS history logging is even enabled, the hosts file, and known fixed-path driver drops (e.g. the `HW.sys` vulnerable driver) |@@ -54,6 +54,26 @@ merely appearing in a cached web page may be a saved reference, such as anarticle about the campaign. The tool distinguishes saved references fromconnection evidence so that each finding can be interpreted in context.+### Supported browsers++| family | browsers | profile locations checked |+| ------ | -------- | ------------------------- |+| Chromium | Chrome, Edge, Brave, **Vivaldi**, Chromium | Windows `%LOCALAPPDATA%\\<vendor>\\User Data`; macOS `~/Library/Application Support/<vendor>`; Linux `~/.config/<vendor>` plus snap and Flatpak locations |+| Firefox | Firefox | standard profile and cache directories |++Vivaldi paths: `%LOCALAPPDATA%\\Vivaldi\\User Data` (Windows),+`~/Library/Application Support/Vivaldi` (macOS), `~/.config/vivaldi`,+`~/.config/vivaldi-snapshot` and the Flatpak `com.vivaldi.Vivaldi` config+(Linux). Other Chromium-based browsers (Opera, Arc and similar) are not scanned+yet; a browser that is not listed is reported as nothing checked for it, never+as clean. Close the browser before scanning so its databases are not locked.++> **Fork note:** Vivaldi support is a change on top of upstream v0.1.1. A+> `dist/zero-breach.py` built from this fork has a different SHA-256 from the+> signed upstream release, so the upstream GPG signature and published checksum+> do not apply to it. Rebuild with `python build/build.py` and compare against+> your own build.+## Install and runRequires Python 3.8 or newer. No administrator. No third-party packages.diff --git a/scan/README.md b/scan/README.mdindex 7bb26a8..16cd7e2 100644--- a/scan/README.md+++ b/scan/README.md@@ -55,7 +55,7 @@ after use. `--json PATH` writes the report you request.| module | what it reads ||---|---|-| `browser` | history, cookies, favicons, HTTP cache, LevelDB and Service Worker caches across Chrome / Edge / Brave / Chromium (every profile) and Firefox. Locked databases are copied before being opened. |+| `browser` | history, cookies, favicons, HTTP cache, LevelDB and Service Worker caches across Chrome / Edge / Brave / Vivaldi / Chromium (every profile) and Firefox. Locked databases are copied before being opened. || `hash` | SHA-256 of candidate files under AppData, ProgramData, both Temps, Downloads, Desktop, Documents and Public, against the sample hashes in the IOC set. || `host` | per-user COM registrations (this chain's documented persistence), the DNS resolver cache, whether DNS history exists at all, and the hosts file. |diff --git a/scan/adint_scan/modules/browser.py b/scan/adint_scan/modules/browser.pyindex 0f74902..36f94e0 100644--- a/scan/adint_scan/modules/browser.py+++ b/scan/adint_scan/modules/browser.py@@ -66,6 +66,7 @@ def _chromium_roots():("brave", os.path.join(LOCAL, "BraveSoftware", "Brave-Browser","User Data")),("chromium", os.path.join(LOCAL, "Chromium", "User Data")),+ ("vivaldi", os.path.join(LOCAL, "Vivaldi", "User Data")),]if sys.platform == "darwin":asup = os.path.join(home, "Library", "Application Support")@@ -74,6 +75,7 @@ def _chromium_roots():("edge", os.path.join(asup, "Microsoft Edge")),("brave", os.path.join(asup, "BraveSoftware", "Brave-Browser")),("chromium", os.path.join(asup, "Chromium")),+ ("vivaldi", os.path.join(asup, "Vivaldi")),]if sys.platform.startswith("linux"):cfg = os.path.join(home, ".config")@@ -84,6 +86,8 @@ def _chromium_roots():("chromium", os.path.join(cfg, "chromium")),("brave", os.path.join(cfg, "BraveSoftware", "Brave-Browser")),("edge", os.path.join(cfg, "microsoft-edge")),+ ("vivaldi", os.path.join(cfg, "vivaldi")),+ ("vivaldi-snapshot", os.path.join(cfg, "vivaldi-snapshot")),# snap packaging("chromium-snap", os.path.join(snap, "chromium", "common", "chromium")),# flatpak packaging@@ -93,6 +97,8 @@ def _chromium_roots():"BraveSoftware", "Brave-Browser")),("chromium-flatpak", os.path.join(var, "org.chromium.Chromium","config", "chromium")),+ ("vivaldi-flatpak", os.path.join(var, "com.vivaldi.Vivaldi",+ "config", "vivaldi")),]return []@@ -331,9 +337,11 @@ def _locked_note(path, exc):"may remain at {}. Remove this temporary directory when its files can ""be released.".format(leftover) if leftover else "")browser_name = "the browser"- for marker, label in (("BraveSoftware", "Brave"), ("Google", "Chrome"),- ("Microsoft", "Edge"), ("Mozilla", "Firefox")):- if marker in path:+ lowered = path.lower()+ for marker, label in (("bravesoftware", "Brave"), ("vivaldi", "Vivaldi"),+ ("google", "Chrome"), ("microsoft", "Edge"),+ ("mozilla", "Firefox")):+ if marker in lowered:browser_name = labelbreakif (isinstance(exc, PermissionError) or getattr(exc, "errno", None) == 13@@ -1129,7 +1137,7 @@ def run(ctx) -> ModuleResult:"{}".format(sys.platform))return r- # --- Chromium family: Chrome, Edge, Brave, Chromium ---------------------+ # --- Chromium family: Chrome, Edge, Brave, Vivaldi, Chromium ---------------------for label, root in CHROMIUM_ROOTS:problem = path_problem(root)if problem:diff --git a/scan/tests/test_vivaldi.py b/scan/tests/test_vivaldi.pynew file mode 100644index 0000000..8a463cd--- /dev/null+++ b/scan/tests/test_vivaldi.py@@ -0,0 +1,56 @@+"""Vivaldi (Chromium-based) is discovered and scanned like the other Chromium browsers."""++import os+import sys+import unittest+from unittest.mock import patch++sys.path[:0] = [os.path.dirname(os.path.dirname(__file__)), os.path.dirname(__file__)]++from test_browser_launch import (BrowserLaunchBase, TEST_DOMAIN,+ chromium_history_db)+from adint_scan.modules import browser+++class TestVivaldiRoots(unittest.TestCase):+ def roots(self, platform, **env):+ with patch.object(browser.sys, "platform", platform), \+ patch.object(browser, "LOCAL", env.get("local", "")), \+ patch.object(browser.os.path, "expanduser", lambda p: "/home/u"):+ return dict(browser._chromium_roots())++ def test_windows(self):+ roots = self.roots("win32", local="C:\\L")+ self.assertIn("vivaldi", roots)+ self.assertTrue(roots["vivaldi"].endswith(os.path.join("Vivaldi", "User Data")))++ def test_macos(self):+ roots = self.roots("darwin")+ self.assertTrue(roots["vivaldi"].endswith(os.path.join("Application Support", "Vivaldi")))++ def test_linux(self):+ roots = self.roots("linux")+ self.assertTrue(roots["vivaldi"].endswith(os.path.join(".config", "vivaldi")))+ self.assertIn("vivaldi-snapshot", roots)+ self.assertIn("vivaldi-flatpak", roots)+++class TestVivaldiScan(BrowserLaunchBase):+ def test_history_hit_in_vivaldi_profile(self):+ ud = os.path.join(self.tmp, "Vivaldi", "User Data")+ chromium_history_db(os.path.join(ud, "Default", "History"),+ "https://{}/x".format(TEST_DOMAIN))+ browser.CHROMIUM_ROOTS = [("vivaldi", ud)]+ browser.ROAMING = browser.LOCAL = self.empty+ result = browser.run(self.ctx)+ self.assertTrue(result.hits, "an indicator in Vivaldi history must be found")++ def test_locked_note_names_vivaldi(self):+ for path in (r"C:\Users\u\AppData\Local\Vivaldi\User Data\Default\History",+ "/home/u/.config/vivaldi/Default/History"):+ note = browser._locked_note(path, PermissionError(13, "locked"))+ self.assertIn("Vivaldi", note)+++if __name__ == "__main__":+ unittest.main()