-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
grab.sh
108 lines (90 loc) · 3.3 KB
/
grab.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
#Grab script was build by peterpt exclusively for fatrat 1.9.4
#Grab script waits for a msfconsole script output and then copy that output to a final folder ,
#Grab script will close automatically the msfconsole window generated by fatrat
#closes the active msfconsole terminal automatically and autoclose itself .
#This script cannot work indenpendently from fatrat
#colours variables
cyan='\e[0;36m'
green='\e[0;34m'
okegreen='\033[92m'
lightgreen='\e[1;32m'
white='\e[1;37m'
red='\e[1;31m'
yellow='\e[0;33m'
BlueF='\e[1;34m' #Biru
RESET="\033[00m" #normal
orange='\e[38;5;166m'
path=`pwd` #Set path variable
file=temp/msff #Filename to search in metasploit output folder
conf=config/grab.conf #Maximum time to wait for all process to be done
cvar="config/config.path"
output=$(sed -n 17p ${cvar})
#If timeout configuration file does not exist then abort script
if [ ! -f "$conf" ]; then
echo "Timeout configuration was not found"
echo "Aborting"
exit
else
#timeout configuration file found , read the 4th line
tmo=`sed -n 4p $conf`
fi
#Clean metasploit output folder (in case a previous file with same name was created)
rm -rf $HOME/.msf4/local/* >/dev/null 2>&1
# Look for the name of the file to be search in metasploit output in msff
# msff file will be created by fatrat
if [ -f "$file" ]; then
#msf file exists then read 1st line (filename to search)
var=`sed -n 1p $file`
else
#msf does not exist , abort
exit 1
fi
function outf(){
clear
echo -e $orange "---------------------------------------------------"
echo -e $orange "|$okegreen Grab Script 1.0 (fatrat 1.9.4 edition)$orange |"
echo -e $orange "---------------------------------------------------"
echo -e $okegreen "Second : $sleep - Timeout : $tmo"
echo ""
echo -e $okegreen "Waiting for msfconsole output to be generated in Xterm Window"
#set directory to search for file , and filename
out="$HOME/.msf4/local/$var"
#sleep variable is equal to itself + 1 second
sleep=$((sleep+1))
if [ $sleep == "$tmo" ] ; then
#in case timeout value achieved without any metasploit output file created
#then exits this script
echo "Metasploit did not generated any output or your timeout is short"
pkill -f Microsploit > /dev/null 2>&1
exit 1
fi
#File was created by metasploit , copy it to final destination , kill msfconsole window and auto-close this script
if [ -f $out ]; then
mv $HOME/.msf4/local/$var $output/$var
#Look in active processes a process name "Microsploit" and kill it
pkill -f Microsploit > /dev/null 2>&1
exit 1
else
#metasploit output file was not yet found , wait 1 second
sleep 1
# start again
outf
fi
}
echo -e $orange "---------------------------------------------------"
echo -e $orange "|$okegreen Grab Script 1.0 (fatrat 1.9.4 edition)$orange |"
echo -e $orange "---------------------------------------------------"
echo -e $okegreen " Dont close this window , it will autoclose itself"
echo ""
echo -e $okegreen "Waiting for msfconsole output to be generated in Xterm Window"
echo -e $orange "Max waiting time = $tmo seconds"
#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
if [ -z "$var" ]; then
exit 1
fi
#set sleep variable to 1 second
sleep="1"
#Everything is ok until this point , start loop until timeout
outf