Skip to content

Commit

Permalink
1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpt committed Jul 19, 2017
1 parent 90ed4e5 commit 8d74613
Showing 1 changed file with 43 additions and 8 deletions.
51 changes: 43 additions & 8 deletions escan
Expand Up @@ -17,12 +17,15 @@ pkill -f masscan* > /dev/null 2>&1
fi
}

#setup colors
cyan='\e[0;36m'
green='\033[92m'
red='\e[1;31m'
yellow='\e[0;33m'
orange='\e[38;5;166m'
path=`pwd`

#Check dependencies
which msfconsole > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
echo
Expand All @@ -49,13 +52,15 @@ echo -e $green " ▐█ ▀. ▐█ ▌▪▐█ ▀█ •█▌▐█•█▌
echo -e $green " ▄▀▀▀█▄██ ▄▄▄█▀▀█ ▐█▐▐▌▐█▐▐▌▐▀▀▪▄▐▀▀▄ "
echo -e $green " ▐█▄▪▐█▐███▌▐█ ▪▐▌██▐█▌██▐█▌▐█▄▄▌▐█•█▌ "
echo -e $green " ▀▀▀▀ ·▀▀▀ ▀ ▀ ▀▀ █▪▀▀ █▪ ▀▀▀ .▀ ▀$yellow 1.0"

echo ""
#echo -e $orange "For switches write ./escan -h"
rm -f masscan >/dev/null 2>&1
rm -f msfip >/dev/null 2>&1
rm -f msf.rc >/dev/null 2>&1
rm -f msflog.logs >/dev/null 2>&1
rm -f paused.conf >/dev/null 2>&1
rm -f nohup.out >/dev/null 2>&1
rm -f tmp.txt >/dev/null 2>&1
rm -f tmp1.txt >/dev/null 2>&1
mass=$path/masscan
echo ""
echo -e $orange "Enter IP or IP range to scan ex: 192.168.1.32 or 192.168.1.1/24"
Expand All @@ -73,14 +78,14 @@ if [ $ip == $val ]
then
echo -e $cyan "Scanning the whole internet will take hours to finish"
echo ""
echo -ne $green "Do you still want to continue ? (y/N)";tput sgr0
echo -ne $green "Do you still want to continue ? (y/N) : ";tput sgr0
read opt
echo ""
case $opt in
y|Y|yes|YES|Yes)
echo -e $green "Press CRTL-C if you want to stop the scanner "
echo ""
echo -e "\033[33;7mScanning Please Wait\033[0m"
echo -e "\033[33;7mScanning $ip , Please Wait\033[0m"
stat="1"
masscan $ip -p 445 --exclude 255.255.255.255 --output-filename $mass >/dev/null 2>&1
;;
Expand All @@ -99,18 +104,26 @@ stat="1"
masscan $ip -p 445 --output-filename $mass >/dev/null 2>&1
fi
echo ""

#Check if masscan created an output file
if [ ! -f "$mass" ]
then
echo -e $yellow "Scanner results not found"
exit 1
fi

#parser masscan output and grab only the ips
cat $mass | grep 'addr=' | awk '{print $3}' | sed -e s/addr=//g | cut -d '"' -f 2 | tr " " "\n" >msfip
msfips=$path/msfip

#check if there was any ip detected with port 445 opened
if [ ! -s $msfips ]
then
echo -e $yellow "Scanner did not detect any host on this $ip with port 445 opened."
exit 1
fi

#metasploit execution script
echo "spool $path/msflog.logs" > msf.rc
echo "use auxiliary/scanner/smb/smb_ms17_010" >> msf.rc
paste -sd, msfip \
Expand All @@ -136,26 +149,48 @@ echo ""
echo -e "\033[33;7mPlease Wait , checking $lc ips may take a while\033[0m"
msfconsole -r $path/msf.rc >/dev/null 2>&1
vuln=`cat msflog.logs | grep "MS17-010" | awk '{print$2}'`

#Check if msf logs got any positive result
if [ -z $vuln ]
then
echo ""
echo -e $red "No vulnerable targets were found on : $ip range"
else
op=$path/vuln.txt

#Check if vulnerability list file exists in ES
if [ -f $op ]; then
echo $vuln > $path/temp.txt
tr " " "\n" <$path/temp.txt >temp1.txt

#Write new detections to last line in vuln.txt
tr " " "\n" <$path/temp.txt >>vuln.txt

else
echo $vuln > $path/temp.txt
tr " " "\n" <$path/temp.txt >temp1.txt

#no vuln. file exists , create a new one
echo "Vulnerable Ips to Eternal Blue exploit (MS17-010) - Scanned by Eternal Scanner" > $op
echo "------------------------------------------------------------------------------" >> $op
echo $vuln > $path/temp.txt
tr " " "\n" <$path/temp.txt >>vuln.txt
fi
lm=`cat $path/temp.txt | wc -l`
rm -f $path/temp.txt >/dev/null 2>&1

# count number of lines in file
lm=`cat $path/temp1.txt | wc -l`
echo ""
echo -e $green "$lm Vulnerable ips found"
echo $vuln
echo "---------------------------------------"
cat $path/temp1.txt
echo "---------------------------------------"
echo -e $yellow "Eternal Scanner saved a file with vulnerable ips to $path/vuln.txt"

#Delete temp files
rm -f temp1.txt >/dev/null 2>&1
rm -f temp.txt >/dev/null 2>&1
rm -f masscan >/dev/null 2>&1
rm -f msfip >/dev/null 2>&1
rm -f msf.rc >/dev/null 2>&1
rm -f msflog.logs >/dev/null 2>&1
rm -f paused.conf >/dev/null 2>&1
fi

0 comments on commit 8d74613

Please sign in to comment.