From cb9cd6d365246772bb5f2f1b9c0152fc0af51ee5 Mon Sep 17 00:00:00 2001 From: peterpt <7487321+peterpt@users.noreply.github.com> Date: Fri, 4 Oct 2019 17:45:59 -0400 Subject: [PATCH] More variables fix A lot of work must be done in all scripts . Basically according to shellcheck "Double quote to prevent globbing and word splitting." ;) --- fatrat | 158 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/fatrat b/fatrat index 675387e..67be1ab 100755 --- a/fatrat +++ b/fatrat @@ -34,16 +34,16 @@ orange='\e[38;5;166m' lnx="Linux" lsb_release -i > temp/distro.tmp lsb_release -c > temp/codename.tmp -rlname=`awk '{print $2}' temp/codename.tmp` -dist=`awk '{print $3}' temp/distro.tmp` -dist1=`awk '{print $4}' temp/distro.tmp` +rlname=$(awk '{print $2}' temp/codename.tmp) +dist=$(awk '{print $3}' temp/distro.tmp) +dist1=$(awk '{print $4}' temp/distro.tmp) rm -f temp/codename.tmp >/dev/null rm -f temp/distro.tmp >/dev/null -if [ "$dist" == "$lnx" ]; +if [[ "$dist" == "$lnx" ]]; then -dist0=$dist1 +dist0="$dist1" else -dist0=$dist +dist0="$dist" fi #SAMARAN TAMPAN @@ -111,8 +111,8 @@ exit 0 fi codename=Whistle OS=`uname` # -distro=$dist0 -disrov=$rlname +distro="$dist0" +disrov="$rlname" SERVICE=service; apkembed='tools/apkembed.rb' # exec script path pwned='python tools/pw_exec.py' @@ -139,10 +139,10 @@ grab="config/grab.conf" meterp="${path}/temp/meterpreter.rc" outf="app_backdoor.apk" msploit="${path}/logs/msploit.log" -lanip=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'` -lanip6=`ip addr | grep 'state UP' -A4 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'` -publicip=`dig +short myip.opendns.com @resolver1.opendns.com` -hostn=`host $publicip | awk '{print $5}' | sed 's/.$//'` +lanip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') +lanip6=$(ip addr | grep 'state UP' -A4 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') +publicip=$(dig +short myip.opendns.com @resolver1.opendns.com) +hostn=$(host "$publicip" | awk '{print $5}' | sed 's/.$//') list="${path}/config/listeners" log="${path}/logs/apk-old.log" pwind="${path}/logs/pwind.log" @@ -180,71 +180,71 @@ spinlong2 () } # Check if configuration file for grab script exists in /config folder # Case grab config does not exist then create a default config with 60 seconds -if [ ! -f $grab ] +if [[ ! -f "$grab" ]] then -echo "------------------------------------------------------------" > $grab -echo "| Timeout configuration for Msfconsole file Grabber Script |" >> $grab -echo "------------------------------------------------------------" >> $grab -echo "60" >> $grab +echo "------------------------------------------------------------" > "$grab" +echo "| Timeout configuration for Msfconsole file Grabber Script |" >> "$grab" +echo "------------------------------------------------------------" >> "$grab" +echo "60" >> "$grab" fi # Default Local Host & Port file creation function function confdefault () { clear -confd=$path/config/conf.def -if [ -f "$confd" ] +confd="$path/config/conf.def" +if [[ -f "$confd" ]] then clear -echo -e $okegreen " " +echo -e "$okegreen"" " echo "Fatrat detected that exists a default config file with the following values :" echo "" -lh=`sed -n 1p $confd` -lp=`sed -n 2p $confd` +lh=$(sed -n 1p "$confd") +lp=$(sed -n 2p "$confd")` echo "LHOST : $lh " echo "LPORT : $lp " echo "" read -rsp $'Press [ENTER] key go to options menu \n' -n 1 key echo "" -echo -e $okegreen "Select one of the options bellow" +echo -e "$okegreen" "Select one of the options bellow" echo "" -echo -e $orange "+---------------------------------+" -echo -e $orange "|$white [$okegreen 1$white ]$yellow Change current config$orange |" -echo -e $orange "|$white [$okegreen 2$white ]$yellow Delete configuration file$orange |" -echo -e $orange "|$white [$okegreen 3$white ]$yellow Cancel$orange |" -echo -e $orange "+---------------------------------+" +echo -e "$orange" "+---------------------------------+" +echo -e "$orange" "|$white [$okegreen 1$white ]$yellow Change current config$orange |" +echo -e "$orange" "|$white [$okegreen 2$white ]$yellow Delete configuration file$orange |" +echo -e "$orange" "|$white [$okegreen 3$white ]$yellow Cancel$orange |" +echo -e "$orange" "+---------------------------------+" echo "" -echo -ne $okegreen "Option : ";tput sgr0 +echo -ne "$okegreen" "Option : ";tput sgr0 read con echo "" -case $con in +case "$con" in 1) -confd=$path/config/conf.def -rm -rf $confd -touch $confd +confd="$path/config/conf.def" +rm -rf "$confd" +touch "$confd" clear echo "" -echo -e $okegreen "Write Lhost value$yellow (ex: 192.168.1.1 or mydomain.com)" -echo -ne $okegreen "LHOST : ";tput sgr0 +echo -e "$okegreen" "Write Lhost value$yellow (ex: 192.168.1.1 or mydomain.com)" +echo -ne "$okegreen" "LHOST : ";tput sgr0 read val -if [ -z $val ] +if [[ -z "$val" ]] then confdefault else -echo $val > $confd +echo "$val" > "$confd" fi echo "" -echo -e $okegreen "Write Lport value$yellow (Must be a port between 1 & 65535)" +echo -e "$okegreen" "Write Lport value$yellow (Must be a port between 1 & 65535)" echo -ne "LPORT : ";tput sgr0 read val -if [ -z $val ] +if [[ -z "$val" ]] then confdefault else -echo $val >> $confd +echo "$val" >> "$confd" fi -echo -e $okegreen "" +echo -e "$okegreen" "" read -rsp $'Configuration created , restart fatrat , Press [ENTER] key to exit fatrat \n' -n 1 key clear exit 0 @@ -252,8 +252,8 @@ exit 0 ;; 2) clear -echo -e $okegreen "" -rm -rf $confd +echo -e "$okegreen" "" +rm -rf "$confd" echo "Default configuration file was deleted , you will now have to input Lhost & Lport values manually in fatrat options ." echo "" @@ -271,46 +271,46 @@ menu esac else -echo -e $okegreen "" +echo -e "$okegreen" "" echo "No default configuration file detected " read -rsp $'Press [ENTER] key to go to options \n' -n 1 key echo "" clear -echo -e $okegreen "Select one of the options bellow" +echo -e "$okegreen" "Select one of the options bellow" echo "" -echo -e $orange "+---------------------+" -echo -e $orange "|$white [$okegreen 1$white ]$yellow Create config$orange |" -echo -e $orange "|$white [$okegreen 2$white ]$yellow Cancel$orange |" -echo -e $orange "+---------------------+" +echo -e "$orange" "+---------------------+" +echo -e "$orange" "|$white [$okegreen 1$white ]$yellow Create config$orange |" +echo -e "$orange" "|$white [$okegreen 2$white ]$yellow Cancel$orange |" +echo -e "$orange" "+---------------------+" echo "" -echo -ne $okegreen "Option : ";tput sgr0 -read con +echo -ne "$okegreen" "Option : ";tput sgr0 +read -r con echo "" -case $con in +case "$con" in 1) -confd=$path/config/conf.def -touch $confd +confd="$path/config/conf.def" +touch "$confd" echo "" -echo -e $okegreen "Write Lhost value$yellow (ex: 192.168.1.1 or mydomain.com)" -echo -ne $okegreen "LHOST : ";tput sgr0 -read val -if [ -z $val ] +echo -e "$okegreen" "Write Lhost value$yellow (ex: 192.168.1.1 or mydomain.com)" +echo -ne "$okegreen" "LHOST : ";tput sgr0 +read -r val +if [[ -z "$val" ]] then confdefault else -echo $val > $confd +echo "$val" > "$confd" fi echo "" -echo -e $okegreen "Write Lport value$yellow (Must be a port between 1 & 65535)" +echo -e "$okegreen" "Write Lport value$yellow (Must be a port between 1 & 65535)" echo -ne "LPORT : ";tput sgr0 -read val -if [ -z $val ] +read -r val +if [[ -z "$val" ]] then confdefault else -echo $val >> $confd +echo "$val" >> "$confd" fi -echo -e $okegreen "" +echo -e "$okegreen" "" read -rsp $'Configuration created , restart fatrat , Press [ENTER] key to exit fatrat \n' -n 1 key clear exit 0 @@ -320,7 +320,7 @@ clear menu ;; *) -echo -e $red "" +echo -e "$red" "" read -rsp $ "Invalid Option" confdefault ;; @@ -332,28 +332,28 @@ function invalid () { err=0 echo "" -if [ -z "$yourip" ]; then -echo -e $red "" +if [[ -z "$yourip" ]]; then +echo -e "$red" "" echo "[ ! ] You must write an IP or Hostname ." -echo -e $okegreen "" +echo -e "$okegreen" "" echo "IP Example : 192.168.1.34 Domain Example : myhost.com" err=1 fi echo "" -if [ -z "$yourport" ]; then -echo -e $red "" +if [[ -z "$yourport" ]]; then +echo -e "$red" "" echo "[ ! ] You must write a port number between 1 & 65535 ." err=1 fi -if [ -z "$fira" ]; then -echo -e $red "" +if [[ -z "$fira" ]]; then +echo -e "$red" "" echo "[ ! ] You must write a filename ." -echo -e $okegreen "" +echo -e "$okegreen" "" echo "Filename Example : myfile" err=1 fi -echo -e $okegreen "" +echo -e "$okegreen" "" } #Selection of Executable and verify if exists for backdoor-factory function selexe() { @@ -361,14 +361,14 @@ echo "" echo -e $okegreen "Enter the path to your EXE file .(ex: /root/downloads/myfile.exe)" echo "" echo -ne $cyan "Path : ";tput sgr0 - read exef -if [ ! -f $exef ] + read -r exef +if [[ ! -f "$exef" ]] then echo "" -echo -e $red "File does not exist , make sure you write the right path of it ." +echo -e "$red" "File does not exist , make sure you write the right path of it ." echo "" -echo -e $okegreen "Press [ENTER] key to try again ." -read cont +echo -e "$okegreen" "Press [ENTER] key to try again ." +read -r cont selexe fi }