From 34d9ba4e29f204ab0fa3cf9c6d163766750b5f85 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 31 May 2013 22:17:19 +0200 Subject: changed ip of slowpoke --- retiolum/hosts/slowpoke | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retiolum/hosts/slowpoke b/retiolum/hosts/slowpoke index e5cf70bf..09e415e1 100644 --- a/retiolum/hosts/slowpoke +++ b/retiolum/hosts/slowpoke @@ -1,4 +1,4 @@ -Address = 81.89.96.210 +Address = 62.113.241.235 Subnet = 10.243.232.121 Subnet = 42:7d8f:9e3a:dcc7:9b22:d1ca:7e28:fe9c -- cgit v1.2.3 From a653b947f5238267201e155005b603664a39d0e8 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 2 Jun 2013 18:57:25 +0200 Subject: added autowifi script --- autowifi/autowifi | 190 ++++++++++++++++++++++++++++++++++++++ autowifi/confdir/blacklist | 2 + autowifi/confdir/cracks/00profile | 11 +++ autowifi/confdir/cracks/01open | 6 ++ cholerab/bling/krebs-v3_small.txt | 10 ++ minikrebs | 2 +- 6 files changed, 220 insertions(+), 1 deletion(-) create mode 100755 autowifi/autowifi create mode 100644 autowifi/confdir/blacklist create mode 100755 autowifi/confdir/cracks/00profile create mode 100755 autowifi/confdir/cracks/01open create mode 100644 cholerab/bling/krebs-v3_small.txt diff --git a/autowifi/autowifi b/autowifi/autowifi new file mode 100755 index 00000000..e2ddb010 --- /dev/null +++ b/autowifi/autowifi @@ -0,0 +1,190 @@ +#!/bin/sh -x + +confdir=${confdir:-"$(dirname $0)/confdir"} +interface="wlan0" + +exists() { type "$1" >/dev/null 2>/dev/null; } + +start_wpa_supplicant(){ + killall wpa_supplicant + sleep 1 +cat>wpa.conf< $confdir/wifi_stats2 + mv $confdir/wifi_stats2 $confdir/wifi_stats + return 0 + fi + return 1 + +} +print_iwlist_env(){ + # takes environment: + # MAC + # FREQ + # QUALITY + # ENCRYPTION + # ESSID + for i in MAC FREQ QUALITY ENCRYPTION ESSID;do + eval echo ${i}_${count}=\\\"\$"${i}"\\\" + done +} + +iwlist_scan(){ + # usage: iwlist_scan $wifi-itf + + count=0 + wpa_cli scan >/dev/null + sleep 10 + + wpa_cli scan_results 2>/dev/null | grep -E "^??:" | sed 's/ / /g' | (while IFS=' ' read MAC FREQ QUALITY ENCRYPTION ESSID + do + : $((count+=1)) + print_iwlist_env + + done; echo WIFI_COUNT=$count) +} + +find_count_of_ssid(){ + c=0 + for i in `seq 1 $WIFI_COUNT`; do + eval SSID=\${ESSID_${i}} + if [ "$SSID" = $1 ]; then + c+=1 + echo $i + fi + done + if [ $c -eq 0 ];then + exit 1 + fi + exit 0 +} + +find_unscanned_networks(){ + for i in `seq 1 $WIFI_COUNT`; do + eval SSID=\${ESSID_${i}} + eval MAC=\${MAC_${i}} + cat $confdir/wifi_stats 2>/dev/null | (while IFS='|' read SSID MAC BANDW KEY; do + if [ "$1" = "$SSID" -a "$2" = "$MAC" ]; then + continue + fi + done; echo $i) + done + exit 0 +} + +connect_to_network_by_ssid(){ + find_count_of_ssid "$1" | (while read i + do + loop_over_cracks $i + done;exit 1) + if [ $? -eq 0 ]; then + exit 0 + fi + echo "no network found :(" + exit 1 +} + +connect_with_pw(){ + find_count_of_ssid "$1" | (while read i + do + KEY="$2" + eval connect \"\${MAC_${i}}\" \"\${ESSID_${i}}\" \${ENCRYPTION_${i}} \"\${KEY}\" + if [ $? -eq 0 ]; then + exit 0 + fi + done;exit 1) +} + +loop_over_networks(){ + for i in `seq 1 $WIFI_COUNT`; do + loop_over_cracks $i + if [ $? -eq 0 ]; then + exit 0 + fi + done +} + +loop_over_cracks(){ + i=$1 + KEY='' + for crack in $(find $confdir/cracks -type f); do + KEY="$(eval root=$confdir \$crack \"\${ESSID_${i}}\" \"\${MAC_${i}}\" \${FREQ_${i}} \${ENCRYPTION_${i}})" + if [ $? -eq 0 ]; then + eval connect \"\${MAC_${i}}\" \"\${ESSID_${i}}\" \${ENCRYPTION_${i}} \"\${KEY}\" + if [ $? -eq 0 ]; then + return 0 + fi + fi + done + return 1 +} + +scan_all(){ + for i in `seq 1 $WIFI_COUNT`; do + loop_over_cracks $i + done +} + +scan_unscanned(){ + find_unscanned_networks | (while read i + do + loop_over_cracks $i + done) +} + + +check_gateway(){ + echo ping -c 1 -w 5 $(ip route | grep $interface | awk '/default/{print $3}') +} + +check_internet(){ + ping -c 1 -w 5 8.8.8.8 +} + +check_bandwidth(){ + echo $(printf "%.16d\n" $(curl ftp://ftp.microsoft.com/Products/mspress/library/ANIMAT.ZIP -w "%{speed_download}" -o /dev/null 2>/dev/null | sed 's/\..*//')) +} + +start_wpa_supplicant +iwlist_scan > /tmp/$interface.scan +. /tmp/$interface.scan +if [ -n "$2" ]; then + echo connecting to $1 with pw $2 + connect_with_pw "$1" "$2" +elif [ -n "$1" ]; then + echo connecting to $1 + connect_to_network_by_ssid "$1" +else + echo looping network now + loop_over_networks +fi diff --git a/autowifi/confdir/blacklist b/autowifi/confdir/blacklist new file mode 100644 index 00000000..f0e5c6a1 --- /dev/null +++ b/autowifi/confdir/blacklist @@ -0,0 +1,2 @@ +02:25:9c:41:c6:89 +02:25:9c:41:c4:cc diff --git a/autowifi/confdir/cracks/00profile b/autowifi/confdir/cracks/00profile new file mode 100755 index 00000000..c2ad6ec7 --- /dev/null +++ b/autowifi/confdir/cracks/00profile @@ -0,0 +1,11 @@ +#!/bin/sh -x +#ESSID MAC CHANNEL ENCRYPTION WPA WPA2 +# ENV: +# root (default: /) +root=${root:-/} +cat $root/wifi_stats 2>/dev/null | (while IFS='|' read SSID MAC BANDW KEY; do + if [ "$1" = "$SSID" -a "$2" = "$MAC" ]; then + echo $KEY + exit 0 + fi +done; exit 1) diff --git a/autowifi/confdir/cracks/01open b/autowifi/confdir/cracks/01open new file mode 100755 index 00000000..7bd98e20 --- /dev/null +++ b/autowifi/confdir/cracks/01open @@ -0,0 +1,6 @@ +#!/bin/sh -x +#ESSID MAC CHANNEL ENCRYPTION WPA WPA2 +if [ "$4" = "[ESS]" ]; then + exit 0 +fi +exit 1 diff --git a/cholerab/bling/krebs-v3_small.txt b/cholerab/bling/krebs-v3_small.txt new file mode 100644 index 00000000..8adce7eb --- /dev/null +++ b/cholerab/bling/krebs-v3_small.txt @@ -0,0 +1,10 @@ +x x x x +x x x x +xx xx + x x x x + x x x x +xxxxxxxxxx + xxxxxxxx +x xxxxxx x +x x x x x +x x xx x x diff --git a/minikrebs b/minikrebs index d74fa7bd..d44469e4 160000 --- a/minikrebs +++ b/minikrebs @@ -1 +1 @@ -Subproject commit d74fa7bd724c45270f86b3b1eacecf90b83b0212 +Subproject commit d44469e4fa51171c12fff95b1a3170eb85328698 -- cgit v1.2.3 From 5a428d4646b73f16b890f6c089a67dbc710df533 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 5 Jun 2013 18:57:33 +0200 Subject: autowifi: now with hooks --- autowifi/autowifi | 24 +++++++++++++++++++++++- autowifi/confdir/hooks/wlan0/post/00tinc-up | 2 ++ autowifi/confdir/hooks/wlan0/pre/00changemac | 5 +++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 autowifi/confdir/hooks/wlan0/post/00tinc-up create mode 100755 autowifi/confdir/hooks/wlan0/pre/00changemac diff --git a/autowifi/autowifi b/autowifi/autowifi index e2ddb010..5bdbde22 100755 --- a/autowifi/autowifi +++ b/autowifi/autowifi @@ -18,6 +18,17 @@ EOF connect(){ #mac ssid encryption key wpa_cli reconfigure + + #INTERFACE PRE CONNECT HOOKS + for hook in $(find $confdir/hooks/$interface/pre -type f | sort -u); do + $hook $@ + done + + #PROFILE PRE CONNECT HOOKS + for hook in $(find "$confdir/hooks/$2/pre" -type f | sort -u); do + $hook $@ + done + int=$(wpa_cli add_network | tail -1) wpa_cli set_network $int ssid \"$2\" wpa_cli set_network $int bssid $1 @@ -39,6 +50,17 @@ connect(){ if check_gateway && check_internet; then echo yay internet + #INTERFACE POST CONNECT HOOKS + for hook in $(find $confdir/hooks/$interface/post -type f | sort -u); do + $hook $@ + done + + #PROFILE POST CONNECT HOOKS + for hook in $(find "$confdir/hooks/$2/post" -type f | sort -u); do + $hook $@ + done + + bandw=$(check_bandwidth) (cat $confdir/wifi_stats | grep -v "|$1|" ; echo "$2|$1|$bandw|$4" ) | sort | uniq > $confdir/wifi_stats2 mv $confdir/wifi_stats2 $confdir/wifi_stats @@ -137,7 +159,7 @@ loop_over_networks(){ loop_over_cracks(){ i=$1 KEY='' - for crack in $(find $confdir/cracks -type f); do + for crack in $(find $confdir/cracks -type f | sort -u); do KEY="$(eval root=$confdir \$crack \"\${ESSID_${i}}\" \"\${MAC_${i}}\" \${FREQ_${i}} \${ENCRYPTION_${i}})" if [ $? -eq 0 ]; then eval connect \"\${MAC_${i}}\" \"\${ESSID_${i}}\" \${ENCRYPTION_${i}} \"\${KEY}\" diff --git a/autowifi/confdir/hooks/wlan0/post/00tinc-up b/autowifi/confdir/hooks/wlan0/post/00tinc-up new file mode 100755 index 00000000..3fd786e4 --- /dev/null +++ b/autowifi/confdir/hooks/wlan0/post/00tinc-up @@ -0,0 +1,2 @@ +#!/bin/sh +tincd -n retiolum -kALRM diff --git a/autowifi/confdir/hooks/wlan0/pre/00changemac b/autowifi/confdir/hooks/wlan0/pre/00changemac new file mode 100755 index 00000000..c3e0632f --- /dev/null +++ b/autowifi/confdir/hooks/wlan0/pre/00changemac @@ -0,0 +1,5 @@ +#!/bin/sh +ifconfig wlan0 down +sleep 1 +macchanger -r wlan0 +ifconfig wlan0 up -- cgit v1.2.3