Skip to main content
The MobSF script automates static analysis of Android APK files using Mobile Security Framework (MobSF). It handles authentication, file upload, analysis execution, and PDF report generation through the MobSF REST API.

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

Script Parameters

Analysis Workflow

1

Server Verification

Checks if MobSF server is running and accessible.
If server is not responding, script prompts user to start MobSF.
2

CSRF Token Retrieval

Obtains CSRF token from MobSF homepage for authenticated requests.
Extracts X-CSRFToken from response headers.
3

APK Upload

Uploads APK file to MobSF via multipart form POST request.
Response contains file checksum (MD5) for subsequent requests.
4

Static Analysis

Triggers static analysis by accessing the analyzer endpoint.
MobSF performs comprehensive security analysis.
5

PDF Report Generation

Downloads generated PDF report with analysis results.
6

Cleanup & Display

Removes temporary authentication files and opens PDF report.Script automatically launches the PDF viewer.

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

Example:

Usage Example

API Endpoints

The script uses these MobSF REST API endpoints:

Dependencies

The script requires these utilities in the same directory:
  • curl.exe: HTTP client for API requests
  • jq-win32.exe: JSON parser for extracting response data
  • pscp.exe: For remote file transfers (if needed)
  • plink.exe: For remote command execution (if needed)

Troubleshooting

Server Not Running

Solution: Start MobSF server on the specified host:

Connection Refused

Check firewall settings and ensure MobSF is listening on 0.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 -k flag 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:
Update script calls accordingly:

Remote Analysis

For remote servers, ensure:
  • Network connectivity to MobSF port
  • No firewall blocking HTTP traffic
  • Sufficient server resources for analysis
  • apktool_decode_local.bat: Decode APK for manual inspection
  • qark.bat: Alternative security analysis tool
  • androbugs_framework.bat: Another APK security scanner