2018-05-02 12:50:31 -06:00
|
|
|
#!/usr/bin/env bash
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-08-22 13:23:08 -06:00
|
|
|
if [ "$HashUtilsVersion" ]; then return 0; fi
|
|
|
|
readonly HashUtilsVersion="1.0"
|
2017-08-08 11:40:32 -06:00
|
|
|
|
|
|
|
HashOutputDevice="/dev/stdout"
|
|
|
|
|
|
|
|
function hash_check_handshake() {
|
2018-01-06 21:21:37 -07:00
|
|
|
local -r handshakeVerifier=$1
|
|
|
|
local -r handshakePath=$2
|
|
|
|
local -r handshakeAPSSID=$3
|
|
|
|
local -r handshakeAPMAC=$4
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2018-01-17 22:22:03 -07:00
|
|
|
echo "Verifier Parameters: " > $HashOutputDevice
|
|
|
|
echo " Verifier: $handshakeVerifier" > $HashOutputDevice
|
|
|
|
echo "Hash Path: $handshakePath" > $HashOutputDevice
|
|
|
|
echo "Hash SSID: \"$handshakeAPSSID\"" > $HashOutputDevice
|
|
|
|
echo " Hash MAC: $handshakeAPMAC" > $HashOutputDevice
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
local analysis # Since it's being used in all relevant instances.
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
case "$handshakeVerifier" in
|
2018-01-06 21:21:37 -07:00
|
|
|
"pyrit")
|
|
|
|
readarray analysis < <(pyrit -r "$handshakePath" analyze 2> $HashOutputDevice)
|
|
|
|
if [ "${#analysis[@]}" -eq 0 -o $? != 0 ]; then
|
|
|
|
echo "Error: pyrit seems to be broken!" > $HashOutputDevice
|
|
|
|
return 1
|
|
|
|
fi
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
local hashMeta=$(echo "${analysis[@]}" | grep -F "AccessPoint ${handshakeAPMAC,,} ('$handshakeAPSSID')")
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
if [ "$hashMeta" ]; then
|
|
|
|
local hashID=$(echo "$hashMeta" | awk -F'[ #:]' '{print $3}')
|
2018-01-17 22:22:03 -07:00
|
|
|
local hashData=$(echo "${analysis[@]}" | awk "\$0~/#$hashID: HMAC_(SHA[0-9]+_AES|MD5_RC4)/{ print \$0 }")
|
2018-01-06 21:21:37 -07:00
|
|
|
else
|
|
|
|
echo "No valid hash meta was found for \"$handshakeAPSSID\"" > $HashOutputDevice
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"aircrack-ng")
|
|
|
|
readarray analysis < <(aircrack-ng "$handshakePath" 2> $HashOutputDevice)
|
|
|
|
if [ "${#analysis[@]}" -eq 0 -o $? != 0 ]; then
|
|
|
|
echo "Error: aircrack-ng seems to be broken!" > $HashOutputDevice
|
|
|
|
return 1
|
|
|
|
fi
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2018-01-06 21:21:37 -07:00
|
|
|
local hashData=$(echo "${analysis[@]}" | grep -E "${handshakeAPMAC^^}\s+" | grep -F "$handshakeAPSSID")
|
|
|
|
;;
|
2018-05-02 18:50:28 -06:00
|
|
|
"cowpatty")
|
|
|
|
readarray analysis < <(aircrack-ng "$handshakePath" 2> $HashOutputDevice)
|
|
|
|
if [ "${#analysis[@]}" -eq 0 -o $? != 0 ]; then
|
|
|
|
echo "Error: cowpatty (aircrack-ng) seems to be broken!" > $HashOutputDevice
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if echo "${analysis[@]}" | grep -E "${handshakeAPMAC^^}\s+" | grep -qF "$handshakeAPSSID"; then
|
|
|
|
local hashData=$(cowpatty -cr "$handshakePath")
|
|
|
|
fi
|
|
|
|
;;
|
2018-01-06 21:21:37 -07:00
|
|
|
*)
|
|
|
|
echo "Invalid verifier, quitting!" > $HashOutputDevice
|
|
|
|
return 1
|
|
|
|
;;
|
2017-12-31 09:02:12 -07:00
|
|
|
esac
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
if [ -z "$hashData" ]; then
|
|
|
|
echo "Handshake for $handshakeAPSSID ($handshakeAPMAC) is missing!"
|
|
|
|
return 1
|
|
|
|
fi
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
case "$handshakeVerifier" in
|
2018-01-06 21:21:37 -07:00
|
|
|
"pyrit")
|
|
|
|
if echo "$hashData" | grep -qF "good"; then
|
|
|
|
local -r hashResult=1
|
|
|
|
fi ;;
|
|
|
|
|
|
|
|
"aircrack-ng")
|
|
|
|
if echo "$hashData" | grep -qE "\([0-9]+ handshake\)"; then
|
|
|
|
local -r hashResult=1
|
|
|
|
fi ;;
|
2018-05-02 18:50:28 -06:00
|
|
|
|
|
|
|
"cowpatty")
|
|
|
|
if echo "$hashData" | grep -q "Collected all necessary data to mount crack against WPA2/PSK passphrase."; then
|
|
|
|
local -r hashResult=1
|
|
|
|
fi ;;
|
2017-12-31 09:02:12 -07:00
|
|
|
esac
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
if [ -z "$hashResult" ]; then
|
2018-01-06 21:21:37 -07:00
|
|
|
echo "Invalid hash for $handshakeAPSSID ($handshakeAPMAC)!" > $HashOutputDevice
|
2017-12-31 09:02:12 -07:00
|
|
|
HASHCheckHandshake="invalid"
|
|
|
|
return 1
|
|
|
|
else
|
2018-01-06 21:21:37 -07:00
|
|
|
echo "Valid hash for $handshakeAPSSID ($handshakeAPMAC)!" > $HashOutputDevice
|
2017-12-31 09:02:12 -07:00
|
|
|
HASHCheckHandshake="valid"
|
|
|
|
fi
|
2017-08-08 11:40:32 -06:00
|
|
|
}
|