Skip to content

Latest commit

Β 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ ReverseAI - Malware Analysis Tool

A complete AI-powered reverse engineering and malware analysis platform for Android APKs. It supports both static and native code analysis using Ghidra, Radare2, CodeBERT, and custom ML models.


πŸ“ Project Structure

ReverseAI-MalwareTool/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app.py                     # Main Flask server
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── malware_classifier.py  # ML model for predicting malware
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ asm_inspector.py       # Uses Radare2 for assembly inspection
β”‚   β”‚   β”œβ”€β”€ deobfuscator.py        # Detects obfuscated code
β”‚   β”‚   β”œβ”€β”€ extract_methods.py     # Extracts Java methods
β”‚   β”‚   β”œβ”€β”€ feature_extractor.py   # Permissions, API calls, unpacking, JADX
β”‚   β”‚   β”œβ”€β”€ ghidra_runner.py       # Runs Ghidra Headless analysis
β”‚   β”‚   β”œβ”€β”€ threat_classifier.py   # Final verdict: malicious or not
β”‚   β”‚   └── unzipper.py            # APK structure analyzer
β”‚   β”œβ”€β”€ ghidra_scripts/
β”‚   β”‚   └── ghidra_extract.py      # Script executed by Ghidra
β”‚   └── data/
β”‚       └── (APK input/output folders)
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   └── ThreatReport.jsx   # Component to render analysis results
β”‚   β”‚   β”œβ”€β”€ App.jsx                # File upload + scan trigger
β”‚   β”‚   └── index.js               # React DOM rendering
β”œβ”€β”€ README.md                      # You are here
└── requirements.txt               # Python dependencies

βš™οΈ Installation & Setup Guide

βœ… Prerequisites

You need the following installed on your system:

Tool Version Recommended
Python 3.10+
Node.js + npm 16.x or 18.x
Apktool 2.9+
JADX 1.4+ (CLI)
Ghidra 11+ (headless support)
Radare2 5.9+
Java JDK 17 or 21

πŸ”§ Backend Setup

  1. Clone the repo:

    git clone https://github.com/your-org/ReverseAI-MalwareTool.git
    cd ReverseAI-MalwareTool/backend
  2. Create a virtual environment:

    python -m venv venv
    venv\Scripts\activate     # on Windows
  3. Install dependencies:

    pip install -r requirements.txt
  4. Ensure tools are on PATH:

    • Add these to your environment variables:
      C:\Windows\Apktool\
      C:\jadx\bin\
      C:\Tools\radare2\radare2-5.9.8-w64\bin
      
  5. Run backend server:

    python app.py

🌐 Frontend Setup

  1. Open a new terminal:

    cd ../frontend
    npm install
    npm start
  2. React dev server runs at http://localhost:3000


πŸš€ How It Works

➀ Step-by-Step Flow

  1. Upload APK from frontend.
  2. Flask receives the file β†’ saves it.
  3. Extracts contents using:
    • apktool (manifest + smali)
    • jadx (Java source)
  4. Runs:
    • Permissions & API extraction
    • Obfuscation check
    • Native .so scanning via:
      • 🧬 Ghidra (headless)
      • πŸ”¬ Radare2 (assembly inspection)
  5. Java methods classified using CodeBERT.
  6. Final prediction using a trained RandomForestClassifier.
  7. Result JSON sent back to frontend.
  8. Frontend renders a beautiful report.

🧠 Technologies Used

Feature Tool
APK unpacking Apktool
Java decompilation JADX
Native code reverse Ghidra
Assembly inspection Radare2
Code classification CodeBERT
Threat classification RandomForest
Frontend UI React
Backend API Flask

πŸ“‚ Important Files (Backend)

File Role
app.py Main backend logic
utils/feature_extractor.py Extracts APIs, permissions, decompiles code
utils/asm_inspector.py Runs Radare2 on .so files
utils/ghidra_runner.py Automates Ghidra headless execution
utils/codebert_classifier.py Uses HuggingFace model to classify methods
utils/threat_classifier.py Combines all signals to determine threat
ghidra_scripts/ghidra_extract.py Custom Ghidra Python logic
models/malware_classifier.py Our trained scikit-learn model

βœ… Final Tips for Teammates

  • Make sure tools run in command line (like apktool d test.apk)
  • Use a real APK to test β€” fake/test ones may not have .so files.
  • If something fails, check:
    • Output in terminal
    • data/ folder
    • print() logs in app.py

REPEAT-------------------------------------------------MORE INFO

πŸ›‘οΈ ReverseAI - Android Malware Analysis Tool

ReverseAI is a powerful automated reverse engineering and malware analysis platform for Android apps (APKs). Designed for hackathons and real-world use, it uses AI + static analysis + reverse engineering to detect and classify malicious behavior β€” even in obfuscated apps with native libraries.


