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.
https://opensecurity.in
GNU General Public License v3.0
17.18k stars 3.22k forks source link

Dynamic Analysis Failed on MacBook Pro m1 #2378

Closed AzhariRamadhan closed 4 months ago

AzhariRamadhan commented 5 months ago

ENVIRONMENT

OS and Version: MacBook Pro M1 Sonoma 14.4 and also i used Docker : OS Environment: Linux (ubuntu 22.04 Jammy Jellyfish) Linux-6.6.22-linuxkit-aarch64-with-glibc2.35
Python Version: Python 3.11.6
MobSF Version: Mobile Security Framework v3.9.8 Beta

EXPLANATION OF THE ISSUE

this issued happen when run mobsf using docker and cannot run dynamic analyzer

STEPS TO REPRODUCE THE ISSUE

1. run AVD from android studio using this command : emulator -avd Small_Phone_API_28
2. and i run mobsf docker using this command : docker run -e MOBSF_ANALYZER_IDENTIFIER=emulator-5554 -p 8000:8000 -p 1337:1337 opensecurity/mobile-security-framework-mobsf:latest
3. when i started dynamic, i got some error like this
```
[INFO] 19/Apr/2024 09:33:38 - Connecting to Android host.docker.internal:5555
* daemon not running; starting now at tcp:5037
* daemon started successfully
[INFO] 19/Apr/2024 09:33:41 - Waiting for 2 seconds...
[ERROR] 19/Apr/2024 09:33:43 - Error Running ADB Command
Traceback (most recent call last):
  File "/home/mobsf/Mobile-Security-Framework-MobSF/mobsf/DynamicAnalyzer/views/android/environment.py", line 167, in adb_command
    result = subprocess.check_output(
  File "/usr/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/adb', '-s', 'host.docker.internal:5555', 'shell', 'getprop', 'ro.build.version.release']' returned non-zero exit status 1.
[INFO] 19/Apr/2024 09:33:47 - Creating Dynamic Analysis Environment for com.comers.samsatbengkulu
[INFO] 19/Apr/2024 09:33:50 - ADB Restarted
[INFO] 19/Apr/2024 09:33:50 - Waiting for 2 seconds...
[INFO] 19/Apr/2024 09:33:52 - Connecting to Android host.docker.internal:5555
[INFO] 19/Apr/2024 09:33:52 - Waiting for 2 seconds...
[INFO] 19/Apr/2024 09:33:54 - Restarting ADB Daemon as root
adb: unable to connect for root: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
[ERROR] 19/Apr/2024 09:33:54 - Dynamic Analyzer
Traceback (most recent call last):
  File "/home/mobsf/Mobile-Security-Framework-MobSF/mobsf/DynamicAnalyzer/views/android/dynamic_analyzer.py", line 152, in dynamic_analyzer
    if not env.connect_n_mount():
  File "/home/mobsf/Mobile-Security-Framework-MobSF/mobsf/DynamicAnalyzer/views/android/environment.py", line 95, in connect_n_mount
    if not self.run_subprocess_verify_output([get_adb(),
  File "/home/mobsf/Mobile-Security-Framework-MobSF/mobsf/DynamicAnalyzer/views/android/environment.py", line 68, in run_subprocess_verify_output
    out = subprocess.check_output(cmd)  # lgtm [py/command-line-injection]
  File "/usr/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/adb', '-s', 'host.docker.internal:5555', 'root']' returned non-zero exit status 1.
[ERROR] 19/Apr/2024 09:33:54 - Dynamic Analysis Failed.
[ERROR] 19/Apr/2024 09:33:54 - Internal Server Error: /android_dynamic/e6a14526aeddeb8447efe51b7d4bf2d2
```
github-actions[bot] commented 5 months ago

👋 @AzhariRamadhan Issues is only for reporting a bug/feature request. For limited support, questions, and discussions, please join MobSF Slack channel Please include all the requested and relevant information when opening a bug report. Improper reports will be closed without any response.

AzhariRamadhan commented 5 months ago

when i try manualy using git clone and run ./run.sh

i got same error [INFO] 19/Apr/2024 10:42:31 - MobSFying Android instance [INFO] 19/Apr/2024 10:42:34 - ADB Restarted [INFO] 19/Apr/2024 10:42:34 - Waiting for 2 seconds... [INFO] 19/Apr/2024 10:42:36 - Connecting to Android emulator-5656 [INFO] 19/Apr/2024 10:42:55 - Waiting for 2 seconds... [ERROR] 19/Apr/2024 10:42:57 - failed to connect to 'emulator-5656:5555': Connection refused [2024-04-19 17:45:24 +0700] [43540] [INFO] Handling signal: winch [2024-04-19 17:45:24 +0700] [43540] [INFO] Handling signal: winch [2024-04-19 17:45:24 +0700] [43540] [INFO] Handling signal: winch [2024-04-19 17:45:24 +0700] [43540] [INFO] Handling signal: winch [2024-04-19 17:45:25 +0700] [43540] [INFO] Handling signal: winch [INFO] 19/Apr/2024 10:48:38 - Connecting to Android emulator-5554 [INFO] 19/Apr/2024 10:48:39 - Waiting for 2 seconds... [ERROR] 19/Apr/2024 10:48:41 - failed to connect to 'emulator-5554:5555': Connection refused [INFO] 19/Apr/2024 10:48:51 - MobSFying Android instance [INFO] 19/Apr/2024 10:48:54 - ADB Restarted [INFO] 19/Apr/2024 10:48:54 - Waiting for 2 seconds... [INFO] 19/Apr/2024 10:48:56 - Connecting to Android emulator-5554 [INFO] 19/Apr/2024 10:48:56 - Waiting for 2 seconds... [ERROR] 19/Apr/2024 10:48:58 - failed to connect to 'emulator-5554:5555': Connection refused

even i try emulator -avd devicename -port 5555 or -port 5554 stil same

ajinabraham commented 4 months ago

Please use slack for support.

ben-tanto commented 4 months ago

What might be useful is ensuring ADB is listening on tcpip mode then running docker in host mode to ensure TCP comms are simpler and on the same host. This may help:

  1. Start AVD
  2. Reconnect to AVD using tcp adb connect 0.0.0.0:5555
  3. Start mobsf in host mode so we can directly connect to adb docker run -it --net=host --rm -e MOBSF_ANALYZER_IDENTIFIER="0.0.0.0:5555" opensecurity/mobile-security-framework-mobsf:latest
p314dO commented 2 months ago

What might be useful is ensuring ADB is listening on tcpip mode then running docker in host mode to ensure TCP comms are simpler and on the same host. This may help:

1. Start AVD

2. Reconnect to AVD using tcp `adb connect 0.0.0.0:5555`

3. Start mobsf in host mode so we can directly connect to adb
   `docker run -it --net=host --rm -e MOBSF_ANALYZER_IDENTIFIER="0.0.0.0:5555" opensecurity/mobile-security-framework-mobsf:latest`

You save me. Thanks!