tpotce/bin/hptest.sh

58 lines
1.1 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."
else
2022-03-21 22:15:58 +00:00
echo "Usage: hptest.sh <[host or ip]>"
2019-05-11 11:29:00 +00:00
exit
fi
}
function fuGETPORTS {
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-21 22:15:58 +00:00
myPORTS=$(for i in $myDOCKERCOMPOSEPORTS; do echo -n "$i,"; done)
2019-05-11 11:29:00 +00:00
echo "$myPORTS"
}
# Main
fuGOTROOT
fuCHECKDEPS
fuCHECKFORARGS
2022-03-21 22:15:58 +00:00
echo "Starting scan ..."
nmap -sV -sC -v -p $(fuGETPORTS) $1
echo "Done."