Overview
Script:mobsf.bat
Platform: Windows
Purpose: Automated APK static analysis with PDF report generation
Tool Information
MobSF: Mobile Security Framework- Repository:
https://github.com/ajinabraham/Mobile-Security-Framework-MobSF - Type: Open-source mobile application security testing framework
- Analysis: Static and dynamic analysis for Android and iOS apps
Installation
From install scripts (Linux):Starting MobSF Server
- Windows
- Linux
Script Parameters
| Parameter | Description | Example |
|---|---|---|
PathAPK | Full path to APK file | C:\samples\app.apk |
FileApk | APK filename (no extension) | app |
Timestamp | Unique timestamp identifier | 20230615_143022 |
Documentacion | Output directory for PDF report | C:\reports |
Server | MobSF server URL | http://192.168.1.100:8000 |
Analysis Workflow
Server Verification
Checks if MobSF server is running and accessible.If server is not responding, script prompts user to start MobSF.
CSRF Token Retrieval
Obtains CSRF token from MobSF homepage for authenticated requests.Extracts
X-CSRFToken from response headers.APK Upload
Uploads APK file to MobSF via multipart form POST request.Response contains file checksum (MD5) for subsequent requests.
Static Analysis
Triggers static analysis by accessing the analyzer endpoint.MobSF performs comprehensive security analysis.
Script Implementation
Output
PDF Report Contents
The generated PDF report includes:- Application Information: Package name, version, permissions
- Security Analysis: Code vulnerabilities, insecure configurations
- Certificate Analysis: Signing certificate details
- Manifest Analysis: AndroidManifest.xml security issues
- Code Analysis: Hardcoded secrets, insecure APIs, cryptography issues
- Binary Analysis: Native library vulnerabilities
- File Analysis: Resource files, assets, and databases
Report Location
Usage Example
API Endpoints
The script uses these MobSF REST API endpoints:| Endpoint | Method | Purpose |
|---|---|---|
/ | GET | Retrieve CSRF token and session cookie |
/upload/ | POST | Upload APK for analysis |
/StaticAnalyzer/ | GET | Trigger static analysis |
/PDF/ | GET | Generate and download PDF report |
Dependencies
The script requires these utilities in the same directory:curl.exe: HTTP client for API requestsjq-win32.exe: JSON parser for extracting response datapscp.exe: For remote file transfers (if needed)plink.exe: For remote command execution (if needed)
Troubleshooting
Server Not Running
Connection Refused
Check firewall settings and ensure MobSF is listening on0.0.0.0:8000 (not 127.0.0.1:8000).
Analysis Taking Too Long
Large APK files or complex applications may take several minutes to analyze. The script waits for analysis completion before generating the PDF.Missing CSRF Token
If CSRF token extraction fails, verify that:- MobSF server is responding
- curl.exe can access the server
- No proxy is interfering with requests
Security Considerations
- Credentials: Script stores cookies in TEMP directory temporarily
- HTTPS: Uses
-kflag to allow self-signed certificates - Cleanup: Automatically removes temporary authentication files
- Network: Ensure MobSF server is on trusted network or use VPN
Advanced Configuration
Custom Server Port
MobSF can run on custom ports:Remote Analysis
For remote servers, ensure:- Network connectivity to MobSF port
- No firewall blocking HTTP traffic
- Sufficient server resources for analysis
Related Scripts
apktool_decode_local.bat: Decode APK for manual inspectionqark.bat: Alternative security analysis toolandrobugs_framework.bat: Another APK security scanner