Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run MobSF through command [FEATURE] #2386

Closed
sohilshrestha0 opened this issue May 7, 2024 · 3 comments
Closed

Run MobSF through command [FEATURE] #2386

sohilshrestha0 opened this issue May 7, 2024 · 3 comments
Assignees
Labels
enhancement MobSF enhancements and feature requests

Comments

@sohilshrestha0
Copy link

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 sohilshrestha0 added the enhancement MobSF enhancements and feature requests label May 7, 2024
Copy link

github-actions bot commented May 7, 2024

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

@sohilshrestha0
Copy link
Author

This is how it works

Screenshot 2024-05-07 110505

@ajinabraham
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement MobSF enhancements and feature requests
Projects
None yet
Development

No branches or pull requests

2 participants