-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d83acb9
commit ebb5b86
Showing
3 changed files
with
88 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,35 @@ | ||
#!/bin/bash | ||
var="$1" | ||
|
||
function validate_ip () { | ||
local IP=$1 | ||
local stat=1 | ||
|
||
if [[ $IP =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | ||
OIFS=$IFS | ||
IFS='.' | ||
ip=($IP) | ||
IFS=$OIFS | ||
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \ | ||
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] | ||
stat=$? | ||
fi | ||
if [ "$stat" -eq 0 ]; then | ||
return $stat | ||
else | ||
echo 'Bad IP' | ||
exit 1 | ||
fi | ||
function validate_ip() { | ||
local IP=$1 | ||
if [[ $IP =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then | ||
for i in ${IP//./ }; do | ||
((i >= 0 && i <= 255)) || { echo 'Bad IP'; exit 1; } | ||
done | ||
else | ||
echo 'Bad IP' | ||
exit 1 | ||
fi | ||
} | ||
|
||
function validate_port () { | ||
local PORT=$1 | ||
if [ -z "$PORT" ]; then | ||
echo 'Port can not be empty' | ||
exit 1 | ||
fi | ||
if [ "$PORT" -gt 1024 ] && [ "$PORT" -lt 65535 ]; then | ||
return 0 | ||
else | ||
echo 'Invalid Port' | ||
exit 1 | ||
fi | ||
function validate_port() { | ||
local PORT=$1 | ||
if [[ -z "$PORT" || "$PORT" -le 1024 || "$PORT" -ge 65535 ]]; then | ||
echo 'Invalid Port' | ||
exit 1 | ||
fi | ||
} | ||
|
||
if [ ! -z "$var" ]; then | ||
IP=$(echo $var | awk -F':' '{print $1}') | ||
PORT=$(echo $var | awk -F':' '{print $2}') | ||
validate_ip $IP | ||
validate_port $PORT | ||
else | ||
if [[ -n "$var" ]]; then | ||
IP="${var%%:*}" | ||
PORT="${var##*:}" | ||
validate_ip "$IP" | ||
validate_port "$PORT" | ||
else | ||
IP='[::]' | ||
PORT='8000' | ||
fi | ||
fi | ||
|
||
python3 -m poetry run gunicorn -b ${IP}:${PORT} mobsf.MobSF.wsgi:application --workers=1 --threads=10 --timeout=3600 \ | ||
--log-level=citical --log-file=- --access-logfile=- --error-logfile=- --capture-output | ||
--log-level=critical --log-file=- --access-logfile=- --error-logfile=- --capture-output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
#!/bin/bash | ||
|
||
echo | ||
echo '=======================MobSF Clean Script for Unix=======================' | ||
echo 'Running this script will delete the Scan database, all files uploaded and generated.' | ||
echo 'Running this script will delete the scan database, all files uploaded and generated.' | ||
|
||
script_path=$(dirname $0) | ||
script_path=$(basename "$(dirname "$0")") | ||
mobsf_home="$HOME/.MobSF" | ||
|
||
if [ "$script_path" != "scripts" ] && [ "$script_path" != "./scripts" ]; then | ||
echo 'Please run script from mobsf.MobSF directory ' | ||
echo './scripts/clean.sh ' | ||
exit 1 | ||
# Ensure the script is run from the correct directory | ||
if [[ "$script_path" != "scripts" ]]; then | ||
echo 'Please run this script from the MobSF directory:' | ||
echo './scripts/clean.sh' | ||
exit 1 | ||
fi | ||
|
||
if [ "$1" != "" ]; then | ||
VAL="$1" | ||
else | ||
read -p 'Continue? (Y/N): ' confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 | ||
# Confirmation prompt | ||
VAL=${1:-} | ||
if [[ -z "$VAL" ]]; then | ||
read -p 'Continue? (Y/N): ' confirm | ||
[[ $confirm =~ ^[yY]([eE][sS])?$ ]] || exit 1 | ||
VAL=$confirm | ||
fi | ||
echo | ||
if [[ $VAL =~ ^[Yy]$ ]] | ||
then | ||
echo 'Deleting all uploads' | ||
rm -rf ./mobsf/uploads/* | ||
echo 'Deleting all downloads' | ||
rm -rf ./mobsf/downloads/* | ||
echo 'Deleting Static Analyzer migrations' | ||
rm -rf ./mobsf/StaticAnalyzer/migrations/* | ||
echo 'Deleting Dynamic Analyzer migrations' | ||
rm -rf ./mobsf/DynamicAnalyzer/migrations/* | ||
echo 'Deleting MobSF migrations' | ||
rm -rf ./mobsf/MobSF/migrations/* | ||
echo 'Deleting Python byte code files' | ||
find ./ -name "*.pyc" -exec rm -rf {} \; | ||
find ./ | grep -E "(__pycache__|\.pyo$)" | xargs rm -rf | ||
echo 'Deleting temp and log files' | ||
rm -rf ./mobsf/debug.log | ||
rm -rf ./classes* | ||
echo 'Deleting Scan database' | ||
rm -rf ./mobsf/db.sqlite3 | ||
echo 'Deleting Secret file' | ||
rm -rf ./mobsf/secret | ||
echo "Deleting MobSF data directory: $mobsf_home" | ||
rm -rf $mobsf_home | ||
echo 'Done' | ||
|
||
echo | ||
if [[ "$VAL" =~ ^[yY]$ ]]; then | ||
echo 'Cleaning up MobSF directories and files...' | ||
|
||
# Remove files from key directories | ||
rm -rf ./mobsf/{uploads,downloads,StaticAnalyzer/migrations,DynamicAnalyzer/migrations,MobSF/migrations}/* | ||
|
||
echo 'Removing Python bytecode and cache files' | ||
find ./ -type f -name "*.pyc" -o -name "*.pyo" -delete | ||
find ./ -type d -name "__pycache__" -exec rm -rf {} + | ||
|
||
# Remove temporary, log, and database files | ||
echo 'Deleting temporary, log, and database files' | ||
rm -f ./mobsf/debug.log ./classes* ./mobsf/db.sqlite3 ./mobsf/secret | ||
|
||
# Remove the MobSF data directory if it exists | ||
if [[ -d "$mobsf_home" ]]; then | ||
echo "Deleting MobSF data directory: $mobsf_home" | ||
rm -rf "$mobsf_home" | ||
fi | ||
|
||
echo 'Cleanup complete.' | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters