WEP-Shared mode

  • In this section, you are going to learn

  • How to run wpa_supplicant and hostapd in WEP-Shared mode

#

Version

Ubuntu

Ubuntu 22.04 64 bit

Linux Kernel

6.5.0

Supplicant

wpa_supplicant 2.10

Hostapd

hostapd 2.10

  • Run AP mode operation with hostapd

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 : Add CONFIG_WEP=y in defconfig file

test:~$ sudo vim defconfig

CONFIG_WEP=y

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 : 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

test:~$ sudo vim ./run_hostapd.conf

ctrl_interface=/run/hostapd
interface=wlan0
driver=nl80211
ssid=test_wep_shared
hw_mode=g
channel=1
macaddr_acl=0
auth_algs=2
ignore_broadcast_ssid=0
# A key may be a quoted string or unquoted hexadecimal digits.
# The key length should be 5, 13, or 16 characters, or 10, 26, or 32
# digits, depending on whether 40-bit (64-bit), 104-bit (128-bit), or
# 128-bit (152-bit) WEP is used.
# Only the default key must be supplied; the others are optional.
# default: not set
wep_key0=123456789a
wep_key1="vwxyz"
wep_key2=0102030405060708090a0b0c0d
wep_key3=".2.4.6.8.0.23"
wep_default_key=0

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 : 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_wep_shared
                type AP
                channel 1 (2412 MHz), width: 20 MHz (no HT), center1: 2412 MHz
                txpower 20.00 dBm
  • Run AP mode operation with wpa_supplicant

AP : 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

AP : Extract wpa_supplicant

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

AP : Change directory to wpa_supplicant

test:~$ cd wpa_supplicant-2.10/wpa_supplicant/

AP : 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

AP : Add CONFIG_WEP=y in defconfig file

test:~$ sudo vim defconfig

CONFIG_WEP=y

AP : 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

AP : Complile wpa_supplicant

Note

  • Compile supplicant by running make command

test:~$ sudo make

AP : Check for the binaries created

Note

  • Make sure wpa_supplicant and wpa_cli are present

test:~$ ls
wpa_supplicant
wpa_cli

AP : Create run_hostapd.conf

test:~$ sudo vim ./run_hostapd.conf

ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
fast_reauth=1
update_config=1

# -- SoftAP mode with encryption/password protected example:
ap_scan=2
network={
       ssid="test_wep_shared"
       mode=2
       frequency=2412
       key_mgmt=NONE
       wep_key0=123456789a
       wep_key1="vwxyz"
       wep_key2=0102030405060708090a0b0c0d
       wep_key3=".2.4.6.8.0.23"
       wep_tx_keyidx=0
       priority=5
       auth_alg=SHARED
}

AP : Run wpa_supplicant

test:~$ sudo ./wpa_supplicant -Dnl80211 -i wlan0 -c ./run_hostapd.conf
Successfully initialized wpa_supplicant
Note: nl80211 driver interface is not designed to be used with ap_scan=2; this can result in connection failures
Note: nl80211 driver interface is not designed to be used with ap_scan=2; this can result in connection failures
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED 
wlan0: CTRL-EVENT-CONNECTED - Connection to 02:00:00:00:00:00 completed [id=0 id_str=]

AP : Check ps status and confirm wpa_supplicant process is running

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

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:off

AP : Check iw dev output after connection

test:~$ sudo iw dev
phy#0
        Interface wlan0
                ifindex 4
                wdev 0x1
                addr 02:00:00:00:00:00
                ssid test_wep_shared
                type AP
                channel 1 (2412 MHz), width: 20 MHz, center1: 2412 MHz
                txpower 20.00 dBm
                multicast TXQ:
                        qsz-byt qsz-pkt flows   drops   marks   overlmt hashcol tx-bytes        tx-packets
                        0       0       54      0       0       0       0       6622            54

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 : Add CONFIG_WEP=y in defconfig file

test:~$ sudo vim defconfig

CONFIG_WEP=y

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 : 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

test:~$ sudo vim ./run_supplicant.conf

ctrl_interface=/run/wpa_supplicant
update_config=1

# A key may be a quoted string or unquoted hexadecimal digits.
# The key length should be 5, 13, or 16 characters, or 10, 26, or 32
# digits, depending on whether 40-bit (64-bit), 104-bit (128-bit), or
# 128-bit (152-bit) WEP is used.
# Only the default key must be supplied; the others are optional.
# default: not set

network={
        ssid="test_wep_shared"
        key_mgmt=NONE
        wep_key0=123456789a
        wep_key1="vwxyz"
        wep_key2=0102030405060708090a0b0c0d
        wep_key3=".2.4.6.8.0.23"
        wep_tx_keyidx=0
        priority=5
        auth_alg=SHARED
        }

STA : Run wpa_supplicant

test:~$ sudo ./wpa_supplicant -Dnl80211 -i wlan1 -c ./run_supplicant.conf
Successfully initialized wpa_supplicant
wlan1: SME: Trying to authenticate with 02:00:00:00:00:00 (SSID='test_wep_shared' freq=2412 MHz)
nl80211: kernel reports: key not allowed
nl80211: kernel reports: key not allowed
nl80211: kernel reports: key not allowed
nl80211: kernel reports: key not allowed
wlan1: Trying to associate with 02:00:00:00:00:00 (SSID='test_wep_shared' freq=2412 MHz)
wlan1: Associated with 02:00:00:00:00:00
wlan1: CTRL-EVENT-CONNECTED - Connection to 02:00:00:00:00:00 completed [id=0 id_str=]
wlan1: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0

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 : 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=2412
ssid=test_wep_shared
id=0
mode=station
pairwise_cipher=WEP-40
group_cipher=WEP-40
key_mgmt=NONE
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_wep_shared"  
          Mode:Managed  Frequency:2.412 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_wep_shared
                type managed
                channel 1 (2412 MHz), width: 20 MHz (no HT), center1: 2412 MHz
                txpower 20.00 dBm
  • Download file to check wireshark output

Packet capture in WEP-shared mode