tpotce/_deprecated/bin/hptest.sh

69 lines
1.4 KiB
Bash
Raw Normal View History

2019-05-11 11:29:00 +00:00
#!/bin/bash
myHOST="$1"
2022-03-21 22:15:58 +00:00
myPACKAGES="nmap"
myDOCKERCOMPOSEYML="/opt/tpot/etc/tpot.yml"
2019-05-11 11:29:00 +00:00
function fuGOTROOT {
myWHOAMI=$(whoami)
if [ "$myWHOAMI" != "root" ]
then
echo "Need to run as root ..."
exit
fi
}
function fuCHECKDEPS {
myINST=""
for myDEPS in $myPACKAGES;
do
myOK=$(dpkg -s $myDEPS | grep ok | awk '{ print $3 }');
if [ "$myOK" != "ok" ]
then
myINST=$(echo $myINST $myDEPS)
fi
done
if [ "$myINST" != "" ]
then
apt-get update -y
for myDEPS in $myINST;
do
apt-get install $myDEPS -y
done
fi
}
function fuCHECKFORARGS {
if [ "$myHOST" != "" ];
then
echo "All arguments met. Continuing."
2022-03-22 13:51:05 +00:00
echo
2019-05-11 11:29:00 +00:00
else
2022-03-21 22:15:58 +00:00
echo "Usage: hptest.sh <[host or ip]>"
2022-03-22 13:51:05 +00:00
echo
2019-05-11 11:29:00 +00:00
exit
fi
}
function fuGETPORTS {
2022-03-22 13:51:05 +00:00
myDOCKERCOMPOSEUDPPORTS=$(cat $myDOCKERCOMPOSEYML | grep "udp" | tr -d '"\|#\-' | cut -d ":" -f2 | cut -d "/" -f1 | sort -gu)
2019-05-11 11:29:00 +00:00
myDOCKERCOMPOSEPORTS=$(cat $myDOCKERCOMPOSEYML | yq -r '.services[].ports' | grep ':' | sed -e s/127.0.0.1// | tr -d '", ' | sed -e s/^:// | cut -f1 -d ':' | grep -v "6429\|6430" | sort -gu)
2022-03-22 13:51:05 +00:00
myUDPPORTS=$(for i in $myDOCKERCOMPOSEUDPPORTS; do echo -n "U:$i,"; done)
myPORTS=$(for i in $myDOCKERCOMPOSEPORTS; do echo -n "T:$i,"; done)
2019-05-11 11:29:00 +00:00
}
# Main
2022-03-22 13:51:05 +00:00
fuGETPORTS
2019-05-11 11:29:00 +00:00
fuGOTROOT
fuCHECKDEPS
fuCHECKFORARGS
2022-03-22 13:51:05 +00:00
echo
echo "Starting scan on all UDP / TCP ports defined in /opt/tpot/etc/tpot.yml ..."
nmap -sV -sC -v -p $myPORTS $1 &
nmap -sU -sV -sC -v -p $myUDPPORTS $1 &
echo
wait
echo "Done."
echo