Clean Code Grab.sh
This commit is contained in:
parent
8fcc167a4c
commit
cabe4bdf40
47
grab.sh
47
grab.sh
|
@ -23,15 +23,14 @@ file=temp/msff #Filename to search in metasploit output folder
|
||||||
conf=config/grab.conf #Maximum time to wait for all process to be done
|
conf=config/grab.conf #Maximum time to wait for all process to be done
|
||||||
|
|
||||||
#If timeout configuration file does not exist then abort script
|
#If timeout configuration file does not exist then abort script
|
||||||
if [ ! -f "$conf" ]
|
if [ ! -f "$conf" ]; then
|
||||||
then
|
echo "Timeout configuration was not found"
|
||||||
echo "Timeout configuration was not found"
|
echo "Aborting"
|
||||||
echo "Aborting"
|
exit
|
||||||
exit
|
|
||||||
else
|
else
|
||||||
|
|
||||||
#timeout configuration file found , read the 4th line
|
#timeout configuration file found , read the 4th line
|
||||||
tmo=`sed -n 4p $conf`
|
tmo=`sed -n 4p $conf`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Clean metasploit output folder (in case a previous file with same name was created)
|
#Clean metasploit output folder (in case a previous file with same name was created)
|
||||||
|
@ -40,15 +39,15 @@ rm -rf $HOME/.msf4/local/* >/dev/null 2>&1
|
||||||
# Look for the name of the file to be search in metasploit output in msff
|
# Look for the name of the file to be search in metasploit output in msff
|
||||||
# msff file will be created by fatrat
|
# msff file will be created by fatrat
|
||||||
|
|
||||||
if [ -f "$file" ]
|
if [ -f "$file" ]; then
|
||||||
then
|
|
||||||
|
|
||||||
#msff file exists then read 1st line (filename to search)
|
#msf file exists then read 1st line (filename to search)
|
||||||
var=`sed -n 1p $file`
|
var=`sed -n 1p $file`
|
||||||
else
|
else
|
||||||
#msff does not exist , abort
|
#msf does not exist , abort
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function outf(){
|
function outf(){
|
||||||
clear
|
clear
|
||||||
echo -e $orange "---------------------------------------------------"
|
echo -e $orange "---------------------------------------------------"
|
||||||
|
@ -62,24 +61,23 @@ out="$HOME/.msf4/local/$var"
|
||||||
|
|
||||||
#sleep variable is equal to itself + 1 second
|
#sleep variable is equal to itself + 1 second
|
||||||
sleep=$((sleep+1))
|
sleep=$((sleep+1))
|
||||||
if [ $sleep == "$tmo" ]
|
if [ $sleep == "$tmo" ] ; then
|
||||||
then
|
|
||||||
|
|
||||||
#in case timeout value achieved without any metasploit output file created
|
#in case timeout value achieved without any metasploit output file created
|
||||||
#then exits this script
|
#then exits this script
|
||||||
|
|
||||||
echo "Metasploit did not generated any output or your timeout is short"
|
echo "Metasploit did not generated any output or your timeout is short"
|
||||||
pkill -f Microsploit > /dev/null 2>&1
|
pkill -f Microsploit > /dev/null 2>&1
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#File was created by metasploit , copy it to final destination , kill msfconsole window and auto-close this script
|
#File was created by metasploit , copy it to final destination , kill msfconsole window and auto-close this script
|
||||||
if [ -f $out ]; then
|
if [ -f $out ]; then
|
||||||
mv $HOME/.msf4/local/$var $HOME/Fatrat_Generated/$var
|
mv $HOME/.msf4/local/$var $HOME/Fatrat_Generated/$var
|
||||||
|
|
||||||
#Look in active processes a process name "Microsploit" and kill it
|
#Look in active processes a process name "Microsploit" and kill it
|
||||||
pkill -f Microsploit > /dev/null 2>&1
|
pkill -f Microsploit > /dev/null 2>&1
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
|
||||||
#metasploit output file was not yet found , wait 1 second
|
#metasploit output file was not yet found , wait 1 second
|
||||||
|
@ -98,9 +96,8 @@ echo -e $okegreen "Waiting for msfconsole output to be generated in Xterm Window
|
||||||
echo -e $orange "Max waiting time = $tmo seconds"
|
echo -e $orange "Max waiting time = $tmo seconds"
|
||||||
#if the current value from msff is empty then abort this script
|
#if the current value from msff is empty then abort this script
|
||||||
#this will mean that msff file exists but does not have anything written
|
#this will mean that msff file exists but does not have anything written
|
||||||
if [ -z "$var" ]
|
if [ -z "$var" ]; then
|
||||||
then
|
exit 1
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#set sleep variable to 1 second
|
#set sleep variable to 1 second
|
||||||
|
|
Loading…
Reference in New Issue