A comprehensive static malware analysis pipeline that performs 8 sequential analysis steps on executable files (.exe) with AI-powered reporting.
- 8 Sequential Analysis Steps: Packing detection, hashing, resource analysis, format analysis, imports/exports, string extraction, signature checking, and metadata extraction
- AI-Powered Reports: Google Gemini API generates detailed reports for each step
- CLI Tool Integration: Uses native Windows tools (Get-FileHash, certutil) and external tools (Resource Hacker, PEView, strings64)
- Comprehensive Logging: Detailed logging for debugging and audit trails
- Structured Output: JSON results and Markdown reports for each step
- Packing Detection & Unpacking: Detects if file is packed and attempts unpacking (UPX support)
- File Hash Calculation: Calculates MD5, SHA1, SHA256 using PowerShell Get-FileHash or certutil
- Resource Analysis: Analyzes PE file resources using Resource Hacker or pefile
- AI File Format Analysis: Uses Google Gemini API to detect actual vs apparent file format
- Import/Export Analysis: Analyzes DLL imports/exports using PEView or pefile
- String Extraction & AI Analysis: Extracts strings using strings64 and analyzes with AI for malicious patterns
- Digital Signature Checking: Checks file signature and reputation using VirusTotal API
- Metadata Extraction: Extracts comprehensive metadata from the executable
- Python 3.10+
- Windows (for native CLI tools)
- UPX: For unpacking UPX-packed files
- Resource Hacker: For detailed resource analysis (falls back to pefile)
- PEView: For import/export analysis (falls back to pefile)
- strings64: For string extraction (falls back to Python implementation)
- Google Gemini API Key: For AI analysis and report generation
- VirusTotal API Key: For signature checking in Step 7
- Clone the repository:
cd C:\Users\harin\OneDrive\Desktop\Docure- Create a virtual environment:
python -m venv venv
.\venv\Scripts\Activate.ps1- Install dependencies:
pip install -r requirements.txt- Create
.envfile in the project root:
GEMINI_API_KEY=your_gemini_api_key_here
VIRUSTOTAL_API_KEY=your_virustotal_api_key_herepy cli_analyze.py --file C:\malware\sample.exe --out outputspy cli_analyze.py --file C:\malware\sample.exe --out outputs --verbosepy cli_analyze.py --file C:\malware\sample.exe --out outputs --no-ai-reportsAfter running the analysis, you'll find:
outputs/
├── steps/
│ ├── step1_packing.json # Step 1 results
│ ├── step1_report.md # AI-generated report for Step 1
│ ├── step2_hash.json # Step 2 results
│ ├── step2_report.md # AI-generated report for Step 2
│ ├── ... # Results and reports for all 8 steps
│ └── step8_metadata.json
├── unpacked/ # Unpacked files (if any)
│ └── sample.unpacked.exe
├── logs/ # Analysis logs
│ └── analysis_YYYYMMDD_HHMMSS.log
└── complete_analysis.json # Complete analysis results
- Detects packing using entropy analysis, YARA rules, and PE analysis
- Attempts to unpack if UPX is detected and UPX tool is available
- Uses unpacked file for subsequent analysis if unpacking succeeds
- Uses PowerShell
Get-FileHash(preferred) - Falls back to
certutilif PowerShell fails - Falls back to Python
hashlibif both fail - Calculates MD5, SHA1, and SHA256
- Uses Resource Hacker CLI if available
- Falls back to
pefilefor basic resource extraction - Extracts all PE resources (icons, strings, version info, etc.)
- Uses Google Gemini API to analyze file header
- Compares actual format vs apparent format
- Detects format mismatches (e.g., .pdf that's actually .zip)
- Uses PEView if available (GUI tool, falls back to pefile)
- Extracts all DLL imports and exports
- Identifies suspicious imports (VirtualAlloc, CreateRemoteThread, etc.)
- Extracts strings using strings64 tool
- Falls back to Python implementation if tool not available
- Analyzes strings with Google Gemini API for malicious patterns
- Identifies IOCs (URLs, IPs, domains)
- Queries VirusTotal API using file hash
- Checks digital signature information
- Retrieves reputation scores (malicious, suspicious, harmless)
- Extracts comprehensive file metadata
- PE headers, sections, timestamps
- File system metadata (size, dates, etc.)
Comprehensive logging is enabled by default:
- File logging:
outputs/logs/analysis_YYYYMMDD_HHMMSS.log - Console output: Real-time progress and results
- Verbose mode:
--verboseflag for detailed debug information
-
Google Gemini API Key:
- Get your API key from https://aistudio.google.com/app/apikey
- Add to
.env:GEMINI_API_KEY=your_key_here
-
VirusTotal API Key:
- Sign up at https://www.virustotal.com/
- Get your API key from your account settings
- Add to
.env:VIRUSTOTAL_API_KEY=your_key_here
- Ensure
.envfile exists in project root - Check that API key is correctly set:
GEMINI_API_KEY=your_key_here
- Required for Step 7 (signature checking)
- Add to
.envfile
- Step 1 will still detect packing but won't unpack
- Download UPX from https://upx.github.io/
- Place
upx.exein project directory or add to PATH
- Step 3 will use pefile fallback (basic resource extraction)
- Download Resource Hacker from http://www.angusj.com/resourcehacker/
- Place in project directory or specify path
- Step 6 will use Python fallback (slower but functional)
- Download strings64 from Sysinternals or place in project directory
- Never analyze malware on production systems
- Use isolated VMs or dedicated analysis environments
- Files are never executed, only statically analyzed
- Sandbox isolation is recommended for actual malware samples
[Your License Here]
[Contributing Guidelines Here]