-
Notifications
You must be signed in to change notification settings - Fork 1
Developer Guide
Deep-dive into the HydraDragonAV Mobile codebase for contributors. For the function-level API of every class and function, see Java-API-Reference and Rust-API-Reference.
HydraDragonAV-Mobile/
├── app/ # Android application module
│ └── src/main/
│ ├── java/com/hydradragon/antivirus/
│ │ ├── engine/ # 46 classes — ScanEngine, NativeScanner, HIPS, network, whitelist, self-protection
│ │ ├── service/ # GuardService, DnsVpnService, DynamicAnalysisService, ScreenCaptureService, receivers
│ │ ├── ui/ # DashboardFragment, ScanFragment, NetworkFragment, SettingsFragment, ThreatLogFragment, BlockActivity, MalwareFoundActivity
│ │ ├── views/ # HexagonStatusView, LiveNetworkChart
│ │ ├── adapter/ # NetworkEventAdapter, ScannedFileAdapter, ThreatAdapter
│ │ ├── model/ # ProcessInfo, ScannedFileInfo, ScanResult, ThreatResult
│ │ ├── security/ # SecureWindowGuard, StrandHoggGuard
│ │ ├── HydraDragonApp.java # Application — theme + native init
│ │ ├── MainActivity.java # launcher activity, permission bootstrap
│ │ └── BootReceiver.java # boot → GuardService
│ ├── jniLibs/{arm64-v8a,armeabi-v7a,x86,x86_64}/libhydradragonandroid.so
│ └── assets/scan/ # .yrc rules, model.mpk, .xf filters, whitelist DBs
├── hydradragonandroid/ # JNI bridge crate — scan pipeline (lib.rs 4196 lines)
│ └── src/{lib,asset_reader,benign_db,dex_scan,elf,emulate,ip_scan,url_scan}.rs
├── hydradragonclamav/ # Pure-Rust ClamAV engine (21 files)
│ └── src/{scanner,database,pattern,logical,bytecode_vm,atom*,fuzzy,icon*,pe,version_info,cert,phishing,yara_scan,...}.rs
├── hydradragonml/ # Burn (ndarray) binary APK classifier
│ └── src/{lib,main,model}.rs + features/mod.rs + bin/train.rs
├── hydradragonextractor/ # archive extraction (zip/tar/gz/xz/7z/rar/bz2/lzma)
│ └── src/{lib,rar}.rs
├── hydradragonxorfilter/ # Binary-Fuse16 .xf format (shared writer + reader)
│ └── src/lib.rs
├── dev-tools/
│ ├── hydradragon_yara_x_compile/ # offline .yar → .yrc compiler
│ ├── xorfilter_writer/ # offline .xf blob builder
│ └── yarGen/ # vendored Florian Roth yarGen (Python)
├── yara-x/ # YARA-X source rules (.yar) + helper scripts + yr.exe
├── database/ # filtered ClamAV signature databases
├── database_non_filtered/ # unfiltered ClamAV databases (source for clam_juice.py)
├── whitelist/ # NSRL whitelist data
├── allxfilters/ # URL/domain XOR filter sources
├── allips/ # malicious IP list sources
├── dataset/ # benign (F-Droid) + malware (MalwareBazaar) APKs
└── *.py # data-pipeline scripts (clam_juice, gen_*, build_url_xfilter, ...)
The yara-x engine is a git dependency (
github.com/HydraDragonAntivirus/yara-x), not a submodule. The localyara-x/directory at the repo root holds the project's rule files, not the engine source. Clone the engine fork separately if you need to modify the modules — see YARA-X-Modules.
The native engine (libhydradragonandroid.so) is built from five Rust crates and communicates with Java via JNI through com.hydradragon.antivirus.engine.NativeScanner. See Rust-API-Reference for the full function-level reference.
| Crate | Purpose | Key source |
|---|---|---|
hydradragonandroid |
JNI bridge + scan pipeline (extract → hydradragon metadata → YARA/ClamAV → ML → verdict) | lib.rs |
hydradragonclamav |
Pure-Rust ClamAV-compatible signature engine + YARA-X bridge |
scanner.rs, database.rs, pattern.rs, logical.rs, bytecode_vm.rs
|
hydradragonml |
Burn (ndarray) binary APK classifier (vocab.json-mapped subword tokenizer + 18 engine features) + scan CLI |
lib.rs, features/mod.rs, model.rs, main.rs, bin/train.rs
|
hydradragonextractor |
Recursive archive extraction (zip/gz/tar/xz/lzma/7z/rar) + zip-bomb detection |
lib.rs, rar.rs
|
hydradragonxorfilter |
Binary-Fuse16 .xf format shared by writer + on-device reader |
lib.rs |
cd hydradragonandroid
build-android.cmdOr with a specific ABI:
build-android.cmd -Abi arm64-v8aThis compiles libhydradragonandroid.so for all four Android ABIs (arm64-v8a, armeabi-v7a, x86_64, x86) using cargo-ndk and copies the outputs into app/src/main/jniLibs/. Prerequisites: Rust toolchain with the four Android targets, Android NDK (ANDROID_NDK_HOME), cargo-ndk (cargo install cargo-ndk).
NativeScanner exposes 25 native methods, all named Java_com_hydradragon_antivirus_engine_NativeScanner_<methodName> (note: com_hydradragon_antivirus, not com_hydradragon_av). They cover init/readiness, settings pushes (emulation/max-scan-size/zip-bomb/scan-relevant-only), whitelist queries, URL/IP/text/HIPS/packet scans, APK scan, batch scan lifecycle, rule hot-learning, and diagnostics. See Rust-API-Reference#jni-exposed-functions-25-total for the full table with Java signatures.
- Add the rule to
yara-x/*.yar(useimport "hydradragon"for module-gated rules). - Compile:
cargo run --release --manifest-path dev-tools/hydradragon_yara_x_compile/Cargo.toml -- yara-x/ app/src/main/assets/scan/(or--checkto validate only). - Rebuild the APK (
./gradlew assembleDebug) — the.yrcis picked up fromassets/scan/.
After making changes to the yara-x fork (e.g. adding a module export), commit + push the fork, then update the pin in all three dependent crates so the offline compiler and the on-device engine stay on the same rev (the serialized .yrc is backend-specific):
cd hydradragonandroid; cargo update -p yara-x # builds the .so
cd ../hydradragonclamav; cargo update -p yara-x
cd ../dev-tools/hydradragon_yara_x_compile; cargo update -p yara-xAll three must match. Then recompile the .yrc files (compiler) and rebuild the .so (the module metadata contract in hydradragonandroid/src/lib.rs must match the fork's schema).
The Android app is a standard Gradle project. The minimum SDK is 26 (Android 8.0 Oreo); per-app network attribution requires API 29 (Android 10) but the rest of the suite runs on Oreo+. See Java-API-Reference for the full class-level reference.
| Service | Type | Purpose |
|---|---|---|
GuardService |
Foreground Service (START_STICKY) | 24/7 monitoring, owns both ScanEngine instances, periodic scans, Downloads/full-storage observers, root-exploit transition detection |
DynamicAnalysisService |
Accessibility Service | On-screen text scanning, clickjacking/UI-spam/notification-spam detection, removal-resistance |
ScreenCaptureService |
Foreground Service (mediaProjection) |
Periodic screen OCR → NetworkObservations + NativeScanner.scanText
|
DnsVpnService |
VpnService | DNS filtering (Web Shield) + optional full-capture packet scanning |
BootReceiver (boot → GuardService), InstallReceiver (on-install scan), UninstallReceiver (cleanup), SmsReceiver (SMS scam/phishing), UserActionReceiver (alert actions), AdminReceiver (device-admin self-protection).
-
cargo clippy -- -D warningsmust pass; userustfmt. - JNI functions follow
Java_com_hydradragon_antivirus_engine_NativeScanner_<name>. - All
unsafeblocks have safety comments.
- Follow Android AOSP style.
- Services handle lifecycle properly (particularly
VpnServiceandAccessibilityService). - Settings UI uses
guardedToggleListenerrate-limiter +FLAG_WINDOW_IS_OBSCUREDtapjacking checks.
./gradlew testcd hydradragonandroid && cargo test
cd ../hydradragonclamav && cargo test- Build debug APK and install on a physical device or emulator (Android 10+ for full feature coverage).
- Verify all permission flows (All-Files-Access mandatory; accessibility/VPN/MediaProjection/SMS/overlay optional).
- Test scan with known EICAR/malware test files.
- Test accessibility, VPN, and screen-capture service toggles.
- Rust-API-Reference — every Rust crate, every function
- Java-API-Reference — every Java class, every method
-
YARA-X-Modules — the custom
hydradragonmodule + rules + build chain - Architecture — system design
- Contributing — contribution guidelines
- Installation-Setup — build environment setup