Introducing a new way to review your PRs.

Read the announcement

mobsf / mobile-security-framework-mobsf

Mobile Security Framework (MobSF) is an automated, all-in-one mobile application (Android/iOS/Windows) pen-testing, malware analysis and security assessment framework capable of performing static and dynamic analysis.

View on GitHub

13 documents · Updated Nov 16, 2026

docs / ios-dynamic-analysis

iOS dynamic analysis

Overview

This area implements two iOS dynamic-analysis paths: Corellium-backed virtual devices under mobsf/…/*.py, and direct jailbroken-device analysis under mobsf/…/*.py. Both paths use the same scan inventory and reporting primitives: mobsf/…/helpers.py lists previously uploaded IPA scans from StaticAnalyzerIOS, derives a per-bundle checksum from the bundle id, and marks whether mobsf_dump_file.txt already exists under settings.UPLD_DIR/<bundle-hash>/; mobsf/…/analysis.py later reads that dump file, mobsf_frida_out.txt, copied HTTP proxy flows from ~/…/<bundle-id>.flow.txt, screenshots from settings.DWD_DIR, and downloaded app-container files to build report data.

The Corellium UI entry point is mobsf/…/dynamic_analyzer.py. dynamic_analysis() checks Corellium readiness/authentication through CorelliumAPI, discovers jailbroken iOS instances, selects or resolves the project id, and calls setup_ssh_keys() so the MobSF-generated public key is authorized for project SSH. dynamic_analyzer() validates a bundle id and instance id, creates settings.UPLD_DIR/<bundle-hash>/, starts the HTTPS proxy via configure_proxy(), and passes the Corellium instance id plus bundle metadata to the analyzer template. configure_proxy() in mobsf/…/helpers.py always restarts the local HTTPS proxy and, for Corellium instances, opens a reverse SSH port forward so traffic from the VM can reach settings.PROXY_PORT on MobSF.

Corellium HTTP integration is centralized in mobsf/…/corellium_apis.py. CorelliumAPI manages API readiness, project lookup, project SSH keys, iOS instance listing/creation, and filters listed instances to iOS devices with the jailbroken patch. CorelliumInstanceAPI wraps instance lifecycle, screenshots, sslsplit network capture, pcap download, console logs, quick-connect SSH command retrieval, and touch/text/button input. CorelliumAgentAPI wraps the in-VM agent used to unlock devices, upload /tmp/app.ipa, install/run/kill/uninstall apps, list apps, and fetch icons. mobsf/…/corellium_instance.py exposes those operations as authenticated POST/GET handlers, including app installation fallback through AppSync when the Corellium agent reports a re-signing error.

Corellium SSH support is in mobsf/…/corellium_ssh.py. It generates an Ed25519 key pair at Path(settings.UPLD_DIR).parent, parses Corellium quick-connect commands into bastion/private-host parts, opens an SSH connection through the bastion with paramiko, and provides three tunnel shapes: local port forwarding for Frida port 27042, reverse forwarding of settings.PROXY_PORT for the HTTPS proxy, and direct command/SFTP upload/download helpers. The Corellium dynamic handlers in mobsf/…/corellium_instance.py use the same SSH layer for arbitrary command execution, /tmp file upload/download, AppSync install commands, and app-container tar creation/download.

Corellium instrumentation starts in mobsf/…/tests_frida.py. ios_instrument() validates the instance id, bundle ids, selected hook names, and hash, creates a Frida object from mobsf/…/frida_core.py, and supports spawn, session, ps, and get actions. Frida.spawn() uses frida.get_remote_device() and, if the Frida server is not reachable, starts the Corellium SSH local forward before retrying. Frida.session() attaches to the current or supplied PID, builds a script from custom code, bundled scripts under settings.TOOLS_DIR/frida_scripts/ios/{default,dump,rpc}, and auxiliary snippets from mobsf/…/frida_auxiliary_scripts.py; then it loads the script, resumes the process, invokes RPC helpers, and keeps the session alive in a background thread. Dump hooks must send JSON with the [MBSFDUMP] key prefix; parse_dump_message() strips that marker and writes one JSON object per line to mobsf_dump_file.txt, while other Frida messages go to mobsf_frida_out.txt. RPC calls also persist the app container path in mobsf_app_container_path.txt after is_safe_ios_container_path() validation, and may write class/method lookup results to mobsf_rpc_classes.txt, mobsf_rpc_methods.txt, or mobsf_rpc_impl.txt.

The Corellium data-collection flow is completed by download_data() in mobsf/…/corellium_instance.py. It reads mobsf_app_container_path.txt, verifies the path, tars the app container on the VM through SSH, copies the tar into both the app upload directory and settings.DWD_DIR/<checksum>-app_data.tar, stops the HTTP proxy tooling, copies the raw web-flow text to settings.DWD_DIR/<checksum>-web_traffic.txt, and downloads Corellium's network pcap to settings.DWD_DIR/<checksum>-network.pcap. ios_view_report() in mobsf/…/report.py then requires either Frida logs or dynamic data, parses API-monitor records with ios_api_analysis(), extracts URLs/domains/emails and local app data files with run_analysis(), enriches domains with tracker matches, and renders or returns the dynamic report context.

The direct-device flow starts in mobsf/…/dynamic_analyzer.py. dynamic_analysis_device() lists uploaded IPAs, USB devices from IOSConnector.get_usb_devices() when not running in Docker, and configured Wi-Fi devices from IOS_ANALYZER_IDENTIFIERS or MOBSF_IOS_ANALYZER_IDENTIFIERS. dynamic_analyzer_device() validates the bundle id and device id, connects through validate_and_connect_device(), creates settings.UPLD_DIR/<bundle-hash>/, starts the local proxy without Corellium reverse forwarding, and calls IOSEnvironment.setup_or_start_frida() before rendering the device analyzer. USB ids must match IOS_DEVICE_ID_REGEX; Wi-Fi entries must match SSH_DEVICE_ID_REGEX and be present in the configured identifiers list. SSH credentials come from IOS_SSH_USER and IOS_SSH_PASSWORD, defaulting to root/alpine.

Device connection and operations are split between mobsf/…/connect.py and mobsf/…/device.py. IOSConnector discovers USB devices with idevice_id/ideviceinfo, maps hardware product types using get_ios_model_mapping(), starts iproxy for local SSH (localhost:2222 by default) and Frida (localhost:37042 to device 27042), and verifies the target is jailbroken by running id and requiring uid=0(root). Wi-Fi connections go directly over SSH to the configured host and port. IOSDevice wraps command execution, SFTP file transfer, process listing, architecture detection, app listing via uicache -l, icon retrieval/uncrushing, deb installation, AppSync setup, and IPA installation with appinst.

Device environment setup is in mobsf/…/environment.py. IOSEnvironment determines the iOS platform architecture via dpkg --print-architecture, expects/downloads a matching frida_<frida-version>_iphoneos-<arch>.deb in settings.DWD_DIR, uploads and installs it, finds the Frida launch daemon plist, rewrites ProgramArguments to listen on 0.0.0.0, restarts Frida through launchctl or frida-server -l 0.0.0.0 &, installs oslog from mobsf/DynamicAnalyzer/tools/ios/oslog/, and records /tmp/frida_setup_done with the Python Frida version to avoid reinstalling on later runs. AppSync for device IPA installs is installed from bundled debs under mobsf/DynamicAnalyzer/tools/ios/appsync/ first, falling back to the Akemi apt repo.

Device Frida integration is mobsf/…/frida.py, which subclasses the Corellium Frida class and reuses script assembly, dump parsing, logging, container-path persistence, and RPC handling. The main difference is device selection: USB analysis adds a remote Frida device at localhost:37042 because IOSConnector started iproxy, while Wi-Fi/Docker analysis connects to the device host on Frida's default port. ios_instrument_device() in mobsf/…/dynamic_analyzer.py supports run, spawn, session, ps, get, and capture; capture uses a threading event that is set when Frida logs ✅ Screenshot Captured, then downloads /tmp/screenshot.png into settings.DWD_DIR/<checksum>-sshot-<timestamp>.png.

Device reporting mirrors the Corellium path in mobsf/…/report.py. download_data_device() tars and downloads the safe Frida-discovered app container path, stops the HTTP proxy, and copies raw web-flow logs. view_report_device() uses the shared ios_api_analysis() and run_analysis() helpers and tracker enrichment. ios_api_monitor() streams parsed mobsf_dump_file.txt records as API-monitor rows, classifying records by keys such as cookies, keychain, network, sql, filename, crypto, nsuserdefaults, and pasteboard.

Coupling

Risks

  • mobsf/…/corellium_ssh.py parses Corellium SSH strings by fixed space positions and always authenticates to the private device as password alpine; if Corellium changes quick-connect output or device credentials, Corellium Frida forwarding, proxy forwarding, file transfer, and AppSync fallback all fail before analysis starts.
  • mobsf/…/corellium_instance.py caches a process-global SSH_TARGET for command and file-download handlers; if two users or instances issue SSH operations concurrently, a stale connection can be reused for the wrong instance until an SSHException forces reconnection.
  • mobsf/…/connect.py may run pkill -f iproxy.*<device_id> before starting USB forwarding; if another MobSF request or external workflow is using iproxy for the same UDID, connecting a device-analysis session can interrupt it.
  • mobsf/…/frida.py connects Wi-Fi Frida sessions to self.connector.host without the SSH port from the configured device id; if Frida is exposed on a non-default host/port arrangement, SSH can succeed while Frida actions fail or attach to an unexpected listener.