summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2013-05-26 11:20:17 +0200
committermakefu <github@syntax-fehler.de>2013-05-26 11:20:17 +0200
commit9bee05500405e0418876406d3dc64beca044667e (patch)
treedca4063b9026e4827142670715d783499b3ead71
parent7b378cab9f8c201b2646d1112867225b47645e4e (diff)
add wps, nonworking
-rw-r--r--usr/lib/autowifi/lib/wps44
1 files changed, 40 insertions, 4 deletions
diff --git a/usr/lib/autowifi/lib/wps b/usr/lib/autowifi/lib/wps
index 0fdba0f5..7fd38a26 100644
--- a/usr/lib/autowifi/lib/wps
+++ b/usr/lib/autowifi/lib/wps
@@ -13,9 +13,45 @@ try_wps_pin(){
PIN="$7"
[ "$ENC" == off ] && return 2
+ WPA_CONF=/tmp/wpa.conf
+ WPA_LOG=/tmp/wpa.log
+ rm $WPA_LOG
+ #mkfifo $WPA_LOG
+ killall wpa_supplicant && sleep 1
+
+ cat > $WPA_CONF <<EOF
+ctrl_interface=/var/run/wpa_supplicant
+ctrl_interface_group=0
+update_config=1
+EOF
+ wpa_supplicant -Dwext -iwlan0 -c $WPA_CONF -f $WPA_LOG &
+ sleep 2
+ if !(sudo wpa_cli wps_reg $MAC $PIN | grep -q OK) ;then
+ echo "wpa_cli wps_reg failed, bailing out!"
+ return 1
+ fi
+
+ WPA_PID=$!
+ #*"WPA: Key negotiation completed"*)
+ # association failed
+ # exit 1 ;;
+ if ( tail -f $WPA_LOG & echo "TAILPID: $!" )| while read line ; do
+ case "$line" in
+ TAILPID:*)IFS=" " set -- $line; TAILPID=$2;;
+ *CTRL-EVENT-DISCONNECTED*):;;
+ *CTRL-EVENT-CONNECTED*)
+ kill -HUP $TAILPID
+ exit 0;;
+
+ esac
+ done ; then
+ echo "Connected!"
+ sed -n 's/[ \t]*psk="\(.*\)"$/\1/p' $WPA_CONF
+ return 0
+ else
+ echo "failed!"
+ return 1
+ fi
+ kill $WPA_PID
- airmon-ng start ${WIFI:-wlan0} $CHANNEL
- sleep 1
- reaver -i mon0 -b $MAC -vv -p "$PIN" -f -c $CHANNEL || :
- airmon-ng stop mon0
}