
Conducting Mobile App Penetration Test
- 216 installs
- 27.3k repo stars
- Updated August 2, 2026
- mukul975/anthropic-cybersecurity-skills
Execute mobile app penetration tests covering local storage, transport security, reverse engineering risks, and platform-specific weaknesses before store release.
About
Cybersecurity skill for conducting mobile app penetration tests: platform-aware testing of storage, networking, reverse engineering, and backend coupling to find exploitable issues before mobile apps ship.
- iOS and Android pentest flows
- Local data and keychain risks
- API and cert pinning checks
- Pre-release exploit simulation
Conducting Mobile App Penetration Test by the numbers
- 216 all-time installs (skills.sh)
- +11 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #739 of 2,203 Security skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill conducting-mobile-app-penetration-testAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 216 |
|---|---|
| repo stars | ★ 27.3k |
| Last updated | August 2, 2026 |
| Repository | mukul975/anthropic-cybersecurity-skills ↗ |
What it does
Execute mobile app penetration tests covering local storage, transport security, reverse engineering risks, and platform-specific weaknesses before store release.
Files
Conducting Mobile App Penetration Test
When to Use
- Testing mobile applications before release to identify security vulnerabilities and data protection issues
- Conducting compliance assessments against OWASP MASVS (Mobile Application Security Verification Standard) levels L1 and L2
- Evaluating the security of mobile banking, healthcare, or government applications handling sensitive data
- Testing mobile apps that interact with backend APIs to assess the end-to-end security of the mobile ecosystem
- Assessing mobile application resistance to reverse engineering, tampering, and runtime manipulation
Do not use against mobile applications without written authorization from the application owner, for distributing modified or repackaged applications, or for testing apps on the public app stores without a separate test build.
Prerequisites
- Target application IPA (iOS) and APK (Android) files or access to download from a private distribution channel
- Rooted Android device or emulator (Genymotion, Android Studio AVD) with Frida, Objection, and Magisk installed
- Jailbroken iOS device or Corellium virtual device with Frida, Objection, and SSL Kill Switch installed
- Static analysis tools: jadx (Android decompilation), Hopper/Ghidra (iOS binary analysis), MobSF (automated scanning)
- Burp Suite Professional configured as proxy for intercepting mobile app traffic with CA certificate installed on the test device
Legal Notice: This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.
Workflow
Step 1: Static Analysis
Analyze the application binary without executing it:
Android Static Analysis:
- Decompile the APK:
jadx -d output/ target.apkto obtain Java/Kotlin source code - Review
AndroidManifest.xmlfor exported components (activities, services, receivers, content providers), permissions, and debuggable flag - Search for hardcoded secrets:
grep -rn "api_key\|password\|secret\|token\|aws_" output/ - Identify insecure data storage patterns: SharedPreferences with sensitive data, SQLite databases without encryption, files in external storage
- Check for WebView vulnerabilities:
setJavaScriptEnabled(true),addJavascriptInterface(), and loading untrusted content - Run MobSF automated scan:
python manage.py runserverand upload the APK for automated static analysis
iOS Static Analysis:
- Extract the IPA and locate the Mach-O binary
- Use
otool -L <binary>to list linked frameworks and identify third-party libraries - Analyze with Ghidra or Hopper for hardcoded URLs, API endpoints, and embedded credentials
- Check Info.plist for App Transport Security (ATS) exceptions that allow insecure HTTP connections
- Review embedded entitlements for excessive capabilities
Step 2: Network Security Testing
Intercept and analyze all network communications:
- Configure Burp Suite as proxy on the test device and install the Burp CA certificate
- Exercise all application functionality while Burp captures API traffic
- SSL/TLS validation: Verify the app validates server certificates properly. If the app fails to connect through the proxy, it may implement certificate pinning.
- Certificate pinning bypass:
- Android: Use Frida script:
frida -U -f com.target.app -l ssl-pinning-bypass.js --no-pause - iOS: Use SSL Kill Switch or Objection:
objection -g "Target App" explore --startup-command "ios sslpinning disable" - API traffic analysis: Review all API calls for:
- Sensitive data transmitted without encryption
- Authentication tokens in URL parameters (visible in logs)
- Excessive data in API responses beyond what the UI displays
- Missing or weak authentication on API endpoints
- WebSocket and custom protocols: Check for non-HTTP communication channels that may bypass standard proxy interception
Step 3: Data Storage Analysis
Test for insecure local data storage:
Android Data Storage:
- Access app data directory:
/data/data/com.target.app/ - Check SharedPreferences XML files for stored credentials, tokens, and PII
- Examine SQLite databases:
sqlite3 /data/data/com.target.app/databases/*.db ".dump" - Check for sensitive data in application logs:
logcat -d | grep -i "password\|token\|key" - Verify that application data is excluded from backups:
android:allowBackup="false"in AndroidManifest.xml - Check clipboard for sensitive data leakage
iOS Data Storage:
- Examine the Keychain for stored credentials:
objection -g "Target App" explorethenios keychain dump - Check NSUserDefaults/plist files:
find /var/mobile/Containers/Data/Application/ -name "*.plist" -exec plutil -p {} \; - Inspect SQLite databases and Core Data stores for unencrypted sensitive data
- Check for data leaking through screenshots (iOS captures screenshots during app backgrounding)
- Verify data protection class: sensitive files should use NSFileProtectionComplete
Step 4: Authentication and Session Management
Test mobile-specific authentication controls:
- Biometric bypass: Test if biometric authentication can be bypassed by hooking the authentication callback with Frida to always return success
- Token storage: Verify that authentication tokens are stored in the Keychain (iOS) or Android Keystore, not in SharedPreferences or files
- Session timeout: Verify that sessions expire after a reasonable idle timeout and that tokens are invalidated server-side on logout
- Root/jailbreak detection bypass: Test if the app detects rooted/jailbroken devices and if the detection can be bypassed with Frida or Magisk Hide
- Deep link abuse: Test if custom URL schemes or universal links can be used to bypass authentication or access restricted functionality
Step 5: Runtime Manipulation
Test the application's resistance to runtime attacks:
- Frida hooking: Use Frida to hook and modify application functions at runtime:
- Bypass root detection: hook the detection function to return false
- Modify return values of authentication checks
- Intercept encryption functions to capture plaintext data before encryption
- Bypass certificate pinning by hooking SSL verification
- Method swizzling (iOS): Use Frida to replace Objective-C method implementations
- Intent manipulation (Android): Send crafted intents to exported components:
adb shell am start -n com.target.app/.InternalActivity -e "user_id" "admin" - Tampering detection: Modify the APK/IPA (add code, change resources), re-sign, and install. Verify whether the app detects tampering.
Key Concepts
| Term | Definition |
|---|---|
| OWASP MASTG | Mobile Application Security Testing Guide; comprehensive manual for mobile app security testing covering both iOS and Android platforms |
| Certificate Pinning | A mobile security control that restricts which TLS certificates the app trusts, preventing man-in-the-middle attacks through proxy interception |
| Frida | Dynamic instrumentation toolkit that allows injection of JavaScript into running processes to hook functions, modify behavior, and bypass security controls |
| Root/Jailbreak Detection | Application-level checks to detect if the device has been modified to grant root access, typically blocking app usage on compromised devices |
| Android Keystore | Hardware-backed credential storage on Android that protects cryptographic keys and secrets from extraction even on rooted devices |
| App Transport Security (ATS) | iOS security feature that enforces HTTPS connections by default; ATS exceptions may indicate insecure network communication |
| Deep Links | URL schemes that open specific screens within a mobile application, which may bypass normal navigation and authentication flows if not properly validated |
Tools & Systems
- Frida / Objection: Dynamic instrumentation tools for hooking functions, bypassing security controls, and manipulating application behavior at runtime
- MobSF (Mobile Security Framework): Automated static and dynamic analysis platform for Android and iOS applications
- jadx: Android decompiler that converts APK bytecode to readable Java source code for manual code review
- Burp Suite Professional: HTTP proxy for intercepting and modifying mobile app API traffic after bypassing certificate pinning
Common Scenarios
Scenario: Mobile Banking Application Security Assessment
Context: A bank is launching a new mobile banking app for iOS and Android. The app handles account viewing, fund transfers, bill payment, and check deposit. OWASP MASVS L2 compliance is required due to the financial data handled.
Approach: 1. Static analysis of the Android APK reveals API endpoints, a hardcoded staging server URL, and an AWS API key in a configuration file 2. Certificate pinning is implemented but bypassed with Frida SSL pinning bypass script 3. API traffic analysis reveals that the balance check endpoint returns all account numbers associated with the user, not just the requested account 4. Local data storage analysis finds that the app caches the last 10 transactions in an unencrypted SQLite database 5. Biometric authentication bypass: Frida hook on the biometric callback always returns success, granting access without fingerprint 6. Root detection is present but bypassed with Magisk Hide module, allowing the app to run on a rooted device with full data access
Pitfalls:
- Testing only on an emulator and missing hardware-specific security features (Android Keystore hardware backing, iOS Secure Enclave)
- Not testing both iOS and Android versions, as they may have different implementations and different vulnerabilities
- Ignoring the backend API security because it was "tested separately" when the mobile app may call API endpoints differently than the web app
- Failing to test certificate pinning bypass, resulting in an incomplete network analysis
Output Format
## Finding: Biometric Authentication Bypass via Frida Instrumentation
**ID**: MOB-003
**Severity**: High (CVSS 7.7)
**Platform**: Android and iOS
**OWASP MASVS**: MASVS-AUTH-2 (Biometric Authentication)
**Description**:
The mobile banking app's biometric authentication can be bypassed using Frida
dynamic instrumentation. The authentication callback function accepts a boolean
result from the biometric API, which can be hooked and forced to return true
without presenting a valid fingerprint or face scan.
**Proof of Concept (Android)**:
frida -U -f com.bank.mobileapp -l bypass-biometric.js --no-pause
// bypass-biometric.js
Java.perform(function() {
var BiometricCallback = Java.use("com.bank.mobileapp.auth.BiometricCallback");
BiometricCallback.onAuthenticationSucceeded.implementation = function(result) {
console.log("[*] Biometric bypassed");
this.onAuthenticationSucceeded(result);
};
});
**Impact**:
An attacker with physical access to an unlocked device can bypass biometric
authentication and access the victim's bank accounts, initiate transfers,
and view financial data without biometric verification.
**Remediation**:
1. Implement server-side biometric verification using Android BiometricPrompt
CryptoObject tied to a Keystore key
2. Require the biometric operation to decrypt a server-side challenge, making
client-side bypass ineffective
3. Add runtime integrity checks to detect Frida and other instrumentation frameworks
4. Implement step-up authentication for high-risk operations (transfers > threshold)
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to the Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by the Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding any notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. Please do not remove or change
the license header comment from a contributed file except when
necessary.
Copyright 2026 mukul975
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
API Reference: Mobile App Penetration Testing Agent
Overview
Tests Android mobile applications for OWASP MASTG vulnerabilities: insecure storage, hardcoded secrets, manifest misconfigurations, certificate pinning bypass, and API authorization flaws. For authorized testing only.
Dependencies
| Package | Version | Purpose |
|---|---|---|
| requests | >=2.28 | API and cert pinning testing |
| apktool | >=2.7 | APK decompilation (subprocess) |
| adb | - | Android device interaction (subprocess) |
CLI Usage
python agent.py --apk target.apk --manifest AndroidManifest.xml \
--api-url https://api.target.com --auth-token <jwt> --output report.jsonKey Functions
decompile_apk(apk_path, output_dir)
Decompiles APK using apktool for static analysis of smali code and resources.
extract_strings_from_apk(apk_path)
Extracts hardcoded sensitive strings (API keys, passwords, tokens, URLs) from APK binary.
check_android_manifest(manifest_path)
Analyzes AndroidManifest.xml for debuggable, allowBackup, exported components, and cleartext traffic settings.
test_certificate_pinning(target_url)
Tests if API connections succeed through a proxy (indicating missing cert pinning).
check_insecure_storage_adb()
Checks shared_prefs, databases, and external storage for sensitive data via adb shell.
test_api_endpoints(base_url, endpoints, auth_token)
Tests API endpoints for authorization bypass by comparing authenticated vs unauthenticated responses.
check_root_detection(package_name)
Inspects the app package for root detection library indicators (RootBeer, SafetyNet).
OWASP MASTG Coverage
| Category | Test | Function |
|---|---|---|
| MASVS-STORAGE | Insecure Data Storage | check_insecure_storage_adb |
| MASVS-STORAGE | Hardcoded Credentials | extract_strings_from_apk |
| MASVS-NETWORK | Certificate Pinning | test_certificate_pinning |
| MASVS-NETWORK | Cleartext Traffic | check_android_manifest |
| MASVS-AUTH | API Authorization | test_api_endpoints |
| MASVS-RESILIENCE | Root Detection | check_root_detection |
#!/usr/bin/env python3
# For authorized penetration testing and lab environments only
"""Mobile App Penetration Testing Agent - Tests Android/iOS apps for OWASP MASTG vulnerabilities."""
import json
import logging
import argparse
import subprocess
from datetime import datetime
import requests
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
logger = logging.getLogger(__name__)
def decompile_apk(apk_path, output_dir):
"""Decompile Android APK using apktool for static analysis."""
cmd = ["apktool", "d", apk_path, "-o", output_dir, "-f"]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
if result.returncode == 0:
logger.info("APK decompiled to %s", output_dir)
return True
logger.error("Decompilation failed: %s", result.stderr[:200])
return False
def extract_strings_from_apk(apk_path):
"""Extract hardcoded strings from APK for sensitive data detection."""
cmd = ["strings", apk_path]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=60)
sensitive_patterns = {
"api_key": [], "password": [], "secret": [], "token": [],
"http://": [], "aws_access": [], "private_key": [],
}
for line in result.stdout.split("\n"):
line_lower = line.strip().lower()
for pattern in sensitive_patterns:
if pattern in line_lower and len(line.strip()) < 200:
sensitive_patterns[pattern].append(line.strip())
total = sum(len(v) for v in sensitive_patterns.values())
logger.info("Extracted %d sensitive strings from APK", total)
return sensitive_patterns
def check_android_manifest(manifest_path):
"""Analyze AndroidManifest.xml for security misconfigurations."""
findings = []
with open(manifest_path, "r", errors="ignore") as f:
content = f.read()
checks = [
("android:debuggable=\"true\"", "App is debuggable - allows runtime manipulation"),
("android:allowBackup=\"true\"", "Backup allowed - data extractable via adb backup"),
("android:exported=\"true\"", "Components exported without permission protection"),
("android:usesCleartextTraffic=\"true\"", "Cleartext HTTP traffic allowed"),
("android:networkSecurityConfig", None),
]
for pattern, description in checks:
if description and pattern in content:
findings.append({"check": pattern, "finding": description, "severity": "Medium"})
if "android:networkSecurityConfig" not in content:
findings.append({
"check": "Missing networkSecurityConfig",
"finding": "No custom network security configuration - may trust user-installed CAs",
"severity": "Medium",
})
logger.info("Manifest analysis: %d findings", len(findings))
return findings
def test_certificate_pinning(target_url):
"""Test if the app enforces certificate pinning via mitmproxy check."""
try:
resp = requests.get(target_url, timeout=10, verify=False)
return {
"url": target_url,
"status": resp.status_code,
"pinning_bypassed": resp.status_code == 200,
"note": "If 200 with proxy active, cert pinning is not enforced",
}
except requests.RequestException as e:
return {"url": target_url, "pinning_bypassed": False, "error": str(e)}
def check_insecure_storage_adb():
"""Check for insecure data storage on connected Android device via adb."""
checks = [
("shared_prefs", "run-as com.target.app ls /data/data/com.target.app/shared_prefs/"),
("databases", "run-as com.target.app ls /data/data/com.target.app/databases/"),
("external_storage", "ls /sdcard/Android/data/com.target.app/"),
]
findings = []
for check_name, adb_cmd in checks:
cmd = ["adb", "shell"] + adb_cmd.split()
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
if result.returncode == 0 and result.stdout.strip():
findings.append({
"check": check_name,
"files_found": result.stdout.strip().split("\n"),
"severity": "High" if check_name == "external_storage" else "Medium",
})
logger.info("Storage checks: %d findings", len(findings))
return findings
def test_api_endpoints(base_url, endpoints, auth_token=None):
"""Test mobile app API endpoints for common vulnerabilities."""
headers = {}
if auth_token:
headers["Authorization"] = f"Bearer {auth_token}"
results = []
for endpoint in endpoints:
url = f"{base_url}{endpoint}"
try:
resp = requests.get(url, headers=headers, timeout=10, verify=False)
result = {
"endpoint": endpoint,
"status": resp.status_code,
"response_size": len(resp.content),
}
no_auth_resp = requests.get(url, timeout=10, verify=False)
if no_auth_resp.status_code == 200 and resp.status_code == 200:
result["auth_bypass"] = True
result["severity"] = "Critical"
else:
result["auth_bypass"] = False
results.append(result)
except requests.RequestException:
continue
return results
def check_root_detection(package_name):
"""Check if the app implements root/jailbreak detection."""
cmd = ["adb", "shell", "pm", "dump", package_name]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
root_indicators = ["rootbeer", "rootdetect", "safetynet", "integrity", "tamper"]
found = [ind for ind in root_indicators if ind in result.stdout.lower()]
return {
"package": package_name,
"root_detection_indicators": found,
"likely_protected": len(found) > 0,
}
def generate_report(apk_analysis, manifest_findings, storage_findings, api_results, cert_pinning):
"""Generate mobile app penetration test report."""
report = {
"timestamp": datetime.utcnow().isoformat(),
"sensitive_strings": {k: len(v) for k, v in apk_analysis.items()},
"manifest_findings": manifest_findings,
"storage_findings": storage_findings,
"api_security": api_results,
"certificate_pinning": cert_pinning,
}
total = len(manifest_findings) + len(storage_findings) + len([r for r in api_results if r.get("auth_bypass")])
print(f"MOBILE PENTEST REPORT - {total} findings")
return report
def main():
parser = argparse.ArgumentParser(description="Mobile App Penetration Testing Agent")
parser.add_argument("--apk", help="Path to Android APK file")
parser.add_argument("--manifest", help="Path to AndroidManifest.xml")
parser.add_argument("--api-url", help="Backend API base URL")
parser.add_argument("--auth-token", help="Auth token for API testing")
parser.add_argument("--output", default="mobile_pentest_report.json")
args = parser.parse_args()
apk_strings = extract_strings_from_apk(args.apk) if args.apk else {}
manifest_findings = check_android_manifest(args.manifest) if args.manifest else []
storage = check_insecure_storage_adb()
api_results = []
if args.api_url:
endpoints = ["/api/v1/user/profile", "/api/v1/users", "/api/v1/settings", "/api/v1/admin"]
api_results = test_api_endpoints(args.api_url, endpoints, args.auth_token)
cert_pinning = test_certificate_pinning(args.api_url) if args.api_url else {}
report = generate_report(apk_strings, manifest_findings, storage, api_results, cert_pinning)
with open(args.output, "w") as f:
json.dump(report, f, indent=2)
logger.info("Report saved to %s", args.output)
if __name__ == "__main__":
main()