Differences between revisions 8 and 10 (spanning 2 versions)
Revision 8 as of 2019-09-18 14:53:41
Size: 7937
Editor: asbesto
Comment:
Revision 10 as of 2020-03-01 09:54:35
Size: 9952
Editor: asbesto
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Perche' BASH VINCE = = Because BASH WIN =
Line 5: Line 5:
== Ipotesi di script ==

TODO

== Scan delle reti wifi presenti ==

iw wlan0 scan e un colpo di grep

Andiamo di awk, andiamo affanculo
== Script to use ==

Here it is, thanks to Katolaz!

 * https://kalos.mine.nu/setnet/

FUCK'N TASTIC!

== Scanning WIFI networks ==

iw wlan0 scan and a little grep

Let's awk, let's fuck ourselves
Line 32: Line 35:
    # Workaround spaces in SSID     # fix spaces in SSID
Line 89: Line 92:

il risultato soddisfa:
result seem good to me:
Line 95: Line 97:
1C497B51F02D:Linkem2.4GHz_51F02C:WPA2:yes:11:76:12d23h25m
E48F34776815:Vodafone-A46124408:WPA2:yes:12:70:1d07h59m
A491B178032E:FASTWEB-78032E:WPA2:yes:1:82:0d11h45m
121331D67AA8:WOW FI - FASTWEB:WPA2:no:1:52:27d15h05m
5CE28C90FA0E:Infostrada-90FA0D:WPA1WPA2:yes::86:6d10h53m
64700239143D:Home:WPA1WPA2:yes:1:67:5d18h35m
1C4997B6F02D:Linkem2.4GHz_51F02C:WPA2:yes:11:76:12d23h25m
A491B1787677:FASTWEB-22032E:WPA2:yes:1:82:0d11h45m
121331D6EEA8:WOW FI - FASTWEB:WPA2:no:1:52:27d15h05m
Line 102: Line 101:
101331D67AA9:FASTWEB-D67AA9(2.4ghz):WPA2:yes:1:51:27d15h05m
30918F9DAD43:Telecom-61991747:WPA1WPA2:yes:11:76:40d15h04m
04F0211B577E:tvccSiracusa:WPA2:no::78:119d10h29m
E48F34564F0C:VodafoneMontedoro:WPA2:yes:7:58:1d03h07m
4C5E0C61E196:mynetworch23:WPA2:no::82:119d10h31m
121331D67AB1:FASTWEB-D67AA9(5ghz):WPA2:yes::66:28d04h46m
E48F34564F0E:Vodafone-WiFi:OPEN:no:7:58:1d03h07m
A691B178032D:WOW FI - FASTWEB:WPA2:no:1:72:0d11h45m
628F34776816:Vodafone-WiFi:OPEN:no:12:70:1d07h59m
628F34774344:Vodafone-Petacci:OPEN:no:12:70:1d07h59m
Line 115: Line 106:
da qui, capire se uno degli ESSID / MAC ADDRESS esiste nelle conf -> collegarsi automaticamente e vaffanculo


== Verifica con db esistente ==

confronto e ricerca file /etc/network/interface.ESSID bello e pronto
Now, if one of those ESSID/MAC exist in our conf -> connect and fuck you

== check in ESSID/MAC db ==

grep / awk into /etc/network/interface.ESSID ?

'''
todo'''
Line 125: Line 116:
RETA, voce del verbo RETARE: mi connetto RETA, "to net" in italian invented words
Line 134: Line 125:
=== interfaces ===

GENERICO WPA DEL CAZZO:
SIMPLE AS FUCK

=== Use of wpa fucking supplicant ===

You need to set /etc/wpa_supplicant/wpa_supplicant.conf as follow.

EXAMPLES

