Mobile-Security-Framework-MobSF icon indicating copy to clipboard operation
Mobile-Security-Framework-MobSF copied to clipboard

Run MobSF through command [FEATURE]

Open sohilshrestha0 opened this issue 1 year ago • 2 comments

Run MobSF through command to make it easy for users to use.

I have written a code in bash script If anyone want to use it then make a file in /usr/local/bin as mobsf and paste this code. and chmod +x mobsf for execute permission

#!/bin/bash

Function to display usage information

usage() { echo "Usage: mobsf [options]" echo "Options:" echo " -d, --dynamic <IP_ADDRESS> Perform dynamic analysis on the device with the specified IP_ADDRESS" echo " -p option must be used to specify the port" echo " -s, --static Perform static analysis" echo " -h, --help Display this usage message" }

Default values

dynamic_mode=false static_mode=false ip_address="" port=""

Fetch the username of the non-root user

username=$(whoami)

Fetch the hostname (PC name)

pc_name=$(hostname)

Check for command-line arguments

while [ $# -gt 0 ]; do case "$1" in -d|--dynamic) dynamic_mode=true shift ip_address=$1 ;; -p) shift port=$1 ;; -s|--static) static_mode=true ;; -h|--help) usage exit 0 ;; *) usage exit 1 ;; esac shift done

If dynamic mode is enabled, run dynamic analysis

if [ "$dynamic_mode" = true ]; then if [ -z "$ip_address" ] && [ -z "$port" ]; then echo "Please specify both IP address and port for dynamic analysis." usage exit 1 elif [ -z "$ip_address" ]; then echo "Please specify an IP address for dynamic analysis." usage exit 1 elif [ -z "$port" ]; then echo "Please specify a port for dynamic analysis." usage exit 1 fi sudo docker run -it --rm -p 8000:8000 -p $port:$port -e MOBSF_ANALYZER_IDENTIFIER=$ip_address:$port opensecurity/mobile-security-framework-mobsf:latest

If static mode is enabled, run static analysis

elif [ "$static_mode" = true ]; then sudo docker run -it --rm -p 8000:8000 opensecurity/mobile-security-framework-mobsf:latest else # If no arguments or invalid arguments are provided, display usage information usage exit 1 fi

Goodbye message using username and PC name

echo "Goodbye $username from $pc_name!"

sohilshrestha0 avatar May 07 '24 05:05 sohilshrestha0

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

github-actions[bot] avatar May 07 '24 05:05 github-actions[bot]

This is how it works

Screenshot 2024-05-07 110505

sohilshrestha0 avatar May 07 '24 05:05 sohilshrestha0

@sohilshrestha0 Thanks for sharing this. It would be nice if you can write a blog or a Github Gist about this and link it in https://github.com/MobSF/docs/blob/master/extras.md

Github issues are strictly for tracking bugs and this will get burried in the list of issues. I am closing this.

ajinabraham avatar May 20 '24 17:05 ajinabraham

sure i will write and link it soon

sohilshrestha0 avatar May 24 '24 16:05 sohilshrestha0