πŸš€ Features

  • βœ… Upload and analyze any .apk via a simple web interface
  • πŸ“¦ Reverse engineering using apktool, jadx, Ghidra, and Radare2
  • πŸ” Detect:
    • Dangerous permissions
    • Suspicious API calls
    • Native .so libraries
    • Obfuscation and asset packing
  • πŸ€– AI threat classification using:
    • RandomForestClassifier on feature vectors
    • CodeBERT on decompiled Java methods
  • πŸ“Š Generate full threat reports in one click

πŸ“‚ Project Structure (What each file does)

ReverseAI-MalwareTool/
β”œβ”€β”€ app.py                        # 🧠 Main Flask backend (API logic & pipeline)
β”œβ”€β”€ train_model.py               # πŸ”¬ (Optional) Used to train the RandomForest model from dataset.csv
β”œβ”€β”€ build_dataset.py            # πŸ”§ Script to build dataset from benign/malware samples
β”œβ”€β”€ test_*.py                   # βœ… Test scripts for extractors & features

β”œβ”€β”€ data/                       # πŸ“ Data I/O
β”‚   β”œβ”€β”€ apks/                   # Uploaded + test APKs
β”‚   β”œβ”€β”€ extracted/              # Decompiled Java + unpacked smali/native structure
β”‚   β”œβ”€β”€ ghidra_output.json      # Ghidra headless output
β”‚   β”œβ”€β”€ dataset.csv             # Feature vector dataset (for training)
β”‚   └── malware/, benign/       # Sample APKs

β”œβ”€β”€ models/                     # πŸ€– AI Models
β”‚   β”œβ”€β”€ codebert_analyzer.py    # Uses HuggingFace CodeBERT to classify method-level code
β”‚   β”œβ”€β”€ malware_classifier.py   # Loads and uses RandomForest model
β”‚   └── malware_model.pkl       # Pre-trained RandomForest binary

β”œβ”€β”€ utils/                      # πŸ”§ Reusable modules
β”‚   β”œβ”€β”€ feature_extractor.py    # Runs apktool, jadx, permission/api/obfuscation scan
β”‚   β”œβ”€β”€ ghidra_runner.py        # Automates Ghidra headless
β”‚   β”œβ”€β”€ asm_inspector.py        # Uses Radare2 to disassemble native code
β”‚   β”œβ”€β”€ codebert_classifier.py  # CodeBERT inference code
β”‚   β”œβ”€β”€ unzipper.py             # Analyzes file structure/assets for malware signs
β”‚   β”œβ”€β”€ extract_methods.py      # Extracts Java method bodies from Decompiled output
β”‚   β”œβ”€β”€ deobfuscator.py         # Detects smali junk + naming obfuscation
β”‚   └── threat_classifier.py    # Combines all into final rule-based threat summary

β”œβ”€β”€ ghidra_scripts/
β”‚   └── ghidra_extract.py       # Ghidra Python script run during native analysis

β”œβ”€β”€ frontend/                   # 🎨 React Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.jsx             # Main upload UI + result rendering
β”‚   β”‚   └── components/ThreatReport.jsx # Result visualization component
β”‚   └── package.json            # React dependencies

β”œβ”€β”€ reports/                    # Optional: store report exports
└── ghidra_project/             # Ghidra project files (auto-created)

πŸ› οΈ Setup Instructions

πŸ”§ Requirements

πŸ“¦ Python Setup (Backend)

cd backend/
python -m venv venv
venv\Scripts\activate   # On Windows
pip install -r requirements.txt

Ensure apktool, jadx, and r2 are added to your PATH and working from CMD.

πŸ“¦ React Setup (Frontend)

cd frontend/
npm install
npm start
  • This runs at http://localhost:3000
  • Backend is served at http://localhost:5000

πŸ§ͺ How It Works (Pipeline Explained)

When you upload an .apk, the following happens:

  1. Unpack + Decompile
    • apktool: Extracts AndroidManifest + smali
    • jadx: Decompiled Java methods
  2. Feature Extraction
    • extract_permissions: Parses manifest
    • list_api_calls: Scans Java code
    • deobfuscate_code: Detects naming junk
  3. AI Prediction
    • RandomForestClassifier: Predicts malicious/benign based on permission/API count
  4. Ghidra + Radare2
    • Native .so libs analyzed for symbols
  5. CodeBERT
    • Classifies Java method behavior (malicious, suspicious, benign)
  6. Threat Report
    • All combined in a JSON response + frontend UI

πŸ“€ Usage

  • Launch both backend and frontend
  • Upload an APK in the frontend
  • Wait 5–15 seconds depending on file size
  • See structured report in browser

🧠 Contribution Tips (for teammates)

  • Frontend logic lives in frontend/src/components/ThreatReport.jsx
  • Backend starts from app.py
  • Want to add new checks? Add them inside utils/ and call from app.py
  • To train new models, use train_model.py and build_dataset.py

πŸ‘¨β€πŸ’» Authors & Contributors


πŸ† Why This Project Is Special

  • Combines reverse engineering + AI + UI
  • One-click, transparent reports
  • Hackathon-ready, scalable, and real-world applicable
  • Judges will love the technical depth, automation, and explainability

πŸ“Έ Sample Report

Report Screenshot

This README was auto-generated by your AI partner to guide your teammates easily.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages