WPS-PIN mode

  • In this section, you are going to learn

  • How to run wpa_supplicant and hostapd in WPS-PIN mode

#

Version

Ubuntu

Ubuntu 22.04 64 bit

Linux Kernel

6.5.0

Supplicant

wpa_supplicant 2.10

Hostapd

hostapd 2.10

AP : Download hostapd

Note

  • Make sure internet is available in laptop to download hostapd package

test:~$ sudo wget http://w1.fi/releases/hostapd-2.10.tar.gz

AP : Extract hostapd

test:~$ sudo tar -xvf hostapd-2.10.tar.gz

AP : Change directory to hostapd

test:~$ cd hostapd-2.10/hostapd/

AP : Check the current working directory using pwd command

Note

  • Make sure your current working directory is hostapd

test:~$ pwd
/home/test/hostapd-2.10/hostapd

AP : Copy the contents of defconfig file to .config file

Note

  • .config file is required for make to start compilation of hostapd

test:~$ sudo cp defconfig .config

AP : Open .config file and copy below lines to .config file

test:~$ sudo vim .config

CONFIG_DRIVER_NL80211=y
CONFIG_WPA_PSK=y
CONFIG_WPS=y

AP : Complile hostapd

Note

  • Compile hostapd by running make command

test:~$ sudo make

AP : Check for the binaries created

Note

  • Make sure hostapd and hostapd_cli are present

test:~$ ls
hostapd
hostapd_cli

AP : Create run_hostapd.conf

Note

  • ssid in ./run_hostapd.conf should be used by clients while connecting to AP

test:~$ sudo vim ./run_hostapd.conf

ctrl_interface=/var/run/hostapd
interface=wlan0
driver=nl80211
ssid=test_wps_pin
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0

wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
group_cipher=CCMP

eap_server=1
wps_state=2
ap_setup_locked=1
uuid=e22ecb71-2706-5c5b-9521-e1cd7dbf8e11

AP : Run hostapd

test:~$ sudo ./hostapd ./run_hostapd.conf
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED 

AP : Check ps status and confirm hostapd process is running

test:~$ ps -N | grep -i hostapd
36261 pts/3    00:00:00 hostapd

AP : Run wps_pin

Attention

  • This starts registrar operation on hostapd

Attention

  • sudo ./hostapd_cli -i wlan0 wps_pbc status will generate a UUID !

Note

  • 86559560 is taken from output of wps_pin any on station side

test:~$ sudo ./hostapd_cli -i wlan0 wps_pbc status

uuid=572cf82f-c957-5653-9b16-b5cfb298abf1

test:~$ sudo ./hostapd_cli -i wlan0 wps_pin 572cf82f-c957-5653-9b16-b5cfb298abf1 86559560

AP : Check iwconfig output after connection

Note

  • Mode field in iwconfig should show master

test:~$ sudo iwconfig 
wlan0     IEEE 802.11  Mode:Master  Tx-Power=20 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on

AP : Check iw dev output after connection

test:~$ sudo iw dev
phy#1
        Interface wlan0
                ifindex 5
                wdev 0x100000001
                addr 02:00:00:00:00:00
                ssid test_wps_pin
                type AP
                channel 6 (2437 MHz), width: 20 MHz (no HT), center1: 2437 MHz
                txpower 20.00 dBm

STA : Download wpa_supplicant

Note

  • Make sure internet is available in laptop to download supplicant package

test:~$ sudo wget https://w1.fi/releases/wpa_supplicant-2.10.tar.gz

STA : Extract wpa_supplicant

test:~$ sudo tar -xvf wpa_supplicant-2.10.tar.gz

STA : Change directory to wpa_supplicant

test:~$ cd wpa_supplicant-2.10/wpa_supplicant/

STA : Check the current working directory using pwd command

Note

  • Make sure your current working directory is wpa_supplicant

test:~$ pwd
/home/test/wpa_supplicant-2.10/wpa_supplicant

STA : Copy the contents of defconfig file to .config file

Note

  • .config file is required for make to start compilation of supplicant

test:~$ sudo cp defconfig .config

STA : Open .config file and copy below lines to .config file

test:~$ sudo vim .config

CONFIG_DRIVER_NL80211=y
CONFIG_WPA_PSK=y
CONFIG_WPS=y

STA : Compile wpa_supplicant

Note

  • Compile supplicant by running make command

test:~$ sudo make

STA : Check for the binaries created

Note

  • Make sure wpa_supplicant and wpa_cli are present

test:~$ ls
wpa_supplicant
wpa_cli

STA : Create run_supplicant.conf

Note

  • ssid need not be mentioned in ./run_supplicant.conf

test:~$ sudo vim ./run_supplicant.conf

ctrl_interface=/run/wpa_supplicant
update_config=1

STA : Run wpa_supplicant

test:~$ sudo ./wpa_supplicant -Dnl80211 -i wlan1 -c ./run_supplicant.conf
Successfully initialized wpa_supplicant

STA : Check ps status and confirm wpa_supplicant process is running

test:~$ ps -N | grep -i wpa
36164 pts/2    00:00:00 wpa_supplicant

STA : Run wps_pin

Attention

  • This starts enrollee operation on supplicant

Attention

  • sudo ./wpa_cli -i wlan1 wps_pin any will generate a pin !

Note

  • 86559560 is generated in this case. Use it in hostapd_cli

test:~$ sudo ./wpa_cli -i wlan1 wps_pin any

86559560

STA : Check connection status using wpa_cli

Note

  • wpa_state=COMPLETED indicates successful connection. Check output of status

test:~$ sudo ./wpa_cli -i wlan1
> status
bssid=02:00:00:00:00:00
freq=2437
ssid=test_owe
id=0
mode=station
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=OWE
wpa_state=COMPLETED
p2p_device_address=42:00:00:00:01:00
address=02:00:00:00:01:00
uuid=572cf82f-c957-5653-9b16-b5cfb298abf1

STA : Check iwconfig output after connection

Note

  • ESSID field in iwconfig should show ssid of AccessPoint

test:~$ sudo iwconfig 
wlan1     IEEE 802.11  ESSID:"test_wps_pin"  
          Mode:Managed  Frequency:2.437 GHz  Access Point: 02:00:00:00:00:00   
          Bit Rate:54 Mb/s   Tx-Power=20 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=70/70  Signal level=-30 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

STA : Check iw dev output after connection

test:~$ sudo iw dev
phy#2
        Interface wlan1
                ifindex 6
                wdev 0x200000001
                addr 02:00:00:00:01:00
                ssid test_wps_pin
                type managed
                channel 6 (2437 MHz), width: 20 MHz (no HT), center1: 2437 MHz
  • Download file to check wireshark output

Packet capture in WPS-PIN mode