traceveil 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 nitya-prakash-pandey-2005
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,156 @@
1
+ Metadata-Version: 2.4
2
+ Name: traceveil
3
+ Version: 0.1.0
4
+ Summary: Developer CLI that runs Traceveil privacy/consent audits on an Android phone over adb and saves JSON reports.
5
+ Author: Traceveil contributors
6
+ License: MIT
7
+ Project-URL: Repository, https://github.com/agrimsri/IQOO-Kernel-Panic
8
+ Keywords: android,adb,privacy,consent,dpdp,audit
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Security
18
+ Classifier: Topic :: Software Development :: Testing
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # Traceveil CLI
25
+
26
+ Run a Traceveil privacy audit on your Android phone from your laptop, and get a JSON report back. Everything goes over USB (adb); nothing is uploaded.
27
+
28
+ ```
29
+ laptop phone (debug build of Traceveil)
30
+ traceveil audit --adb broadcast--> DebugAuditReceiver -> runs the normal audit
31
+ ^ |
32
+ | adb shell cat v
33
+ +-------- report.json <--- /sdcard/Android/data/com.dpdpxray.app/files/reports/<id>/
34
+ saves .traceveil/reports/<id>.json
35
+ ```
36
+
37
+ The trigger exists **only in debug builds**. Release builds have no way to start an audit from adb.
38
+
39
+ ## 1. One-time setup
40
+
41
+ You need: Python 3.11+, JDK 17, Android platform-tools (adb), a phone with USB debugging on.
42
+
43
+ Install the CLI (from PyPI once published, or from a checkout):
44
+
45
+ ```bash
46
+ pipx install traceveil # or: pip install traceveil
47
+ pip install -e . # from a checkout; `python3 -m traceveil` also works
48
+ ```
49
+
50
+ The examples below use `python3 -m traceveil`; the installed `traceveil` command is identical.
51
+
52
+ ```bash
53
+ # 1. Build and install the debug app (run from the repo root)
54
+ bash ./gradlew :app:assembleDebug :leakyshop:assembleLeakyDebug
55
+ adb install -r app/build/outputs/apk/debug/app-debug.apk
56
+ adb install -r leakyshop/build/outputs/apk/leaky/debug/leakyshop-leaky-debug.apk # demo app to audit
57
+
58
+ # 2. Check the phone is ready
59
+ python3 -m traceveil doctor
60
+ ```
61
+
62
+ Under **WSL2** the Linux `adb` cannot see USB phones. Use the Windows one for every command:
63
+ `--adb /mnt/c/Users/<you>/AppData/Local/Android/Sdk/platform-tools/adb.exe` (or `export ADB=...`).
64
+ Install the APK with that adb too, from a Windows path.
65
+
66
+ On the phone, once:
67
+ 1. **Open Traceveil** and allow the **VPN** permission (Android only delivers the trigger to an app that has been opened).
68
+ 2. Turn on the **Traceveil accessibility service** (Settings > Accessibility).
69
+ 3. Set **Private DNS = Off** (otherwise lookups are hidden from the audit).
70
+
71
+ ## 2. Run an audit
72
+
73
+ ```bash
74
+ python3 -m traceveil audit --package com.leakyshop.demo
75
+ ```
76
+
77
+ With several phones attached add `--serial <serial>` (`adb devices` lists them).
78
+
79
+ What happens, step by step:
80
+
81
+ 1. The CLI checks Traceveil is installed and sends the trigger. You see `audit started: cli-<time>-<id>`.
82
+ 2. The phone runs the audit (about 1 to 3 minutes for three plans). By default **you tap Accept / Reject on the phone** when asked. Add `--auto-drive` to let Traceveil tap.
83
+ 3. The CLI waits (default 15 min, change with `--wait <seconds>`), then reads `report.json` from the phone and checks it is valid.
84
+ 4. It saves the report to `.traceveil/reports/<request_id>.json` and prints a summary:
85
+
86
+ ```
87
+ Traceveil audit LeakyShop (com.leakyshop.demo) score 21 / AT_RISK findings 5
88
+ C1 HIGH Trackers contacted before consent
89
+ ...
90
+ policy: 3 finding(s) at or above high
91
+ report saved: .traceveil/reports/cli-20261010T071219Z-0f9239c5.json
92
+ ```
93
+
94
+ Useful options:
95
+
96
+ | Option | What it does |
97
+ |---|---|
98
+ | `--plans silent,reject,accept` | Pick plans (default all three; one plan is quick but often gives an inconclusive score) |
99
+ | `--json` | Print the full JSON instead of the summary |
100
+ | `--out report.json` | Also write the JSON to a file you choose |
101
+ | `--auto-drive` | Traceveil taps Accept/Reject itself |
102
+ | `--reset` | Clear the app's data first. **Only for your own test apps**; needs Shizuku |
103
+ | `--resume <request_id>` | Fetch the result of an earlier run (after a timeout or unplug) |
104
+
105
+ Settings you use often can live in `traceveil.toml` (`python3 -m traceveil init` creates it): `target.package`, `audit.fail_on`, `audit.min_score`, `output.dir`.
106
+
107
+ ## 3. The report
108
+
109
+ ```json
110
+ {
111
+ "schemaVersion": 1,
112
+ "requestId": "cli-20261010T071219Z-0f9239c5",
113
+ "auditId": "audit-1791616339835",
114
+ "target": { "package": "com.leakyshop.demo", "label": "LeakyShop" },
115
+ "device": { "model": "vivo I2501", "androidVersion": "16" },
116
+ "score": 21,
117
+ "band": "AT_RISK",
118
+ "findingCount": 5,
119
+ "findings": [
120
+ { "check": "C1", "severity": "HIGH", "title": "Trackers contacted before consent", "confidence": 1.0 }
121
+ ],
122
+ "sessions": [ { "plan": "REJECT", "netEvents": 12, "consentChoice": "REJECT", "notes": [] } ]
123
+ }
124
+ ```
125
+
126
+ `score` is `null` (never 0) when the result is inconclusive. The report is a technical assessment, not legal advice.
127
+
128
+ ## 4. Exit codes (for scripts and CI)
129
+
130
+ | Code | Meaning |
131
+ |---|---|
132
+ | 0 | Finished, policy passed |
133
+ | 1 | Policy failed (score below `min_score`, or a finding at/above `fail_on`) |
134
+ | 2 | Inconclusive, app-reported failure, or missing/malformed report |
135
+ | 3 | Device or trigger problem (no phone, app missing, VPN/accessibility off, another audit running) |
136
+ | 4 | Bad arguments |
137
+ | 6 | Timed out (the audit keeps running; use `--resume`) |
138
+
139
+ ## 5. If something goes wrong
140
+
141
+ - **Phone unplugged mid-audit**: the CLI prints a yellow message. Reconnect, unlock the phone, press Enter to retry (or `q` to quit). The audit keeps running on the phone; `--resume <request_id>` picks it up later.
142
+ - **"no debug trigger answered"**: install the *debug* APK and open Traceveil once. A force-stopped app does not receive the trigger.
143
+ - **"VPN permission not granted" / "accessibility service is off"**: do steps 1 and 2 of the phone setup.
144
+ - **Timeout**: raise `--wait`, or run again with `--resume <id>`.
145
+ - **Device "unauthorized"**: unlock the phone and tap Allow on the USB debugging prompt.
146
+
147
+ Safety: audit only your own test apps (like the LeakyShop demos). The CLI never force-stops anything and never uploads data.
148
+
149
+ ## 6. Tests
150
+
151
+ ```bash
152
+ pip install -e . && python3 -m unittest tools.tests.test_traceveil_audit tools.tests.test_traceveil_cli # CLI, no phone needed
153
+ bash ./gradlew :core:test :app:testDebugUnitTest # Android side
154
+ ```
155
+
156
+ More detail (design, limits, device evidence): `docs/CLI_AUDIT.md`.
@@ -0,0 +1,352 @@
1
+ # TraceVeil
2
+
3
+ Team Kernel Panic: [nitya-prakash-pandey-2005](https://github.com/nitya-prakash-pandey-2005), [agrimsri](https://github.com/agrimsri), and [yashviup](https://github.com/yashviup).
4
+
5
+ This repository starts from the existing DPDP X-Ray baseline, developed before the finale. See [source provenance](PROVENANCE.md) for the baseline date and import scope. New development builds on that baseline. AI coding assistance is used during development. The applicability of the prototype-reuse rule must be resolved before this repository is presented as an eligible event submission.
6
+
7
+ Screenshots below show the original baseline and may display its former product name.
8
+
9
+ Current team setup and work split: [teammate handoff](docs/TEAM_HANDOFF.md), [active milestones](docs/planning/IMPLEMENTATION_MILESTONES.md), and [device verification](docs/VERIFICATION.md). Agrim starts the evidence contracts; Yashvi starts Voice Copilot; Nitya integrates their tested components. The handoff documents known AI failures and unfinished features.
10
+
11
+ **Testing safety:** audit configuration defaults to keeping data and manual consent choices. The setup screen presets automation/reset only for the two controlled demo apps. Clearing another test app's data requires an explicit reset choice and Shizuku; keep that choice off for personal apps. Real-app observation is limited: it does not inspect encrypted payloads or provide comprehensive fraud protection, automatic permission interception or a background wake word. DNS observations and scores are not legal certification.
12
+
13
+ **An on-device privacy auditor for Android apps, built around India's Digital Personal Data Protection (DPDP) Act 2023.**
14
+
15
+ Point TraceVeil at any app installed on your phone. It shows you:
16
+ - which tracking companies the app contacts;
17
+ - whether it does so **before** the user has agreed to anything;
18
+ - whether it **keeps doing it after the user says no**.
19
+
20
+ It reviews the app's consent screen for potential dark patterns, provides relevant DPDP passages and developer fix templates, and exports a PDF report. Findings are technical signals for review, not determinations that an app broke the law. The evidence workflow can be used internationally; the current legal corpus is India-specific and voice UI supports English/Hindi.
21
+
22
+ Audit analysis, saved reports and the default voice copilot run on the phone without a cloud-answer fallback. Capture relays the target app's DNS queries. Network Proof shows qualified UID/DNS estimates, not a measured guarantee of zero uploads. Speech-pack downloads require a user action and provider connectivity; they are not cloud speech recognition. Reports leave the device when you choose to share them.
23
+
24
+ <p align="center">
25
+ <img src="docs/screenshots/home.png" width="230" alt="Home screen">
26
+ <img src="docs/screenshots/timeline-reject.png" width="230" alt="Live timeline: trackers keep firing after the user refused">
27
+ <img src="docs/screenshots/results.png" width="230" alt="Audit result: score 21, at risk">
28
+ </p>
29
+
30
+ ---
31
+
32
+ ## Contents
33
+
34
+ - [Why this exists](#why-this-exists)
35
+ - [What TraceVeil checks](#what-traceveil-checks)
36
+ - [Screenshots](#screenshots)
37
+ - [How an audit works](#how-an-audit-works)
38
+ - [Architecture](#architecture)
39
+ - [Getting started](#getting-started)
40
+ - [Using TraceVeil](#using-traceveil)
41
+ - [The LeakyShop test app](#the-leakyshop-test-app)
42
+ - [On-device AI](#on-device-ai)
43
+ - [Privacy of TraceVeil itself](#privacy-of-traceveil-itself)
44
+ - [Limitations](#limitations)
45
+ - [Roadmap](#roadmap)
46
+ - [Licence and attributions](#licence-and-attributions)
47
+
48
+ ---
49
+
50
+ ## Why this exists
51
+
52
+ The DPDP Act 2023 and the DPDP Rules 2025 make consent the centre of personal-data processing in India. Consent must be **free, specific, informed, unconditional and unambiguous, with a clear affirmative action** (Section 6(1)). It must also be as easy to withdraw as it was to give (Section 6(4)).
53
+
54
+ Most Android apps ship third-party SDKs (analytics, attribution, ads, crash reporting) that start talking to their servers the moment the app opens. That is often before any consent screen appears, and sometimes even after the user taps "Reject".
55
+
56
+ Developers rarely do this on purpose. An SDK's default `init()` call is usually enough. But nobody can see it happening:
57
+ - **Developers** can't see which SDKs phone home, or when.
58
+ - **Product and legal teams** get a consent banner from design, not proof that it works.
59
+ - **Users** have no way to tell whether "Reject" means anything.
60
+
61
+ Existing tools don't close the gap:
62
+ - Network proxies need a laptop, a certificate and an expert.
63
+ - Static scanners list SDKs but can't say *when* they fire relative to a consent choice.
64
+ - Cloud scanners upload the app and its traffic somewhere else.
65
+
66
+ TraceVeil observes DNS lookups on the phone and relates them to recorded consent choices. Controlled full audits can reset a test app and exercise no interaction, Reject and Accept. Quick observation preserves a real app's current state unless the tester explicitly approves a reset; cached consent and encrypted DNS can limit evidence. An intended choice that never occurred is marked incomplete rather than treated as a passed check.
67
+
68
+ ## What TraceVeil checks
69
+
70
+ | Check | What it means | DPDP basis | Penalty ceiling |
71
+ |---|---|---|---|
72
+ | **C1** | Trackers contacted **before** any consent choice | s.4(1), s.6(1) | up to ₹50 crore |
73
+ | **C2** | Trackers contacted **after the user refused** | s.4(1), s.6(1) | up to ₹50 crore |
74
+ | **C3** | A consent option is pre-ticked | s.6(1), "clear affirmative action" | up to ₹50 crore |
75
+ | **C4** | No way to refuse, or refusal hidden behind "Manage" | s.6(1), s.6(4) | up to ₹50 crore |
76
+ | **C5** | One button bundles several purposes | s.6(1), Rule 3(b) | up to ₹50 crore |
77
+ | **C6** | The notice doesn't itemise the data or state the purpose | s.5(1), Rule 3(b) | up to ₹50 crore |
78
+ | **C7** | No visible way to withdraw consent | s.6(4), Rule 3(c) | up to ₹50 crore |
79
+ | **C8** | Notice offered only in English | s.5(3), s.6(3) | up to ₹50 crore |
80
+ | **C9** | Tracking in an app used by children | s.9(1), s.9(3) | **up to ₹200 crore** |
81
+ | **C10** | Ad or device IDs likely shared before consent (*inferred*) | s.6(1) | up to ₹50 crore |
82
+ | **NC** | No consent mechanism at all, yet trackers are contacted | s.5(1), s.6(1), s.6(10) | up to ₹50 crore |
83
+ | **V0** | Too few network lookups to judge, so the result is **inconclusive** (never "clean") | — | — |
84
+
85
+ Each finding is labelled either:
86
+ - **observed**: seen on the device during the audit;
87
+ - **inferred**: derived from SDK documentation or AI review.
88
+
89
+ All findings combine into a **DPDP readiness score** out of 100, with bands from *At risk* to *DPDP-ready*.
90
+
91
+ > Penalty ceilings are the statutory maximums in the DPDP Act Schedule, not predicted fines. TraceVeil is a technical assessment tool, **not legal advice**.
92
+
93
+ ## Screenshots
94
+
95
+ | Home and readiness checks | Pick the app to audit | Choose the audit plan |
96
+ |:---:|:---:|:---:|
97
+ | <img src="docs/screenshots/home.png" width="240"> | <img src="docs/screenshots/picker.png" width="240"> | <img src="docs/screenshots/setup.png" width="240"> |
98
+ | Everything TraceVeil needs (VPN, consent watcher, Shizuku, Private DNS, AI model) with one-tap fixes. | Any installed app, searchable. | **Full audit** (three runs from a fresh install) or **Quick audit** (one run). The agent can tap Accept and Reject for you. |
99
+
100
+ | Live timeline | Result | Finding detail |
101
+ |:---:|:---:|:---:|
102
+ | <img src="docs/screenshots/timeline-reject.png" width="240"> | <img src="docs/screenshots/results.png" width="240"> | <img src="docs/screenshots/finding.png" width="240"> |
103
+ | Every tracker lookup is timed against the consent choice. Here the user refused at 15.1 s, and AppsFlyer, Meta and Google Analytics were contacted again 0.1 s later. | Score, severity bar, one-line summary and every finding with its evidence level and penalty ceiling. | The evidence (each host and when it was contacted), plus the **verbatim** DPDP text it breaks. |
104
+
105
+ | How to fix | Report | PDF export |
106
+ |:---:|:---:|:---:|
107
+ | <img src="docs/screenshots/fixes.png" width="240"> | <img src="docs/screenshots/report.png" width="240"> | <img src="docs/screenshots/pdf.png" width="240"> |
108
+ | SDK-specific code and manifest changes, ready to copy. | Markdown report with a summary table, findings, evidence and citations. | A shareable PDF saved to `Downloads/TraceVeil`. |
109
+
110
+ | A leaky consent screen | A compliant consent screen | After the fix |
111
+ |:---:|:---:|:---:|
112
+ | <img src="docs/screenshots/leakyshop-consent.png" width="240"> | <img src="docs/screenshots/leakyshop-fixed-consent.png" width="240"> | <img src="docs/screenshots/fixed-result.png" width="240"> |
113
+ | Pre-ticked box, no Reject button (it's hidden behind "Manage"). | Equal Accept and Reject buttons, off-by-default toggles, withdrawal notice, three languages. | The same audit on the fixed app: **100, DPDP-ready**. |
114
+
115
+ ## How an audit works
116
+
117
+ ```
118
+ ┌──────────────┐ pm clear (Shizuku) ┌──────────────────────────┐
119
+ │ Fresh install│ ──────────────────────▶ │ Per-app DNS capture (VPN) │
120
+ └──────────────┘ └────────────┬─────────────┘
121
+ │ every lookup, timestamped
122
+ ┌──────────────────────────────┐ ▼
123
+ │ Consent watcher │ ┌──────────────────────────┐
124
+ │ (AccessibilityService) │──────▶ │ Phase assigner │
125
+ │ • detects the consent screen │ taps, │ before choice / after │
126
+ │ • reads the UI tree │ times │ accept / after refusal │
127
+ │ • takes a screenshot │ └────────────┬─────────────┘
128
+ │ • taps Reject / Accept │ │
129
+ └──────────────┬───────────────┘ ▼
130
+ │ screenshot ┌──────────────────────────────┐
131
+ ▼ │ Rules engine C1–C10, NC, V0 │
132
+ ┌──────────────────────────────┐ │ + readiness score │
133
+ │ On-device Gemma (optional) │───▶ └────────────┬─────────────────┘
134
+ │ constrained-JSON screen review│ ▼
135
+ └──────────────────────────────┘ ┌──────────────────────────────┐
136
+ │ Citations (BM25 + embeddings) │
137
+ │ Fix catalogue · PDF/Markdown │
138
+ └──────────────────────────────┘
139
+ ```
140
+
141
+ A **full audit** runs three plans, each from a clean install:
142
+
143
+ 1. **No interaction:** open the app and don't touch anything. Shows what fires before the user even sees a choice.
144
+ 2. **Reject:** refuse consent. If refusal is hidden behind "Manage", the agent opens it and refuses there, and records that refusal was hidden (C4). This run proves **C2**.
145
+ 3. **Accept:** give consent. This is the baseline for what the app does with permission.
146
+
147
+ A **quick audit** runs one plan (open the app and accept) in about 40 seconds.
148
+
149
+ ### The key technical ideas
150
+
151
+ - **Per-app DNS capture without root.**
152
+ - TraceVeil's `VpnService` routes only the target app (`addAllowedApplication`) and only a fake DNS server address through the tunnel.
153
+ - Every DNS query is logged with a nanosecond timestamp, then forwarded to the real resolver through a protected socket.
154
+ - Answers are rewritten to **TTL 0**, so Android never caches them and every new connection shows up as a fresh lookup.
155
+ - No other traffic is touched, decrypted or stored.
156
+ - **Exact consent timing.**
157
+ - The accessibility service watches the target app's window with a short trailing debounce.
158
+ - It recognises consent screens with a multilingual lexicon (English, Hindi, Kannada), and records the precise moment of the Accept or Reject tap.
159
+ - When the user taps by hand on a screen that doesn't report taps (for example Jetpack Compose), the choice is inferred when the dialog closes.
160
+ - **Fresh install every run.** Through [Shizuku](https://shizuku.rikka.app/), TraceVeil runs `pm clear`, `am force-stop` and `am start` with shell privileges, with no root and no PC.
161
+ - **Observed facts win.**
162
+ - Deterministic checks on the accessibility tree are merged with the AI's screenshot review.
163
+ - When they disagree, the tree wins and the disagreement is shown, never hidden.
164
+ - **The law, verbatim.**
165
+ - The relevant DPDP sections (s.4, 5, 6, 9, Rule 3 and the Schedule) ship with the app.
166
+ - Each finding cites its own sections.
167
+ - Free-text questions are answered by BM25 retrieval, optionally upgraded with EmbeddingGemma semantic search.
168
+
169
+ ## Architecture
170
+
171
+ ```
172
+ kernel-panic/
173
+ ├── core/ Pure Kotlin/JVM library: all the logic, fully unit-tested
174
+ ├── app/ The Android app (Jetpack Compose)
175
+ └── leakyshop/ A small test app with "leaky" and "fixed" flavours
176
+ ```
177
+
178
+ ### `core/`: the auditing brain (no Android dependencies)
179
+
180
+ | Package | Responsibility |
181
+ |---|---|
182
+ | `model` | Audit plans, network events, consent events, screen audits, findings, scores |
183
+ | `dns` | DNS packet parsing, response building, SERVFAIL, TTL rewriting |
184
+ | `trackers` | Catalogue of 36 tracker families, including Indian SDKs such as CleverTap, MoEngage, WebEngage and InMobi, with categories (analytics, attribution, advertising, crash reporting…) |
185
+ | `consent` | Consent-screen lexicon in English, Hindi and Kannada |
186
+ | `audit` | Phase assigner: places each lookup before the choice, after accept, or after refusal |
187
+ | `screen` | UI-tree formatter, deterministic screen auditor, AI response parser, merge logic, the constrained-JSON prompt and schema |
188
+ | `rules` | Rules engine C1–C10, NC, V0 and the score calculator |
189
+ | `fixes` | Fix catalogue: SDK-specific code and manifest changes plus UI fixes |
190
+ | `dpdp` | Verbatim DPDP corpus, BM25 retriever, citation service |
191
+ | `report` | JSON and Markdown report generation |
192
+
193
+ **65 unit tests** cover the DNS codec, tracker matching, lexicon, phase assignment, every rule, screen auditing, fixes, citations and reports.
194
+
195
+ ### `app/`: the Android side
196
+
197
+ | Package | Responsibility |
198
+ |---|---|
199
+ | `capture` | `XrayVpnService` (per-app DNS tunnel), `DnsForwarder`, `CaptureBus` |
200
+ | `consent` | `ConsentAccessibilityService`: consent detection, UI-tree mapping, screenshots, Accept/Reject taps |
201
+ | `control` | `ShizukuBridge` (clear, stop and start apps) and device readiness checks |
202
+ | `ai` | LiteRT-LM engine (Gemma) on GPU, CPU or NPU: screen review, plain-language explanations, EmbeddingGemma retrieval, benchmark |
203
+ | `audit` | `AuditOrchestrator`: runs the plans, coordinates capture, watcher, agent taps and AI, then produces the result |
204
+ | `data` | Audit history, settings, a clearly labelled sample audit |
205
+ | `report` | PDF rendering and export to Downloads or the share sheet |
206
+ | `ui` | Compose screens: home, app picker, live audit, results, finding detail, fixes, report, AI lab, camera check, settings |
207
+
208
+ ### Tech stack
209
+
210
+ - **Language and UI:** Kotlin 2.4, Jetpack Compose (Material 3), kotlinx.serialization, coroutines.
211
+ - **On-device AI:** [LiteRT-LM](https://github.com/google-ai-edge/LiteRT-LM) running Gemma (screen review and explanations) and EmbeddingGemma (semantic legal search).
212
+ - **Privileged control:** [Shizuku](https://github.com/RikkaApps/Shizuku) API.
213
+ - **Platform APIs:** `VpnService`, `AccessibilityService` (including `takeScreenshot`), `PdfDocument`.
214
+ - **Build:** Android Gradle Plugin 9, compileSdk 37, minSdk 29 (Android 10+), targetSdk 36.
215
+
216
+ ## Getting started
217
+
218
+ ### Requirements
219
+
220
+ - An Android phone running **Android 10 or newer**. On Android 10, consent screens are checked from the accessibility tree only (screenshots need Android 11+). Arm64 is recommended; debug builds also run on the x86_64 emulator.
221
+ - To build from source: **JDK 17** and the **Android SDK** (platform 37, build-tools 36 or newer).
222
+ - Optional:
223
+ - [Shizuku](https://shizuku.rikka.app/), for fresh-install resets and full audits.
224
+ - A Gemma `.litertlm` model, for AI screen review and explanations.
225
+
226
+ ### Build
227
+
228
+ ```bash
229
+ git clone https://github.com/agrimsri/IQOO-Kernel-Panic.git
230
+ cd IQOO-Kernel-Panic
231
+
232
+ ./gradlew :core:test # run the 65 unit tests
233
+ ./gradlew :app:assembleDebug # build TraceVeil
234
+ ./gradlew :leakyshop:assembleLeakyDebug :leakyshop:assembleFixedDebug # build the test apps
235
+ ```
236
+
237
+ ### Install
238
+
239
+ ```bash
240
+ adb install app/build/outputs/apk/debug/app-debug.apk
241
+ adb install leakyshop/build/outputs/apk/leaky/debug/leakyshop-leaky-debug.apk
242
+ adb install leakyshop/build/outputs/apk/fixed/debug/leakyshop-fixed-debug.apk
243
+ ```
244
+
245
+ ### One-time phone setup
246
+
247
+ TraceVeil's home screen lists every item under **Before you audit**, with a button to fix each one.
248
+
249
+ 1. **VPN permission:** tap **Allow**. The VPN only carries DNS lookups for the app being audited.
250
+ 2. **Consent watcher:** tap **Turn on**, then go to Accessibility, choose **TraceVeil consent watcher**, and turn it on.
251
+ 3. **Fresh-install reset** (recommended):
252
+ - Install Shizuku and start it with Wireless debugging (everything happens on the phone; no PC needed).
253
+ - Tap **Allow** in TraceVeil.
254
+ - Without Shizuku, quick audits still work.
255
+ 4. **Private DNS:** set it to **Off** (Settings → Network → Private DNS). With it on, Android sends lookups over encrypted DNS that TraceVeil can't see.
256
+ 5. **On-device AI** (optional): see [On-device AI](#on-device-ai).
257
+
258
+ ## Using TraceVeil
259
+
260
+ 1. **Audit an app:** pick the app, then choose:
261
+ - **Full audit** (about 2 minutes; about 1 minute with *Fast audits* on);
262
+ - **Quick audit** (about 40 seconds).
263
+ 2. **Agent taps:**
264
+ - Keep **Let the agent tap Accept and Reject** on to make the audit fully automatic.
265
+ - Turn it off to tap the buttons yourself when asked.
266
+ - Turn on **This app is used by children** to add the Section 9 check.
267
+ 3. **Watch the live timeline:**
268
+ - Each lookup appears with its time, company and category.
269
+ - Trackers contacted before a choice, or after a refusal, turn red.
270
+ - **Mark consent now** records a consent moment by hand for screens that expose no text, such as games or canvas-drawn UI.
271
+ 4. **Read the result:**
272
+ - The score and its band.
273
+ - The findings, ordered by severity. Tap one to see the evidence, the exact DPDP text, and an on-device explanation in English or Hindi.
274
+ 5. **How to fix:** copy the SDK-specific code or manifest change, rebuild, and audit again.
275
+ 6. **Report and export:**
276
+ - **Save PDF to Downloads**, **Share PDF**, or **Save Markdown**.
277
+ - Files go to `Downloads/TraceVeil`.
278
+ 7. **Camera check:** photograph or choose a screenshot of any consent screen, including one on another device, for an instant dark-pattern review.
279
+
280
+ Other tools:
281
+ - **Settings:**
282
+ - *Presentation mode*: larger text for projectors and screen sharing.
283
+ - *Fast audits*: shorter waits.
284
+ - *Load AI when an audit starts.*
285
+ - **Your own domains**: long-press a host on any timeline so your own backend is never counted as a tracker.
286
+ - **Open sample audit:** a complete, clearly labelled sample result, so you can explore the app before setting anything up.
287
+
288
+ ## The LeakyShop test app
289
+
290
+ `leakyshop/` is a tiny shopping app built to exercise every check. It contains **no real SDKs**: it performs the same DNS lookups that AppsFlyer, the Meta SDK and Firebase Analytics make, and sends no data.
291
+
292
+ | Flavour | Behaviour | TraceVeil result |
293
+ |---|---|---|
294
+ | **leaky** | Starts the "SDKs" on launch, pre-ticks a sharing box, hides Reject behind "Manage", and keeps tracking after refusal | **21, At risk**: C2 critical, plus C1, C3, C4 and C10 |
295
+ | **fixed** | Waits for consent, uses off-by-default toggles, gives Accept and Reject equal weight, offers three languages, explains withdrawal | **100, DPDP-ready** |
296
+
297
+ It is a safe, repeatable way to see each finding fire, and to check that the suggested fixes make them go away.
298
+
299
+ ## On-device AI
300
+
301
+ TraceVeil works without any model: screen checks then use the accessibility tree only. Adding a model enables:
302
+ - **AI screen review:** Gemma reads the consent screenshot and returns structured JSON (buttons, pre-ticked options, languages, dark patterns). That is merged with the tree facts.
303
+ - **Plain-language explanations** of each finding, in English or Hindi.
304
+ - **Semantic legal search** with EmbeddingGemma.
305
+ - **A benchmark** on CPU, GPU and NPU in the **AI lab**.
306
+
307
+ Copy model files into the app's models folder (no root needed):
308
+
309
+ ```bash
310
+ adb push gemma-4-E2B-it.litertlm /sdcard/Android/data/com.dpdpxray.app/files/models/
311
+ ```
312
+
313
+ - A file name containing `embed` is loaded as the embedding model.
314
+ - A Qualcomm NPU bundle (file name containing `npu` or the SoC id) enables the NPU backend.
315
+ - Models are not bundled; they're covered by the Gemma Terms of Use.
316
+
317
+ ## Privacy of TraceVeil itself
318
+
319
+ - **No uploads.** Capture, AI analysis and reports are all produced on the phone. Reports leave the device only when you share them.
320
+ - **DNS only.** The VPN carries DNS lookups for the one app under audit. TraceVeil doesn't intercept, decrypt or store any other traffic.
321
+ - The `INTERNET` permission exists only to forward those DNS lookups to the real resolver.
322
+ - The accessibility service reads the target app's window only during an audit.
323
+ - There are no analytics, ads or crash-reporting SDKs in TraceVeil.
324
+
325
+ ## Limitations
326
+
327
+ - **DNS-level evidence.** TraceVeil sees that an app *tried to contact* a tracker, not what it sent. Claims about payloads (for example advertising IDs) are always labelled *inferred*.
328
+ - **Hidden lookups.** Apps using their own DNS-over-HTTPS, hard-coded IPs, or long-lived connections can avoid fresh lookups. When too little is seen, TraceVeil reports **inconclusive**, never "clean".
329
+ - **Legitimate uses.** Some processing may rely on a legitimate use under Section 7 rather than consent. TraceVeil flags the technical behaviour; whether an exemption applies is a legal judgement.
330
+ - **Canvas-drawn UIs.** Some games and Flutter or Unity apps expose no accessibility text. Use **Mark consent now** together with the AI screenshot review.
331
+ - **Play services.** Some SDKs send data through Google Play services. The optional *Include Google Play services lookups* setting captures them, at the cost of also seeing other apps' Play traffic.
332
+
333
+ ## Roadmap
334
+
335
+ - Payload-level evidence for debug builds the developer controls.
336
+ - A CI mode: run the rules engine against a capture file in a pull request.
337
+ - More languages for the consent lexicon and notices (Tamil, Telugu, Bengali, Marathi).
338
+ - Tracker catalogue updates from a signed, offline-verifiable list.
339
+ - Checks for consent-manager integrations and withdrawal flows deeper in app settings.
340
+
341
+ ## Licence and attributions
342
+
343
+ - **Code:** [MIT License](LICENSE) © 2026 Nitya Prakash Pandey.
344
+ - **Archivo font:** SIL Open Font License 1.1 (Omnibus-Type).
345
+ - **LiteRT-LM:** Apache License 2.0.
346
+ - **Shizuku API/provider 13.1.5:** MIT License (separate from the Shizuku app).
347
+ - **Gemma models:** Gemma Terms of Use (not bundled).
348
+ - **DPDP Act 2023 and DPDP Rules 2025:** text from Government of India publications.
349
+
350
+ See the [attribution register](ATTRIBUTIONS.md) for licence evidence and remaining release checks, and [repository checks](docs/REPOSITORY_CHECKS.md) for CI and the read-only commit-date checker.
351
+
352
+ > TraceVeil is a technical assessment tool. Its findings are not legal advice.
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "traceveil"
7
+ dynamic = ["version"]
8
+ description = "Developer CLI that runs Traceveil privacy/consent audits on an Android phone over adb and saves JSON reports."
9
+ readme = "tools/README.md"
10
+ requires-python = ">=3.11"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "Traceveil contributors" }]
13
+ keywords = ["android", "adb", "privacy", "consent", "dpdp", "audit"]
14
+ classifiers = [
15
+ "Environment :: Console",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Security",
24
+ "Topic :: Software Development :: Testing",
25
+ ]
26
+ dependencies = [] # standard library only; needs Android platform-tools (adb) on PATH or via --adb
27
+
28
+ [project.urls]
29
+ Repository = "https://github.com/agrimsri/IQOO-Kernel-Panic"
30
+
31
+ [project.scripts]
32
+ traceveil = "traceveil.cli:main"
33
+
34
+ [tool.setuptools.dynamic]
35
+ version = { attr = "traceveil.__version__" }
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,12 @@
1
+ """Traceveil developer CLI: drives an iQOO/Android device over adb and reports network-environment signals."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ # Process exit codes, also reported in the JSON verdict.
6
+ EXIT_PASS = 0
7
+ EXIT_FINDINGS = 1
8
+ EXIT_INCONCLUSIVE = 2
9
+ EXIT_DEVICE = 3
10
+ EXIT_USAGE = 4
11
+ EXIT_POLICY = 5
12
+ EXIT_TIMEOUT = 6
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())