{{{
ctrl_interface=/var/run/wpa_supplicant
update_config=1

# any normal AP with password, wpa (wep unchecked)
network={
 ssid="FRITZ!Box 7490"
 psk="jesusfuckingchrist"
}

network={
 ssid="OpenWrt"
 psk="systemdshit"
}

# An OPEN AP without pw or security
network={
 ssid="Vodafone-WiFi"
 key_mgmt=NONE

# An OPEN AP with same ESSID of other AP around: here's how to connect specifically to that one!
# NOTE that bssid is a FUCKING STRING BUT doesn't require the " as any other string option in the config file.
# WHY, WHY THE FUCK IS THAT.
# THIS DROVE ME NUTS FOR AN ENTIRE WEEK. I HOPE WHO WROTE THE CONFIG FILE PARSER WILL PASS AN ENTIRE WEEK
# WITH HIS BOWELS EXPLODING SHIT EVERYWHERE.
network={
 bssid=e4:8f:34:56:4f:0e
 key_mgmt=NONE

}

}}}

To use it, just launch

{{{
wpa_supplicant -dd -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
}}}

''-dd'' is for debugging.

=== CHECK if network is ok and relaunch dhclient accordingly ===

Sometime the wifi goes down and turn up again. But doing so, sometimes default route is cleared, I don't know why. So wifi turn on again, you are connected to wifi, but network doesn't work, you check, route -n and there's no fucking default gw. So you have to add it by hand (route add default gw etc. etc.) or you have to kill the fucking dhclient and re-launch it by hand.

This sexual harassment led me to write this script that automagically check the network / gw and KILL / relaunch dhclient accordingly.

{{{
#!/bin/bash
INTERFACE="wlan0"
SERVICE="wpa_supplicant"
while :
do
wpa=`pidof $SERVICE`

if [ "${wpa:-null}" = null ]; then
    echo "wpa_supplicant is DEAD"
else
    echo "wpa_supplicant is running, pid $wpa "
    gat=$(/sbin/ip route | awk '/default/ { print $3 }')
    if [ "${gat:-null}" = null ]; then
       echo "wpa_supplicant is running, but NO GATEWAY"
       sleep 1 && killall dhclient && sleep 1 && dhclient -v $INTERFACE
    else
       echo "GW is $gat"
    fi
fi
sleep 10
done
}}}

I just launch this on a shell and GW is checked every 10 seconds. So I'm pretty sure my fucking network connection will STAY THE FUCK ON


=== /etc/network/interfaces ===

generic dickhead WPA setup:
Line 157: Line 230:
GENERICO RETE APERTA SOLO SSID Generic open network, no pw, SSID only
Line 174: Line 247:

}}}

NOTA: wireless-ap trovato miracolosamente, capito da:

gli initscripts di Debian passano le opzioni wireless-sarcazzo direttamente a iwconfig, quindi la lista di opzioni sta in
https://linux.die.net/man/8/iwconfig

vedi il contenuto del merdoso file '''/etc/network/if-pre-up.d/wireless-tools'''


== docs sparpagliati ovunque porcoddio ==
}}}

I choose to connect to a specific AP using the mac address because we have many AP with the same name in this area.


NOTE: I found '''wireless-ap''' settings only by GREAT LUCK, reading a TON OF SHIT:

DEBIANshit initscripts pass wireless-shit options directly to iwconfig, SO the option list can (only?) be found by reading https://linux.die.net/man/8/iwconfig

what the actual fuck

Also look the fucking '''/etc/network/if-pre-up.d/wireless-tools''' file

== docs are scattered everywhere, jesus fucking christ ==
Line 189: Line 264:
 * PORCODIO  * to hell with god


The following shit is in italian language. I don't care. Your fault.
Line 245: Line 323:
CategoryMuseum CategoryMuseo

Because BASH WIN

Script to use

Here it is, thanks to Katolaz!

FUCK'N TASTIC!

Scanning WIFI networks

iw wlan0 scan and a little grep

Let's awk, let's fuck ourselves

