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.

Home Page:https://opensecurity.in

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Docker Persistence] Not enough privileges to write in volumes

HackJJ opened this issue · comments

commented

ENVIRONMENT

OS and Version: Apple M2 Sonoma 14.2.1
Python Version: 3.11.7
MobSF Version: Latest one in GitHub

EXPLANATION OF THE ISSUE

I am trying to follow the persistence documentation as per https://github.com/MobSF/docs/blob/master/docker.md with the latest version pulled down from GitHub:

git clone https://github.com/MobSF/Mobile-Security-Framework-MobSF.git
cd Mobile-Security-Framework-MobSF
mkdir persistence && sudo chown 9901:9901 persistence
docker build --platform linux/arm64 -t project-name .
docker run -it --rm --name mobsf -p 8000:8000 -v persistence:/home/mobsf/.MobSF project-name

When I do this, I get errors

STEPS TO REPRODUCE THE ISSUE

git clone https://github.com/MobSF/Mobile-Security-Framework-MobSF.git
cd Mobile-Security-Framework-MobSF
mkdir persistence && sudo chown 9901:9901 persistence
docker build --platform linux/arm64 -t project-name .
docker run -it --rm --name mobsf -p 8000:8000 -v persistence:/home/mobsf/.MobSF project-name

LOG FILE

Cannot create config file
Traceback (most recent call last):
  File "/home/mobsf/Mobile-Security-Framework-MobSF/mobsf/MobSF/init.py", line 64, in create_user_conf
    with open(config_path, 'w') as f:
PermissionError: [Errno 13] Permission denied: '/home/mobsf/.MobSF/config.py'
Creating MobSF Home Directory
Traceback (most recent call last):
  File "/home/mobsf/Mobile-Security-Framework-MobSF/mobsf/MobSF/init.py", line 118, in get_mobsf_home
    os.makedirs(dwd_dir)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/home/mobsf/.MobSF/downloads/'
Traceback (most recent call last):
  File "/home/mobsf/Mobile-Security-Framework-MobSF/manage.py", line 18, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py", line 382, in execute
    settings.INSTALLED_APPS
  File "/usr/local/lib/python3.10/dist-packages/django/conf/__init__.py", line 89, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python3.10/dist-packages/django/conf/__init__.py", line 76, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python3.10/dist-packages/django/conf/__init__.py", line 190, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/mobsf/Mobile-Security-Framework-MobSF/mobsf/MobSF/settings.py", line 32, in <module>
    DWD_DIR = os.path.join(MobSF_HOME, 'downloads/')
  File "/usr/lib/python3.10/posixpath.py", line 76, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
[2024-03-02 14:09:23 +0000] [1] [INFO] Starting gunicorn 21.2.0
[2024-03-02 14:09:23 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2024-03-02 14:09:23 +0000] [1] [INFO] Using worker: gthread
[2024-03-02 14:09:23 +0000] [8] [INFO] Booting worker with pid: 8
Cannot create config file
Traceback (most recent call last):
  File "/home/mobsf/Mobile-Security-Framework-MobSF/mobsf/MobSF/init.py", line 64, in create_user_conf
    with open(config_path, 'w') as f:
PermissionError: [Errno 13] Permission denied: '/home/mobsf/.MobSF/config.py'
Creating MobSF Home Directory
Traceback (most recent call last):
  File "/home/mobsf/Mobile-Security-Framework-MobSF/mobsf/MobSF/init.py", line 118, in get_mobsf_home
    os.makedirs(dwd_dir)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/home/mobsf/.MobSF/downloads/'
[2024-03-02 14:09:24 +0000] [8] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/arbiter.py", line 609, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/workers/gthread.py", line 95, in init_process
    super().init_process()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/usr/local/lib/python3.10/dist-packages/gunicorn/util.py", line 371, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/mobsf/Mobile-Security-Framework-MobSF/mobsf/MobSF/wsgi.py", line 16, in <module>
    from . import settings
  File "/home/mobsf/Mobile-Security-Framework-MobSF/mobsf/MobSF/settings.py", line 32, in <module>
    DWD_DIR = os.path.join(MobSF_HOME, 'downloads/')
  File "/usr/lib/python3.10/posixpath.py", line 76, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
[2024-03-02 14:09:24 +0000] [8] [INFO] Worker exiting (pid: 8)
[2024-03-02 14:09:24 +0000] [1] [ERROR] Worker (pid:8) exited with code 3
[2024-03-02 14:09:24 +0000] [1] [ERROR] Shutting down: Master
[2024-03-02 14:09:24 +0000] [1] [ERROR] Reason: Worker failed to boot.

👋 @HackJJ
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.

commented

It works if I do this sudo chmod -R 777 persistence

I don't see this issue locally in my Mac and Linux. Might be a permission issue at your end.