android-re-mcp 1.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- android_re_mcp/__init__.py +11 -0
- android_re_mcp/__main__.py +90 -0
- android_re_mcp/clitools.py +48 -0
- android_re_mcp/config.py +38 -0
- android_re_mcp/config.toml +9 -0
- android_re_mcp/frida_scripts/__init__.py +1 -0
- android_re_mcp/frida_scripts/build_bundles.sh +56 -0
- android_re_mcp/frida_scripts/crypto_monitor.js +13776 -0
- android_re_mcp/frida_scripts/frida_detection_bypass.js +13767 -0
- android_re_mcp/frida_scripts/index.py +127 -0
- android_re_mcp/frida_scripts/memory_scan.js +140 -0
- android_re_mcp/frida_scripts/method_tracer.js +13742 -0
- android_re_mcp/frida_scripts/network_monitor.js +13774 -0
- android_re_mcp/frida_scripts/root_detection_bypass.js +13809 -0
- android_re_mcp/frida_scripts/src/crypto_monitor.js +124 -0
- android_re_mcp/frida_scripts/src/frida_detection_bypass.js +124 -0
- android_re_mcp/frida_scripts/src/method_tracer.js +95 -0
- android_re_mcp/frida_scripts/src/network_monitor.js +128 -0
- android_re_mcp/frida_scripts/src/root_detection_bypass.js +139 -0
- android_re_mcp/frida_scripts/src/ssl_pinning_universal.js +105 -0
- android_re_mcp/frida_scripts/src/storage_monitor.js +155 -0
- android_re_mcp/frida_scripts/ssl_pinning_universal.js +13756 -0
- android_re_mcp/frida_scripts/storage_monitor.js +13782 -0
- android_re_mcp/guard.py +132 -0
- android_re_mcp/handlers/__init__.py +1 -0
- android_re_mcp/handlers/apiextractor.py +183 -0
- android_re_mcp/handlers/apkdiff.py +333 -0
- android_re_mcp/handlers/apkscan.py +151 -0
- android_re_mcp/handlers/device.py +660 -0
- android_re_mcp/handlers/dynamic.py +816 -0
- android_re_mcp/handlers/flutter.py +345 -0
- android_re_mcp/handlers/googleservices.py +209 -0
- android_re_mcp/handlers/memory.py +85 -0
- android_re_mcp/handlers/native.py +731 -0
- android_re_mcp/handlers/network.py +379 -0
- android_re_mcp/handlers/patcher.py +377 -0
- android_re_mcp/handlers/rasp.py +389 -0
- android_re_mcp/handlers/signing.py +91 -0
- android_re_mcp/handlers/static.py +1154 -0
- android_re_mcp/knowledge/bypass-frida.md +37 -0
- android_re_mcp/knowledge/bypass-playbooks.md +122 -0
- android_re_mcp/knowledge/bypass-root.md +36 -0
- android_re_mcp/knowledge/bypass-ssl.md +25 -0
- android_re_mcp/knowledge/common-mistakes.md +74 -0
- android_re_mcp/knowledge/crypto-patterns.md +91 -0
- android_re_mcp/knowledge/detection-patterns.md +107 -0
- android_re_mcp/knowledge/first-look.md +41 -0
- android_re_mcp/knowledge/framework-fingerprints.md +93 -0
- android_re_mcp/knowledge/master-agent-workflow.md +32 -0
- android_re_mcp/knowledge/rasp-assess.md +58 -0
- android_re_mcp/knowledge/stuck.md +35 -0
- android_re_mcp/paths.py +69 -0
- android_re_mcp/server.py +1386 -0
- android_re_mcp/setup/__init__.py +1 -0
- android_re_mcp/setup/check_tools.py +377 -0
- android_re_mcp/setup/install_tool.py +342 -0
- android_re_mcp-1.4.0.dist-info/METADATA +113 -0
- android_re_mcp-1.4.0.dist-info/RECORD +62 -0
- android_re_mcp-1.4.0.dist-info/WHEEL +4 -0
- android_re_mcp-1.4.0.dist-info/entry_points.txt +2 -0
- android_re_mcp-1.4.0.dist-info/licenses/LICENSE +23 -0
- android_re_mcp-1.4.0.dist-info/licenses/NOTICE.md +4 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""android-re-mcp (Python): dynamic Android analysis MCP server.
|
|
2
|
+
|
|
3
|
+
Derived from mobile-security-mcp 0.1.4 (MIT). See NOTICE.md in the repository.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
__version__ = version("android-re-mcp")
|
|
10
|
+
except PackageNotFoundError: # running from a source checkout
|
|
11
|
+
__version__ = "0+local"
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Entry point for the android-re-mcp MCP server.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
python -m android_re_mcp # stdio transport (default)
|
|
6
|
+
python -m android_re_mcp --transport sse --port 8765 # SSE, loopback only
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import argparse
|
|
12
|
+
import asyncio
|
|
13
|
+
import logging
|
|
14
|
+
import sys
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _build_parser() -> argparse.ArgumentParser:
|
|
20
|
+
p = argparse.ArgumentParser(
|
|
21
|
+
prog="android-re-mcp",
|
|
22
|
+
description="Android dynamic analysis MCP server (Python half of android-re-mcp)",
|
|
23
|
+
)
|
|
24
|
+
p.add_argument(
|
|
25
|
+
"--transport",
|
|
26
|
+
choices=["stdio", "sse"],
|
|
27
|
+
default="stdio",
|
|
28
|
+
help="Transport to use (default: stdio)",
|
|
29
|
+
)
|
|
30
|
+
p.add_argument(
|
|
31
|
+
"--host",
|
|
32
|
+
default="127.0.0.1",
|
|
33
|
+
help="Address for SSE transport (default: 127.0.0.1). Anything else needs ANDROID_RE_MCP_TOKEN.",
|
|
34
|
+
)
|
|
35
|
+
p.add_argument(
|
|
36
|
+
"--port",
|
|
37
|
+
type=int,
|
|
38
|
+
default=8765,
|
|
39
|
+
help="Port for SSE transport (default: 8765)",
|
|
40
|
+
)
|
|
41
|
+
p.add_argument(
|
|
42
|
+
"--log-level",
|
|
43
|
+
default="WARNING",
|
|
44
|
+
choices=["DEBUG", "INFO", "WARNING", "ERROR"],
|
|
45
|
+
)
|
|
46
|
+
p.add_argument(
|
|
47
|
+
"--setup",
|
|
48
|
+
action="store_true",
|
|
49
|
+
help="Automatically download and install all missing RE tools into ~/tools",
|
|
50
|
+
)
|
|
51
|
+
return p
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def main() -> None:
|
|
55
|
+
"""Main entry point — starts the MCP server."""
|
|
56
|
+
parser = _build_parser()
|
|
57
|
+
args = parser.parse_args()
|
|
58
|
+
|
|
59
|
+
logging.basicConfig(
|
|
60
|
+
level=getattr(logging, args.log_level),
|
|
61
|
+
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
|
|
62
|
+
stream=sys.stderr,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
if args.setup:
|
|
66
|
+
print("[*] Starting zero-touch automated setup...")
|
|
67
|
+
from android_re_mcp.setup.install_tool import install_all_missing_tools
|
|
68
|
+
install_all_missing_tools()
|
|
69
|
+
print("[*] Setup complete! You can now start the MCP server.")
|
|
70
|
+
sys.exit(0)
|
|
71
|
+
|
|
72
|
+
from android_re_mcp.paths import ensure_tools_on_path
|
|
73
|
+
|
|
74
|
+
ensure_tools_on_path()
|
|
75
|
+
|
|
76
|
+
# Import here so startup errors surface cleanly
|
|
77
|
+
from android_re_mcp.server import create_server
|
|
78
|
+
|
|
79
|
+
server = create_server()
|
|
80
|
+
|
|
81
|
+
if args.transport == "stdio":
|
|
82
|
+
logger.info("Starting android-re-mcp over stdio")
|
|
83
|
+
asyncio.run(server.run_stdio())
|
|
84
|
+
else:
|
|
85
|
+
logger.info("Starting android-re-mcp SSE on %s:%d", args.host, args.port)
|
|
86
|
+
asyncio.run(server.run_sse(host=args.host, port=args.port))
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
if __name__ == "__main__":
|
|
90
|
+
main()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Locate the CLI executables the handlers actually invoke.
|
|
2
|
+
|
|
3
|
+
PATH is checked first, then the console-script directory that lives next
|
|
4
|
+
to the running interpreter (venv installs), which PATH often misses when
|
|
5
|
+
the server is started from an unactivated virtualenv — exactly the case
|
|
6
|
+
where `pip show apkleaks` said available while the handler said
|
|
7
|
+
missing_tool.
|
|
8
|
+
|
|
9
|
+
check_tools and every handler resolve through this module, so what the
|
|
10
|
+
inventory reports is what the tools really execute.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
import shutil
|
|
17
|
+
import sys
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def find_cli(name: str) -> str | None:
|
|
22
|
+
"""Absolute path of *name* as the handlers would invoke it, or None."""
|
|
23
|
+
if not name or os.path.basename(name) != name:
|
|
24
|
+
# Only plain tool names are expected; anything else is a caller bug.
|
|
25
|
+
return None
|
|
26
|
+
hit = shutil.which(name)
|
|
27
|
+
if hit:
|
|
28
|
+
return hit
|
|
29
|
+
candidates: list[Path] = []
|
|
30
|
+
# NB: absolute(), not resolve() — a venv interpreter is usually a symlink;
|
|
31
|
+
# resolving it would leave the venv's script directory entirely.
|
|
32
|
+
candidates.append(Path(sys.executable).absolute().parent)
|
|
33
|
+
scripts_name = "Scripts" if os.name == "nt" else "bin"
|
|
34
|
+
candidates.append(Path(sys.prefix) / scripts_name)
|
|
35
|
+
suffixes = (".exe", ".cmd", ".bat", "") if os.name == "nt" else ("",)
|
|
36
|
+
seen: set[Path] = set()
|
|
37
|
+
for directory in candidates:
|
|
38
|
+
if directory in seen:
|
|
39
|
+
continue
|
|
40
|
+
seen.add(directory)
|
|
41
|
+
for suffix in suffixes:
|
|
42
|
+
candidate = directory / f"{name}{suffix}"
|
|
43
|
+
try:
|
|
44
|
+
if candidate.is_file() and os.access(candidate, os.X_OK):
|
|
45
|
+
return str(candidate)
|
|
46
|
+
except OSError: # pragma: no cover - defensive
|
|
47
|
+
continue
|
|
48
|
+
return None
|
android_re_mcp/config.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Settings from the packaged defaults, overridden by the user's config file."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from android_re_mcp.paths import tools_dir, user_config_path
|
|
9
|
+
|
|
10
|
+
_DEFAULTS = Path(__file__).parent / "config.toml"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _read(path: Path) -> dict:
|
|
14
|
+
try:
|
|
15
|
+
import tomllib
|
|
16
|
+
except ImportError: # Python < 3.11 is not supported, kept for safety
|
|
17
|
+
return {}
|
|
18
|
+
try:
|
|
19
|
+
with open(path, "rb") as fh:
|
|
20
|
+
return tomllib.load(fh)
|
|
21
|
+
except (FileNotFoundError, PermissionError, ValueError):
|
|
22
|
+
return {}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def load_config() -> dict[str, dict[str, Any]]:
|
|
26
|
+
merged = _read(_DEFAULTS)
|
|
27
|
+
for section, values in _read(user_config_path()).items():
|
|
28
|
+
if isinstance(values, dict):
|
|
29
|
+
merged.setdefault(section, {}).update(values)
|
|
30
|
+
return merged
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def signer_jar() -> Path:
|
|
34
|
+
"""Absolute path to uber-apk-signer. Never resolved against the working directory."""
|
|
35
|
+
configured = str(load_config().get("signing", {}).get("jar_path", "") or "")
|
|
36
|
+
if configured and Path(configured).is_absolute():
|
|
37
|
+
return Path(configured)
|
|
38
|
+
return tools_dir() / "signing" / "uber-apk-signer.jar"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Defaults only. Put your own settings in ~/.config/android-re-mcp/config.toml (or $ANDROID_RE_MCP_CONFIG).
|
|
2
|
+
[signing]
|
|
3
|
+
# Absolute path to uber-apk-signer.jar. Empty uses ~/tools/signing/uber-apk-signer.jar
|
|
4
|
+
jar_path = ""
|
|
5
|
+
# Empty keystore uses uber-apk-signer's built-in debug keystore. Passwords given here show up in the process list.
|
|
6
|
+
keystore_path = ""
|
|
7
|
+
keystore_password = ""
|
|
8
|
+
key_alias = ""
|
|
9
|
+
key_password = ""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Frida script library package — categorized JS scripts for Android RE."""
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Rebuild the frida_scripts/*.js bundles from the raw sources in src/.
|
|
3
|
+
#
|
|
4
|
+
# frida 17 removed the global `Java`/`ObjC` bridges from script runtimes
|
|
5
|
+
# (QuickJS *and* V8): scripts must import them explicitly. Raw sources
|
|
6
|
+
# are written against the classic global and cannot work as-is, so every
|
|
7
|
+
# Java-hooking script ships as a self-contained bundle with
|
|
8
|
+
# frida-java-bridge compiled in. memory_scan is pure-native and ships as
|
|
9
|
+
# the raw source.
|
|
10
|
+
#
|
|
11
|
+
# Prerequisites: node + frida-compile (pipx-installed frida-tools ships
|
|
12
|
+
# it) and a checkout of the bridge: `npm install frida-java-bridge`.
|
|
13
|
+
#
|
|
14
|
+
# Usage: cd python/src/android_re_mcp/frida_scripts && bash build_bundles.sh
|
|
15
|
+
set -euo pipefail
|
|
16
|
+
|
|
17
|
+
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
18
|
+
COMPILE="${FRIDA_COMPILE:-$(command -v frida-compile || echo /home/dragon/.local/bin/frida-compile)}"
|
|
19
|
+
|
|
20
|
+
WORK="$(mktemp -d)"
|
|
21
|
+
trap 'rm -rf "$WORK"' EXIT
|
|
22
|
+
|
|
23
|
+
cd "$WORK"
|
|
24
|
+
# The bridge must resolve from the working directory.
|
|
25
|
+
if [ ! -d node_modules/frida-java-bridge ]; then
|
|
26
|
+
echo "[*] Installing frida-java-bridge..."
|
|
27
|
+
npm init -y >/dev/null
|
|
28
|
+
npm install frida-java-bridge >/dev/null 2>&1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
for f in "$HERE"/src/*.js; do
|
|
32
|
+
name="$(basename "$f" .js)"
|
|
33
|
+
if [ "$name" = "memory_scan" ]; then
|
|
34
|
+
continue # pure-native: ships as-is
|
|
35
|
+
fi
|
|
36
|
+
{
|
|
37
|
+
echo 'import Java from "frida-java-bridge";'
|
|
38
|
+
cat "$f"
|
|
39
|
+
} > "$name.entry.js"
|
|
40
|
+
"$COMPILE" -S -B iife "$name.entry.js" -o "$HERE/$name.js"
|
|
41
|
+
node --check "$HERE/$name.js"
|
|
42
|
+
echo "[+] bundled $name ($(wc -c < "$HERE/$name.js") bytes)"
|
|
43
|
+
done
|
|
44
|
+
|
|
45
|
+
echo "[*] Verifying config-protocol and bridge markers..."
|
|
46
|
+
for out in "$HERE"/*.js; do
|
|
47
|
+
name="$(basename "$out" .js)"
|
|
48
|
+
[ "$name" = "memory_scan" ] && continue
|
|
49
|
+
n_recv=$(grep -c 'recv("config"' "$out" || true)
|
|
50
|
+
n_bridge=$(grep -c "frida-java-bridge" "$out" || true)
|
|
51
|
+
if [ "$n_recv" -lt 2 ] || [ "$n_bridge" -lt 1 ]; then
|
|
52
|
+
echo "[!] $name: recv=$n_recv bridge=$n_bridge — refusing" >&2
|
|
53
|
+
exit 1
|
|
54
|
+
fi
|
|
55
|
+
done
|
|
56
|
+
echo "[*] All bundles verified."
|