$1 ~ /^BSS/ {
    if($2 !~ /Load:/) { #< Escape "BBS Load:" line
        gsub("(\\(.*|:)", "", $2)
        MAC = toupper($2)
        wifi[MAC]["enc"] = "OPEN"
        wifi[MAC]["WPS"] = "no"
        wifi[MAC]["wpa1"] = ""
        wifi[MAC]["wpa2"] = ""
        wifi[MAC]["wep"] = ""
    }
}
$1 == "SSID:" {
    # fix spaces in SSID
    FS=":" #< Changing field separator on ":", it should be
           #  forbidded sign for SSID name
    $0=$0
    sub(" ", "", $2) #< remove first whitespace
    wifi[MAC]["SSID"] = $2
    FS=" "
    $0=$0
}
$1 == "capability:" {
    for(i=2; i<=NF; i++) {
        if($i ~ /0x[0-9]{4}/) {
            gsub("(\\(|\\))", "", $i)
            if (and(strtonum($i), 0x10)) 
                wifi[MAC]["wep"] = "WEP"
        }
    }
}
$1 == "WPA:" {
    wifi[MAC]["wpa1"] = "WPA1"
}
$1 == "RSN:" {
    wifi[MAC]["wpa2"] = "WPA2"
}
$1 == "WPS:" {
    wifi[MAC]["WPS"] = "yes"
}
$1 == "DS" {
    wifi[MAC]["Ch"] = $5
}
$1 == "signal:" {
    match($2, /-([0-9]{2})\.00/, m)
    wifi[MAC]["Sig"] = m[1]
}
$1 == "TSF:" {
    gsub("(\\(|d|,)", "", $4)
    match($5, /([0-9]{2}):([0-9]{2}):/, m)
    day = $4
    hour = m[1]
    min = m[2]
    wifi[MAC]["TSF"] = day"d"hour"h"min"m"
}
END {
    for (w in wifi) {
        if (wifi[w]["wep"]) {
            if (wifi[w]["wpa1"] || wifi[w]["wpa2"])
                wifi[w]["enc"] = wifi[w]["wpa1"]wifi[w]["wpa2"]
            else
                wifi[w]["enc"] = "WEP"
        }
        printf "%s:%s:%s:%s:%s:%s:%s\n", w, wifi[w]["SSID"], wifi[w]["enc"], \
               wifi[w]["WPS"], wifi[w]["Ch"], wifi[w]["Sig"], wifi[w]["TSF"]
    }
}

result seem good to me:

root@rover:/home/asbesto# iw wlan0 scan | awk -f parsa.awk
1C4997B6F02D:Linkem2.4GHz_51F02C:WPA2:yes:11:76:12d23h25m
A491B1787677:FASTWEB-22032E:WPA2:yes:1:82:0d11h45m
121331D6EEA8:WOW FI - FASTWEB:WPA2:no:1:52:27d15h05m
BA9E639DB4E7:Wiremore:WPA2:no:6:27:0d01h35m
628F34774344:Vodafone-Petacci:OPEN:no:12:70:1d07h59m
root@rover:/home/asbesto#

Now, if one of those ESSID/MAC exist in our conf -> connect and fuck you

check in ESSID/MAC db

grep / awk into /etc/network/interface.ESSID ?

todo

Reta

RETA, "to net" in italian invented words

service networking stop
cp /etc/network/interfaces.ESSIDDELCAZZO /etc/network/interfaces
service networking start

SIMPLE AS FUCK

Use of wpa fucking supplicant

You need to set /etc/wpa_supplicant/wpa_supplicant.conf as follow.

EXAMPLES

ctrl_interface=/var/run/wpa_supplicant
update_config=1

# any normal AP with password, wpa (wep unchecked)
network={
        ssid="FRITZ!Box 7490"
        psk="jesusfuckingchrist"
}

network={
        ssid="OpenWrt"
        psk="systemdshit"
}

