2014-08-06 11:43:40 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
GREEN="\\033[1;32m"
|
|
|
|
DEFAULT="\\033[0;39m"
|
|
|
|
RED="\\033[1;31m"
|
|
|
|
ROSE="\\033[1;35m"
|
|
|
|
BLUE="\\033[1;34m"
|
|
|
|
WHITE="\\033[0;02m"
|
|
|
|
YELLOW="\\033[1;33m"
|
|
|
|
CYAN="\\033[1;36m"
|
|
|
|
|
2014-08-22 14:52:02 +02:00
|
|
|
[ -z "$AIL_HOME" ] && echo "Needs the env var AIL_HOME. Run the script from the virtual environment." && exit 1;
|
|
|
|
[ -z "$AIL_REDIS" ] && echo "Needs the env var AIL_REDIS. Run the script from the virtual environment." && exit 1;
|
|
|
|
[ -z "$AIL_LEVELDB" ] && echo "Needs the env var AIL_LEVELDB. Run the script from the virtual environment." && exit 1;
|
|
|
|
|
|
|
|
export PATH=$AIL_HOME:$PATH
|
|
|
|
export PATH=$AIL_REDIS:$PATH
|
|
|
|
export PATH=$AIL_LEVELDB:$PATH
|
2014-08-06 11:43:40 +02:00
|
|
|
|
|
|
|
function helptext {
|
|
|
|
echo -e $YELLOW"
|
|
|
|
|
|
|
|
.o. ooooo ooooo
|
|
|
|
.888. \`888' \`888'
|
|
|
|
.8\"888. 888 888
|
|
|
|
.8' \`888. 888 888
|
|
|
|
.88ooo8888. 888 888
|
|
|
|
.8' \`888. 888 888 o
|
|
|
|
o88o o8888o o o888o o o888ooooood8
|
|
|
|
|
|
|
|
Analysis Information Leak framework
|
|
|
|
"$DEFAULT"
|
|
|
|
This script launch:
|
|
|
|
"$CYAN"
|
|
|
|
- All the ZMQ queuing modules.
|
|
|
|
- All the ZMQ processing modules.
|
|
|
|
- All Redis in memory servers.
|
|
|
|
- All Level-DB on disk servers.
|
|
|
|
"$DEFAULT"
|
|
|
|
(Inside screen Daemons)
|
|
|
|
"$RED"
|
|
|
|
But first of all you'll need to edit few path where you installed
|
|
|
|
your redis & leveldb servers.
|
|
|
|
"$DEFAULT"
|
|
|
|
Usage:
|
|
|
|
-----
|
|
|
|
"
|
|
|
|
}
|
|
|
|
|
|
|
|
function launching_redis {
|
2014-08-22 14:52:02 +02:00
|
|
|
conf_dir="${AIL_HOME}/configs/"
|
2014-08-06 11:43:40 +02:00
|
|
|
|
2017-09-26 16:17:06 +02:00
|
|
|
screen -dmS "Redis_AIL"
|
2014-08-06 11:43:40 +02:00
|
|
|
sleep 0.1
|
|
|
|
echo -e $GREEN"\t* Launching Redis servers"$DEFAULT
|
2017-09-26 16:17:06 +02:00
|
|
|
screen -S "Redis_AIL" -X screen -t "6379" bash -c 'redis-server '$conf_dir'6379.conf ; read x'
|
2014-08-06 11:43:40 +02:00
|
|
|
sleep 0.1
|
2017-09-26 16:17:06 +02:00
|
|
|
screen -S "Redis_AIL" -X screen -t "6380" bash -c 'redis-server '$conf_dir'6380.conf ; read x'
|
2014-08-06 11:43:40 +02:00
|
|
|
sleep 0.1
|
2017-09-26 16:17:06 +02:00
|
|
|
screen -S "Redis_AIL" -X screen -t "6381" bash -c 'redis-server '$conf_dir'6381.conf ; read x'
|
2016-08-18 15:34:19 +02:00
|
|
|
|
|
|
|
# For Words and curves
|
|
|
|
sleep 0.1
|
2017-09-26 16:17:06 +02:00
|
|
|
screen -S "Redis_AIL" -X screen -t "6382" bash -c 'redis-server '$conf_dir'6382.conf ; read x'
|
2014-08-06 11:43:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function launching_lvldb {
|
|
|
|
lvdbhost='127.0.0.1'
|
2014-08-22 14:52:02 +02:00
|
|
|
lvdbdir="${AIL_HOME}/LEVEL_DB_DATA/"
|
2014-08-06 11:43:40 +02:00
|
|
|
nb_db=13
|
|
|
|
|
2017-08-23 10:16:56 +02:00
|
|
|
db_y=`date +%Y`
|
|
|
|
#Verify that a dir with the correct year exists, create it otherwise
|
|
|
|
if [ ! -d "$lvdbdir$db_y" ]; then
|
|
|
|
mkdir -p "$db_y"
|
|
|
|
fi
|
|
|
|
|
2017-09-26 16:17:06 +02:00
|
|
|
screen -dmS "LevelDB_AIL"
|
2014-08-06 11:43:40 +02:00
|
|
|
sleep 0.1
|
|
|
|
echo -e $GREEN"\t* Launching Levels DB servers"$DEFAULT
|
2016-08-09 11:59:36 +02:00
|
|
|
|
2017-08-23 10:16:56 +02:00
|
|
|
#Launch a DB for each dir
|
|
|
|
for pathDir in $lvdbdir*/ ; do
|
|
|
|
yDir=$(basename "$pathDir")
|
|
|
|
sleep 0.1
|
2018-04-11 10:48:22 +02:00
|
|
|
screen -S "LevelDB_AIL" -X screen -t "$yDir" bash -c 'redis-leveldb -h; redis-leveldb -H '$lvdbhost' -D '$pathDir' -P '$yDir' -M '$nb_db'; read x'
|
2017-08-23 10:16:56 +02:00
|
|
|
done
|
2014-08-06 11:43:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function launching_logs {
|
2017-09-26 16:17:06 +02:00
|
|
|
screen -dmS "Logging_AIL"
|
2014-08-06 11:43:40 +02:00
|
|
|
sleep 0.1
|
|
|
|
echo -e $GREEN"\t* Launching logging process"$DEFAULT
|
2017-09-26 16:17:06 +02:00
|
|
|
screen -S "Logging_AIL" -X screen -t "LogQueue" bash -c 'log_subscriber -p 6380 -c Queuing -l ../logs/; read x'
|
2014-08-06 11:43:40 +02:00
|
|
|
sleep 0.1
|
2017-09-26 16:17:06 +02:00
|
|
|
screen -S "Logging_AIL" -X screen -t "LogScript" bash -c 'log_subscriber -p 6380 -c Script -l ../logs/; read x'
|
2014-08-06 11:43:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function launching_queues {
|
2017-09-26 16:17:06 +02:00
|
|
|
screen -dmS "Queue_AIL"
|
2014-08-06 11:43:40 +02:00
|
|
|
sleep 0.1
|
|
|
|
|
2014-09-02 15:21:36 +02:00
|
|
|
echo -e $GREEN"\t* Launching all the queues"$DEFAULT
|
2018-04-11 10:48:22 +02:00
|
|
|
screen -S "Queue_AIL" -X screen -t "Queues" bash -c 'python3 launch_queues.py; read x'
|
2014-08-06 11:43:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function launching_scripts {
|
2017-04-25 09:32:05 +02:00
|
|
|
echo -e "\t* Checking configuration"
|
2018-04-11 10:48:22 +02:00
|
|
|
bash -c "python3 Update-conf.py"
|
2017-04-25 09:32:05 +02:00
|
|
|
exitStatus=$?
|
|
|
|
if [ $exitStatus -ge 1 ]; then
|
|
|
|
echo -e $RED"\t* Configuration not up-to-date"$DEFAULT
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
echo -e $GREEN"\t* Configuration up-to-date"$DEFAULT
|
|
|
|
|
2017-09-26 16:17:06 +02:00
|
|
|
screen -dmS "Script_AIL"
|
2014-08-06 11:43:40 +02:00
|
|
|
sleep 0.1
|
|
|
|
echo -e $GREEN"\t* Launching ZMQ scripts"$DEFAULT
|
|
|
|
|
2018-04-11 10:48:22 +02:00
|
|
|
screen -S "Script_AIL" -X screen -t "ModuleInformation" bash -c 'python3 ModulesInformationV2.py -k 0 -c 1; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "Mixer" bash -c 'python3 Mixer.py; read x'
|
|
|
|
sleep 0.1
|
2018-04-12 17:06:57 +02:00
|
|
|
screen -S "Script_AIL" -X screen -t "Global" bash -c 'python3 Global.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "Duplicates" bash -c 'python3 Duplicates.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "Attributes" bash -c 'python3 Attributes.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "Lines" bash -c 'python3 Lines.py; read x'
|
|
|
|
sleep 0.1
|
2018-04-16 14:50:04 +02:00
|
|
|
screen -S "Script_AIL" -X screen -t "DomClassifier" bash -c './DomClassifier.py; read x'
|
|
|
|
sleep 0.1
|
2018-04-12 17:06:57 +02:00
|
|
|
screen -S "Script_AIL" -X screen -t "Categ" bash -c 'python3 Categ.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "Tokenize" bash -c 'python3 Tokenize.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "CreditCards" bash -c 'python3 CreditCards.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "Onion" bash -c './Onion.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "Mail" bash -c './Mail.py; read x'
|
|
|
|
sleep 0.1
|
2018-04-20 10:48:44 +02:00
|
|
|
#screen -S "Script_AIL" -X screen -t "Dox" bash -c './Dox.py; read x'
|
|
|
|
sleep 0.1
|
2018-04-16 14:50:04 +02:00
|
|
|
screen -S "Script_AIL" -X screen -t "Web" bash -c './Web.py; read x'
|
|
|
|
sleep 0.1
|
2018-04-12 17:06:57 +02:00
|
|
|
screen -S "Script_AIL" -X screen -t "Credential" bash -c './Credential.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "Curve" bash -c './Curve.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "CurveManageTopSets" bash -c './CurveManageTopSets.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "RegexForTermsFrequency" bash -c './RegexForTermsFrequency.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "SetForTermsFrequency" bash -c './SetForTermsFrequency.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "Indexer" bash -c './Indexer.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "Keys" bash -c './Keys.py; read x'
|
|
|
|
sleep 0.1
|
2018-04-20 10:48:44 +02:00
|
|
|
screen -S "Script_AIL" -X screen -t "Base64" bash -c './Base64.py; read x'
|
|
|
|
sleep 0.1
|
2018-04-12 17:06:57 +02:00
|
|
|
screen -S "Script_AIL" -X screen -t "Phone" bash -c './Phone.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "Release" bash -c './Release.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "Cve" bash -c './Cve.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "WebStats" bash -c './WebStats.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "ModuleStats" bash -c './ModuleStats.py; read x'
|
|
|
|
sleep 0.1
|
2018-04-16 14:50:04 +02:00
|
|
|
screen -S "Script_AIL" -X screen -t "SQLInjectionDetection" bash -c './SQLInjectionDetection.py; read x'
|
|
|
|
sleep 0.1
|
2018-04-12 17:06:57 +02:00
|
|
|
screen -S "Script_AIL" -X screen -t "alertHandler" bash -c './alertHandler.py; read x'
|
|
|
|
sleep 0.1
|
|
|
|
screen -S "Script_AIL" -X screen -t "SentimentAnalysis" bash -c './SentimentAnalysis.py; read x'
|
2016-08-19 13:34:02 +02:00
|
|
|
|
2014-08-06 11:43:40 +02:00
|
|
|
}
|
|
|
|
|
2017-09-26 16:17:06 +02:00
|
|
|
function shutting_down_redis {
|
|
|
|
redis_dir=${AIL_HOME}/redis/src/
|
|
|
|
bash -c $redis_dir'redis-cli -p 6379 SHUTDOWN'
|
|
|
|
sleep 0.1
|
|
|
|
bash -c $redis_dir'redis-cli -p 6380 SHUTDOWN'
|
|
|
|
sleep 0.1
|
|
|
|
bash -c $redis_dir'redis-cli -p 6381 SHUTDOWN'
|
|
|
|
sleep 0.1
|
|
|
|
bash -c $redis_dir'redis-cli -p 6382 SHUTDOWN'
|
|
|
|
}
|
|
|
|
|
|
|
|
function checking_redis {
|
|
|
|
flag_redis=0
|
|
|
|
redis_dir=${AIL_HOME}/redis/src/
|
|
|
|
bash -c $redis_dir'redis-cli -p 6379 PING | grep "PONG" &> /dev/null'
|
|
|
|
if [ ! $? == 0 ]; then
|
|
|
|
echo -e $RED"\t6379 not ready"$DEFAULT
|
|
|
|
flag_redis=1
|
|
|
|
fi
|
|
|
|
sleep 0.1
|
|
|
|
bash -c $redis_dir'redis-cli -p 6380 PING | grep "PONG" &> /dev/null'
|
|
|
|
if [ ! $? == 0 ]; then
|
|
|
|
echo -e $RED"\t6380 not ready"$DEFAULT
|
|
|
|
flag_redis=1
|
|
|
|
fi
|
|
|
|
sleep 0.1
|
|
|
|
bash -c $redis_dir'redis-cli -p 6381 PING | grep "PONG" &> /dev/null'
|
|
|
|
if [ ! $? == 0 ]; then
|
|
|
|
echo -e $RED"\t6381 not ready"$DEFAULT
|
|
|
|
flag_redis=1
|
|
|
|
fi
|
|
|
|
sleep 0.1
|
|
|
|
bash -c $redis_dir'redis-cli -p 6382 PING | grep "PONG" &> /dev/null'
|
|
|
|
if [ ! $? == 0 ]; then
|
|
|
|
echo -e $RED"\t6382 not ready"$DEFAULT
|
|
|
|
flag_redis=1
|
|
|
|
fi
|
|
|
|
return $flag_redis;
|
|
|
|
}
|
|
|
|
|
2014-08-06 11:43:40 +02:00
|
|
|
#If no params, display the help
|
|
|
|
#[[ $@ ]] || { helptext; exit 1;}
|
|
|
|
|
|
|
|
helptext;
|
|
|
|
|
|
|
|
############### TESTS ###################
|
2017-09-26 16:17:06 +02:00
|
|
|
isredis=`screen -ls | egrep '[0-9]+.Redis_AIL' | cut -d. -f1`
|
|
|
|
islvldb=`screen -ls | egrep '[0-9]+.LevelDB_AIL' | cut -d. -f1`
|
|
|
|
islogged=`screen -ls | egrep '[0-9]+.Logging_AIL' | cut -d. -f1`
|
|
|
|
isqueued=`screen -ls | egrep '[0-9]+.Queue_AIL' | cut -d. -f1`
|
|
|
|
isscripted=`screen -ls | egrep '[0-9]+.Script_AIL' | cut -d. -f1`
|
2014-08-06 11:43:40 +02:00
|
|
|
|
2017-03-15 16:36:51 +01:00
|
|
|
options=("Redis" "LevelDB" "Logs" "Queues" "Scripts" "Killall" "Shutdown" "Update-config")
|
2014-08-06 11:43:40 +02:00
|
|
|
|
|
|
|
menu() {
|
|
|
|
echo "What do you want to Launch?:"
|
|
|
|
for i in ${!options[@]}; do
|
|
|
|
printf "%3d%s) %s\n" $((i+1)) "${choices[i]:- }" "${options[i]}"
|
|
|
|
done
|
|
|
|
[[ "$msg" ]] && echo "$msg"; :
|
|
|
|
}
|
|
|
|
|
|
|
|
prompt="Check an option (again to uncheck, ENTER when done): "
|
2017-11-28 15:15:12 +01:00
|
|
|
while menu && read -rp "$prompt" numinput && [[ "$numinput" ]]; do
|
|
|
|
for num in $numinput; do
|
|
|
|
[[ "$num" != *[![:digit:]]* ]] && (( num > 0 && num <= ${#options[@]} )) || {
|
|
|
|
msg="Invalid option: $num"; break
|
|
|
|
}
|
|
|
|
((num--)); msg="${options[num]} was ${choices[num]:+un}checked"
|
|
|
|
[[ "${choices[num]}" ]] && choices[num]="" || choices[num]="+"
|
|
|
|
done
|
2014-08-06 11:43:40 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
for i in ${!options[@]}; do
|
|
|
|
if [[ "${choices[i]}" ]]; then
|
|
|
|
case ${options[i]} in
|
|
|
|
Redis)
|
|
|
|
if [[ ! $isredis ]]; then
|
|
|
|
launching_redis;
|
|
|
|
else
|
|
|
|
echo -e $RED"\t* A screen is already launched"$DEFAULT
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
LevelDB)
|
|
|
|
if [[ ! $islvldb ]]; then
|
|
|
|
launching_lvldb;
|
|
|
|
else
|
|
|
|
echo -e $RED"\t* A screen is already launched"$DEFAULT
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
Logs)
|
|
|
|
if [[ ! $islogged ]]; then
|
|
|
|
launching_logs;
|
|
|
|
else
|
|
|
|
echo -e $RED"\t* A screen is already launched"$DEFAULT
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
Queues)
|
|
|
|
if [[ ! $isqueued ]]; then
|
|
|
|
launching_queues;
|
|
|
|
else
|
|
|
|
echo -e $RED"\t* A screen is already launched"$DEFAULT
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
Scripts)
|
|
|
|
if [[ ! $isscripted ]]; then
|
2017-09-26 16:17:06 +02:00
|
|
|
if checking_redis; then
|
|
|
|
launching_scripts;
|
|
|
|
else
|
2018-04-11 10:48:22 +02:00
|
|
|
echo -e $YELLOW"\tScript not started, waiting 10 secondes"$DEFAULT
|
|
|
|
sleep 10
|
2017-09-26 16:17:06 +02:00
|
|
|
if checking_redis; then
|
|
|
|
launching_scripts;
|
|
|
|
else
|
|
|
|
echo -e $RED"\tScript not started"$DEFAULT
|
|
|
|
fi;
|
|
|
|
fi;
|
2014-08-06 11:43:40 +02:00
|
|
|
else
|
|
|
|
echo -e $RED"\t* A screen is already launched"$DEFAULT
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
Killall)
|
|
|
|
if [[ $isredis || $islvldb || $islogged || $isqueued || $isscripted ]]; then
|
2017-09-26 16:17:06 +02:00
|
|
|
echo -e $GREEN"Gracefully closing redis servers"$DEFAULT
|
|
|
|
shutting_down_redis;
|
|
|
|
echo -e $GREEN"Killing all"$DEFAULT
|
2014-08-06 11:43:40 +02:00
|
|
|
kill $isredis $islvldb $islogged $isqueued $isscripted
|
2017-08-21 13:54:44 +02:00
|
|
|
sleep 0.2
|
2014-08-06 11:43:40 +02:00
|
|
|
echo -e $ROSE`screen -ls`$DEFAULT
|
|
|
|
echo -e $GREEN"\t* $isredis $islvldb $islogged $isqueued $isscripted killed."$DEFAULT
|
|
|
|
else
|
|
|
|
echo -e $RED"\t* No screen to kill"$DEFAULT
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
Shutdown)
|
|
|
|
bash -c "./Shutdown.py"
|
|
|
|
;;
|
2017-03-15 16:36:51 +01:00
|
|
|
Update-config)
|
2017-04-25 09:32:05 +02:00
|
|
|
echo -e "\t* Checking configuration"
|
2017-03-15 16:36:51 +01:00
|
|
|
bash -c "./Update-conf.py"
|
2017-04-25 09:32:05 +02:00
|
|
|
exitStatus=$?
|
|
|
|
if [ $exitStatus -ge 1 ]; then
|
|
|
|
echo -e $RED"\t* Configuration not up-to-date"$DEFAULT
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
echo -e $GREEN"\t* Configuration up-to-date"$DEFAULT
|
|
|
|
fi
|
2017-03-15 16:36:51 +01:00
|
|
|
;;
|
2014-08-06 11:43:40 +02:00
|
|
|
esac
|
|
|
|
fi
|
|
|
|
done
|