LibPass is a black-box adversarial attack framework designed to evade third-party library (TPL) detection tools. It uses entropy-guided perturbation strategies to generate adversarial APKs that can bypass state-of-the-art TPL detection tools while maintaining functionality.
This repository contains the implementation of the following paper:
"LibPass: An Entropy-Guided Black-Box Adversarial Attack against Third-Party Library Detection Tools in the Wild"
- Published in: IEEE Transactions on Dependable and Secure Computing (TDSC)
- Paper Link: https://www.computer.org/csdl/journal/tq/5555/01/11275815/2c9ntOyAxRC
- Status: Accepted (TDSC-2025-04-0554.R2)
If you use LibPass in your research, please cite our paper:
@article{libpass2025,
title={LibPass: An Entropy-Guided Black-Box Adversarial Attack against Third-Party Library Detection Tools in the Wild},
author={Zhou, Jian and others},
journal={IEEE Transactions on Dependable and Secure Computing},
year={2025},
publisher={IEEE Computer Society}
}- π― Black-Box Attack: Works without knowledge of the detection tool's internal mechanisms
- π Entropy-Guided Search: Uses graph entropy (dependency entropy and structural entropy) to guide perturbation search
- π Firefly Algorithm: Enhanced Firefly algorithm with KDTree spatial indexing for efficient perturbation search
- π‘οΈ Function-Preserving Perturbations: Adds and merges nodes while maintaining APK functionality
- π Multi-Detector Support: Supports multiple TPL detection tools:
- LibScan: Signature-based detection
- LibLoom: Bloom filter-based detection
- LibPecker: Profile-based detection
- LibHunter: Graph-based detection
- LiteRadar: Lightweight detection
- β‘ Parallel Execution: Multi-threaded batch processing for efficient large-scale attacks
- π Attack Modes:
black_box: Uses detector confidence scoresblack_box_plus: Uses graph entropy for guidance
- ποΈ Attack Levels:
library_level: Evade entire library detectionversion_level: Evade specific version detection
- π Comprehensive Logging: Configurable log levels with detailed attack statistics
- TPL Decoupler: Identifies and isolates third-party library classes from app code
- Heterogeneous Graph Builder: Constructs multi-typed graphs capturing semantic and structural information
- Entropy Calculator: Computes dependency entropy and structural entropy to quantify graph complexity
- Perturbation Applier: Applies function-preserving perturbations (add/merge operations)
- Firefly Algorithm: Searches for optimal perturbation sequences using entropy as fitness function
- APK Repackager: Converts modified Jimple code back to DEX and repackages APK
APK Input β TPL Decoupling β Graph Construction β Entropy Calculation
β Firefly Search β Perturbation Application β APK Repackaging
β Detection Verification β Adversarial APK Output
- Java: 11 or higher
- Python: 3.7 or higher
- Gradle: 6.0+ (or use included Gradle Wrapper)
- Android SDK: For
android.jarfiles (API level 20+) - Soot Framework: 4.5.0
git clone https://github.com/yourusername/LibPass.git
cd LibPass/src# Install Python dependencies
pip install -r requirements.txt
# Build Java project
./gradlew buildDownload Android SDK and set the path to android.jar:
# Example: Android API 30
export ANDROID_JAR=/path/to/android-sdk/platforms/android-30/android.jarjava -cp build/libs/src-1.0.0.jar \
com.libpass.attack.AutomatedAttackMain \
apk \
/path/to/app.apk \
/path/to/library.jar \
library-name \
/path/to/android.jar \
./output \
LibScan \
100 \
INFO \
1 \
black_box \
library_leveljava -cp build/libs/src-1.0.0.jar \
com.libpass.attack.AutomatedAttackMain \
groundtruth \
/path/to/groundtruth.txt \
/path/to/apks/ \
/path/to/libraries/ \
/path/to/android.jar \
./output \
LibScan \
100 \
INFO \
4 \
black_box \
library_leveljava -cp build/libs/src-1.0.0.jar \
com.libpass.attack.AutomatedAttackMain \
<mode> <apk_path> <tpl_path> <tpl_name> <android_jar> <output_dir> \
[detector_type] [max_iterations] [log_level] [parallel_workers] \
[attack_mode] [attack_level]Parameters:
mode:apkfor single/batch APK attackapk_path: Path to APK file or directorytpl_path: Path to TPL JAR/DEX filetpl_name: Name of the target libraryandroid_jar: Path to Android JAR fileoutput_dir: Output directory for adversarial APKsdetector_type:LibScan,LibLoom,LibPecker,LibHunter, orLiteRadar(default:LibScan)max_iterations: Maximum attack iterations (default: 100)log_level:ERROR,WARNING,INFO, orDEBUG(default:INFO)parallel_workers: Number of parallel workers (default: 1)attack_mode:black_boxorblack_box_plus(default:black_box)attack_level:library_levelorversion_level(default:library_level)
java -cp build/libs/src-1.0.0.jar \
com.libpass.attack.AutomatedAttackMain \
groundtruth \
<groundtruth_file> <apk_base_dir> <tpl_base_dir> <android_jar> <output_dir> \
[detector_type] [max_iterations] [log_level] [parallel_workers] \
[attack_mode] [attack_level]GroundTruth File Format:
apk1.apk:library1,library2
apk2.apk:library3
...
- Uses detector confidence scores to guide attacks
- Stops when confidence drops below threshold
- Faster execution
- Uses graph entropy for perturbation guidance
- More sophisticated search strategy
- Higher success rate
- Goal: Make the entire library undetectable
- Success: Library not detected by the detector
- Goal: Change detected version or make library undetectable
- Success: Library not detected OR wrong version detected
src/
βββ java/ # Java source code
β βββ com/libpass/attack/
β βββ attack/ # Core attack engine and configuration
β β βββ LibPassAttackEngine.java
β β βββ AttackMode.java
β β βββ AttackLevel.java
β β βββ AttackResult.java
β βββ automation/ # Automated attack orchestration and batch processing
β β βββ AutomatedAttackEngine.java
β β βββ AutomatedAttackMain.java
β β βββ AutomatedAttackResult.java
β β βββ BatchAttackResult.java
β β βββ GroundTruthBatchAttackResult.java
β β βββ AttackStatistics.java
β βββ detector/ # TPL detector adapters and interfaces
β β βββ TPLDetector.java
β β βββ DetectionResult.java
β β βββ LibScanDetector.java
β β βββ LibLoomDetector.java
β β βββ LibPeckerDetector.java
β β βββ LibHunterDetector.java
β β βββ LiteRadarDetector.java
β βββ perturbation/ # Perturbation operations and application
β β βββ AddingPerturbation.java
β β βββ MergingPerturbation.java
β β βββ PerturbationApplier.java
β β βββ ModificationLogger.java
β β βββ CallSiteUpdater.java
β βββ apk/ # APK processing utilities
β β βββ APKRepackager.java
β β βββ APKSigner.java
β βββ graph/ # Graph structures for dependency analysis
β β βββ HeterogeneousGraph.java
β β βββ GraphNode.java
β β βββ GraphBuilder.java
β βββ firefly/ # Firefly algorithm for optimization
β β βββ FireflyAlgorithm.java
β β βββ Firefly.java
β β βββ KDTree.java
β βββ entropy/ # Entropy calculation for code metrics
β β βββ GraphEntropyCalculator.java
β βββ decoupling/ # TPL decoupling utilities
β β βββ TPLDecoupler.java
β βββ util/ # Utility classes
β β βββ Logger.java
β βββ AttackStrategy.java # Attack strategy interface
β βββ AttackConfig.java # Attack configuration
β βββ AttackResult.java # Attack result (legacy)
β βββ APKModifier.java # APK modification utilities
β βββ AutomatedAttackMain.java # Main entry point for automated attacks (command line)
βββ TPL_Detectors/ # Third-party detection tools
β βββ LibScan/ # LibScan tool
β βββ LIBLOOM/ # LibLoom tool
β βββ LibPecker/ # LibPecker tool
β βββ LibHunter/ # LibHunter tool
β βββ LiteRadar/ # LiteRadar tool
βββ python/ # Python scripts
β βββ automated_attack.py
β βββ evaluator.py
βββ build.gradle # Build configuration
βββ requirements.txt # Python dependencies
βββ validate_apk.sh # End-to-end APK functionality validation
βββ sign_apk.sh # APK signing tool
βββ LICENSE
βββ README.md
The attack generates:
- Adversarial APKs: Modified APKs that evade detection
- Attack Statistics: Success rate, perturbation count, execution time
- Detailed Logs: Per-iteration attack progress and results
Example output:
Task #1: SUCCESS - final_confidence=0.000000, perturbations=5, time=12000 ms, types=[add_class, merge_method]
Task #2: FAILED - final_confidence=0.850000, perturbations=100, time=45000 ms
This tool is intended for academic research and security testing purposes only.
- Use only with proper authorization
- Comply with applicable laws and regulations
- Follow ethical guidelines for security research