How soni-shivam/c-s-cool-stuff works
Purpose and entry points
DRISHTI is a defensive Android APK triage system: it produces calibrated threat scoring, evidence-grounded analysis, signed provenance, and reports. The primary backend orchestration entry point is drishti/pipeline.py; API startup and job control are in drishti/api/main.py and drishti/api/jobs.py. Makefile drives local install, test, and API startup. v1-reference/ is a frozen, non-imported predecessor.
Contract-first analysis boundary
Typed contracts define handoffs among all stages: APK/corpus inputs, static findings, dynamic traces, AI verdicts, scores, containment evidence, and final verdicts. These contracts are the principal compatibility boundary for the pipeline, API, UI, and Android consumer.
• drishti/contracts/base.py
• drishti/contracts/static_report.py
• drishti/contracts/verdict.py
M1–M2: ingestion and static reverse engineering
M1 validates and identifies incoming APKs, applies reputation/intelligence checks, and creates the analysis record. M2 decompiles and inspects manifests/code, call graphs, sensitive sinks, permission combinations, and brand impersonation; it produces structured evidence and hypotheses rather than an executable result.
• drishti/m1_ingest/ingest.py
• drishti/m2_static/engine.py
• drishti/m2_static/lookalike.py
M3: sealed active detonation
Dynamic execution is explicitly isolated from developer machines. Admission and containment gate samples before the detonator/harness runs them; trace ingestion and normalization turn observed device/network behavior into contracts. The system can identify evasion checks and morph the emulator environment to trigger dormant behavior. Network capture is observational via the proxy addon.
• drishti/m3_dynamic/detonator.py
• drishti/m3_dynamic/harness.py
• drishti/m3_dynamic/normaliser.py
M4–M6: grounded interpretation, ML, and fusion
The GenAI controller uses retrieval, constrained agents, safety checks, and evidence-aware tools to interpret static and dynamic artefacts; its output must remain grounded. ML derives features and runs bundled classifier/anomaly/calibration models. The scoring engine fuses these signals into the 0–100 risk score and confidence, separating interpretation from final decision policy.
• drishti/m4_genai/controller.py
• drishti/m5_ml/infer.py
• drishti/m6_score/engine.py
Provenance and deliverables
A hash-chained, Ed25519-signed ledger records evidence/provenance independently of report presentation. Reporting projects the verified analysis into case files, HTML dossiers, STIX, and YARA outputs. API routes expose analysis state, artifacts, ledger verification, and logs to consumers.
• drishti/ledger/store.py
• drishti/ledger/verifier.py
• drishti/m7_report/dossier.py
Consumers, infrastructure, and external boundaries
The React/Vite analyst console polls API jobs, artefacts, logs, and graph/report views. The separate Android Shield client watches installed packages, obtains/uses verdicts, and applies device-side policy/notifications. Android canary/decoy applications provide controlled samples. GCP Terraform/Packer and operational scripts provision sealed GCE detonation VMs with no egress, external IP, or Google identity; LLM providers are accessed through the GenAI client, outside the trusted evidence boundary.
• ui/src/App.tsx
• shield/app/src/main/java/in/drishti/shield/ScanEngine.kt
• infra/gcp/terraform/runtime/main.tf
Main entry points: base.py Typed analysis contracts · main.py API and job control · pipeline.py Pipeline orchestrator · ingest.py M1 APK ingestion
Components 19
Control plane
- API and job control
drishti/api/main.py - Pipeline orchestrator
drishti/pipeline.py - Typed analysis contracts · Shared handoffs for evidence, traces, scores, and verdicts.
drishti/contracts/base.py
Analysis pipeline
- M1 APK ingestion
drishti/m1_ingest/ingest.py - M2 static analysis · Produces structured evidence and hypotheses.
drishti/m2_static/engine.py - Brand impersonation
drishti/m2_static/lookalike.py - M4 grounded interpretation · Uses constrained, evidence-aware tools and safety checks.
drishti/m4_genai/controller.py - M5 ML inference
drishti/m5_ml/infer.py - M6 scoring · Fuses signals into risk score and confidence.
drishti/m6_score/engine.py
Sealed detonation
Execution is isolated from developer machines.
- Admission and containment · Gates samples before active execution.
- Detonator and harness
drishti/m3_dynamic/detonator.py - Trace normalization · Normalizes observed device and network behavior.
drishti/m3_dynamic/normaliser.py - Sealed GCE detonation VMs · Provisioned with no egress, external IP, or Google identity.
infra/gcp/terraform/runtime/main.tf
Provenance and consumers
- Signed evidence ledger · Ed25519-signed evidence is independent of presentation.
drishti/ledger/store.py - Ledger verification
drishti/ledger/verifier.py - M7 reports and exports · Projects verified analysis into dossiers, STIX, and YARA.
drishti/m7_report/dossier.py - Analyst console
ui/src/App.tsx - Android Shield client · Watches packages and applies verdict-driven policy.
shield/app/src/main/java/in/drishti/shield/ScanEngine.kt
Other components
- LLM providers · Outside the trusted evidence boundary.
Connections 23
- API and job control → Pipeline orchestrator: starts jobs
- Analyst console → API and job control: polls jobs and artifacts
- Android Shield client → API and job control: obtains verdicts
- Pipeline orchestrator → M1 APK ingestion: APK input
- M1 APK ingestion → Typed analysis contracts: analysis record
- M1 APK ingestion → M2 static analysis: validated APK
- M2 static analysis → Brand impersonation: app identity evidence
- M2 static analysis → Typed analysis contracts: static findings
- Pipeline orchestrator → Admission and containment: candidate sample
- Admission and containment → Detonator and harness: approved sample
- Sealed GCE detonation VMs → Detonator and harness: isolated runtime
- Detonator and harness → Trace normalization: device and network traces
- Trace normalization → Typed analysis contracts: dynamic traces
- Typed analysis contracts → M4 grounded interpretation: evidence
- LLM providers → M4 grounded interpretation: model responses
- Typed analysis contracts → M5 ML inference: features
- M4 grounded interpretation → M6 scoring: grounded verdict
- M5 ML inference → M6 scoring: calibrated signals
- M6 scoring → Typed analysis contracts: final verdict
- Typed analysis contracts → Signed evidence ledger: evidence and provenance
- Signed evidence ledger → Ledger verification: hash chain
- Ledger verification → M7 reports and exports: verified analysis
- M7 reports and exports → API and job control: artifacts and state