# An OPEN AP without pw or security
network={
        ssid="Vodafone-WiFi"
        key_mgmt=NONE

# An OPEN AP with same ESSID of other AP around: here's how to connect specifically to that one! 
# NOTE that bssid is a FUCKING STRING BUT doesn't require the " as any other string option in the config file.
# WHY, WHY THE FUCK IS THAT. 
# THIS DROVE ME NUTS FOR AN ENTIRE WEEK. I HOPE WHO WROTE THE CONFIG FILE PARSER WILL PASS AN ENTIRE WEEK
# WITH HIS BOWELS EXPLODING SHIT EVERYWHERE.
network={
        bssid=e4:8f:34:56:4f:0e
        key_mgmt=NONE

}

To use it, just launch

wpa_supplicant -dd -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

-dd is for debugging.

CHECK if network is ok and relaunch dhclient accordingly

Sometime the wifi goes down and turn up again. But doing so, sometimes default route is cleared, I don't know why. So wifi turn on again, you are connected to wifi, but network doesn't work, you check, route -n and there's no fucking default gw. So you have to add it by hand (route add default gw etc. etc.) or you have to kill the fucking dhclient and re-launch it by hand.

This sexual harassment led me to write this script that automagically check the network / gw and KILL / relaunch dhclient accordingly.

INTERFACE="wlan0"
SERVICE="wpa_supplicant"
while :
do
wpa=`pidof $SERVICE`

if [ "${wpa:-null}" = null ]; then
    echo "wpa_supplicant is DEAD"
else
    echo "wpa_supplicant is running, pid $wpa "
    gat=$(/sbin/ip route | awk '/default/ { print $3 }')
    if [ "${gat:-null}" = null ]; then
       echo "wpa_supplicant is running, but NO GATEWAY"
       sleep 1 && killall dhclient && sleep 1 && dhclient -v $INTERFACE
    else
       echo "GW is $gat"
    fi
fi
sleep 10
done

I just launch this on a shell and GW is checked every 10 seconds. So I'm pretty sure my fucking network connection will STAY THE FUCK ON

/etc/network/interfaces

generic dickhead WPA setup:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto wlan0
allow-hotplug
iface wlan0 inet dhcp
        wpa-ssid wifi-del-cazzo
        wpa-psk sucaminchia

Generic open network, no pw, SSID only

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto wlan0
allow-hotplug
iface wlan0 inet dhcp
 wireless-ap E4:8F:34:56:4F:0E
 wireless-essid Vodafone-WiFi

I choose to connect to a specific AP using the mac address because we have many AP with the same name in this area.

NOTE: I found wireless-ap settings only by GREAT LUCK, reading a TON OF SHIT:

DEBIANshit initscripts pass wireless-shit options directly to iwconfig, SO the option list can (only?) be found by reading https://linux.die.net/man/8/iwconfig

what the actual fuck

Also look the fucking /etc/network/if-pre-up.d/wireless-tools file

docs are scattered everywhere, jesus fucking christ

The following shit is in italian language. I don't care. Your fault.

Parametri WPA senza wpasupplicant.conf
Almeno a partire da Lenny (Debian 5) è possibile configurare wpa_supplicant direttamente dal file /etc/network/interfaces; per fare ciò sarà però necessario modificare un poco la sintassi. Rifacendomi all'esempio sopra riportato (nel caso con DHCP, ma vale la stessa cosa per un indirizzo statico), il file unico di configurazione andrebbe scritto nel modo seguente:

auto wlan0
iface wlan0 inet dhcp
wpa-ssid NOME_RETE_WIRELESS
wpa-psk cc989812bc2cd489f960d8c1b2428d98d3c5555dac62d70ff691762fb4cc418a
evitando appunto la linea "pre-up wpa_supplicant -iwlan0 -c /etc/wpa_supplicant.conf -B" e dunque l'utilizzo del file "etc/wpa_supplicant.conf. Alla fine i due metodi di configurazione sono da considerarsi equivalenti; sarà infine solo la filosofia dell'utente ad indicare quale metodo sia il migliore (c'è chi preferisce configurare un file in meno nel sistema operativo e chi preferisce avere un file di configurazione "dedicato" per ogni funzione del sistema). In ogni caso, come sempre, prima viene la conoscenza delle possibilità e poi si potrà decidere in tutta calma :-).

Info.png        Nota 
È possibile che in alcune guide troverete la linea "wpa-driver wext" a seguire o a precedere le due citate; nonostante quest'opzione sia effettivamente necessaria, se la si tralascia è ciò che viene comunque selezionato per default: tanto vale allora dimenticarcela ;-).

Oltre alle opzioni "wpa-ssid" e "wpa-psk" (e "wpa-driver"), nel file /usr/share/doc/wpasupplicant/README.Debian.gz troverete tutte le altre possibilità che vi riportiamo qui sotto e utilizzabili a seconda dell'esigenza.

Element        Example Value            Description
=======        =============            ===========
wpa-ssid       plaintextstring          sets the ssid of your network

wpa-bssid      00:1a:2b:3c:4d:5e        the bssid of your AP

wpa-psk        0123456789......         your preshared wpa key. Use
                                        wpa_passphrase(8) to generate your psk
                                        from a passphrase and ssid pair

wpa-key-mgmt   NONE, WPA-PSK, WPA-EAP,  list of accepted authenticated key
               IEEE8021X                management protocols

wpa-group      CCMP, TKIP, WEP104,      list of accepted group ciphers for WPA
               WEP40

wpa-pairwise   CCMP, TKIP, NONE         list of accepted pairwise ciphers for
                                        WPA

wpa-auth-alg   OPEN, SHARED, LEAP       list of allowed IEEE 802.11
                                        authentication algorithms

wpa-proto      WPA, RSN                 list of accepted protocols

wpa-identity   myplaintextname          administrator provided username
                                        (EAP authentication)

wpa-password   myplaintextpassword      your password (EAP authentication)

wpa-scan-ssid  0 or 1                   toggles scanning of ssid with specific
                                        Probe Request frames

wpa-ap-scan    0 or 1 or 2              adjusts the scanning logic of
                                        wpa_supplicant


CategoryMuseo

MyConnectionManager (last edited 2020-03-01 11:21:33 by asbesto)