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
Comments
👋 @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. |
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!"
The text was updated successfully, but these errors were encountered: