2017-08-08 11:40:32 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
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() {
|
2017-12-31 09:02:12 -07:00
|
|
|
local handshakeVerifier=$1
|
|
|
|
local handshakePath=$2
|
|
|
|
local handshakeAPSSID=$3
|
|
|
|
local handshakeAPMAC=$4
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
local analysis
|
|
|
|
local hashData
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
echo "Verifier Parameters: $handshakeVerifier, path $handshakePath, SSID \"$handshakeAPSSID\", MAC $handshakeAPMAC" >$HashOutputDevice
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
case "$handshakeVerifier" in
|
|
|
|
"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
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
local hashMeta=$(echo "${analysis[@]}" | grep -F "AccessPoint ${handshakeAPMAC,,} ('$handshakeAPSSID')")
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
if [ "$hashMeta" ]; then
|
|
|
|
local hashID=$(echo "$hashMeta" | awk -F'[ #:]' '{print $3}')
|
|
|
|
hashData=$(echo "${analysis[@]}" | awk "\$0~/#$hashID: HMAC_SHA[0-9]+_AES/{ print \$0 }")
|
|
|
|
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
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
hashData=$(echo "${analysis[@]}" | grep -E "${handshakeAPMAC^^}\s+" | grep -F "$handshakeAPSSID")
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Invalid verifier, quitting!"
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
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
|
|
|
local hashResult
|
|
|
|
case "$handshakeVerifier" in
|
|
|
|
"pyrit") hashResult=$(echo "$hashData" | grep "good") ;;
|
|
|
|
"aircrack-ng") hashResult=$(echo "$hashData" | grep "(1 handshake)") ;;
|
|
|
|
esac
|
2017-08-08 11:40:32 -06:00
|
|
|
|
2017-12-31 09:02:12 -07:00
|
|
|
if [ -z "$hashResult" ]; then
|
|
|
|
echo "Invalid hash for $handshakeAPSSID ($handshakeAPMAC)!"
|
|
|
|
HASHCheckHandshake="invalid"
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
echo "Valid hash for $handshakeAPSSID ($handshakeAPMAC)!"
|
|
|
|
HASHCheckHandshake="valid"
|
|
|
|
fi
|
2017-08-08 11:40:32 -06:00
|
|
|
}
|