Skip to content

7. Docker Container for MobSF Static Analysis

Ajin Abraham edited this page May 16, 2019 · 13 revisions

Building Image from Dockerfile

git clone https://github.com/MobSF/Mobile-Security-Framework-MobSF.git
cd Mobile-Security-Framework-MobSF
docker build -t mobsf .
docker run -it -p 8000:8000 mobsf

This will run MobSF at 0.0.0.0:8000

Building Image behind a proxy from Dockerfile

docker build --build-arg https_proxy="http://proxy_ip:proxy_port" --build-arg http_proxy="proxy_ip:proxy_port" --build-arg NO_PROXY="127.0.0.1" -t mobsf .

(replace `proxy_ip` with the value of your proxy ip address and `proxy_port` with the proxy port used 

Rebuilding Image from Dockerfile from Scratch

docker rmi ubuntu:18.04
docker build --no-cache --rm -t mobsf .

Prebuilt MobSF Docker Image

https://hub.docker.com/r/opensecurity/mobile-security-framework-mobsf/

docker pull opensecurity/mobile-security-framework-mobsf
docker run -it -p 8000:8000 opensecurity/mobile-security-framework-mobsf:latest

For persistence

docker run -it -p 8000:8000 -v <your_local_dir>:/root/.MobSF opensecurity/mobile-security-framework-mobsf:latest

For postgres support

You will need docker-compose : see https://docs.docker.com/compose/install/

  • build the images docker-compose build
  • launch the services docker-compose up -d (in background) or docker-compose up (in foreground )

Then verify the 2 services are up:

docker ps

CONTAINER ID        IMAGE                                   COMMAND                  CREATED             STATUS              PORTS                          NAMES
7de107c5b853        mobile-security-framework-mobsf_mobsf   "python3 manage.py r…"   5 weeks ago         Up 5 weeks          0.0.0.0:8000->8000/tcp         mobile-security-framework-mobsf_mobsf_1
149a3ffa61ca        postgres:latest                         "docker-entrypoint.s…"   5 weeks ago         Up 5 weeks          5432/tcp                       mobile-security-framework-mobsf_postgres_1

If you don't want to use docker-compose, you will need to start a postgres container first , then to start MobSF using the dockerfile and setting POSTGRES variable to True

docker build --build-arg POSTGRES=True -t mobsf .

You can change postgres connection information in postgres_support.sh Do it before building the image

#!/bin/bash
set -e
POSTGRES=$1
echo "Postgres support : ${POSTGRES}"
if [ "$POSTGRES" == True ]; then
 echo "Installing Postgres"
 pip3 install psycopg2-binary
 #Enable postgres support
 sed -i '/# Sqlite3 suport/,/# End Sqlite3 support/d' ./MobSF/settings.py && \
 sed -i "/# Postgres DB - Install psycopg2/,/'''/d" ./MobSF/settings.py && \
 sed -i "/# End Postgres support/,/'''/d" ./MobSF/settings.py && \
 sed -i "s/'PASSWORD': '',/'PASSWORD': 'password',/" ./MobSF/settings.py && \
 sed -i "s/'HOST': 'localhost',/'HOST': 'postgres',/" ./MobSF/settings.py
fi

If you have error at first Launch

docker exec -it mobile-security-framework-mobsf_mobsf_1 python3 manage.py makemigrations
docker exec -it mobile-security-framework-mobsf_mobsf_1 python3 manage.py migrate
You can’t perform that action at this time.