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