vanhoefm / krackattacks-scripts

Other
3.33k stars 768 forks source link

hostapd_free_hapd_data: Interface wlan0 wasn't started #17

Closed cmonty14 closed 6 years ago

cmonty14 commented 6 years ago

Hi, after disabling Wifi (in network manager of XFCE4) I execute script krack-test-client.py. However this script reports error that "hostapd did not start properly".

thomas@pc8-nb:~/Scripte/krackattacks-scripts/krackattack$ sudo ./krack-test-client.py 
[10:06:05] Note: disable Wi-Fi in network manager & disable hardware encryption. Both may interfere with this script.
[10:06:06] Starting hostapd ...
Configuration file: hostapd.conf
nl80211: Could not configure driver mode
nl80211: deinit ifname=wlan0 disabled_11b_rates=0
nl80211 driver initialization failed.
wlan0: interface state UNINITIALIZED->DISABLED
wlan0: AP-DISABLED 
hostapd_free_hapd_data: Interface wlan0 wasn't started
connect exception  hostapd_ctrl/wlan0 9877
[10:06:07] It seems hostapd did not start properly, please inspect its output.
[10:06:07] Did you disable Wi-Fi in the network manager? Otherwise hostapd won't work.
Traceback (most recent call last):
  File "./krack-test-client.py", line 612, in <module>
    attack.run(test_grouphs=test_grouphs, test_tptk=test_tptk)
  File "./krack-test-client.py", line 474, in run
    self.hostapd_ctrl = Ctrl("hostapd_ctrl/" + self.nic_iface)
  File "/home/thomas/Scripte/krackattacks-scripts/krackattack/wpaspy.py", line 49, in __init__
    socket.SOCK_DGRAM)
socket.gaierror: [Errno -3] Temporary failure in name resolution
[10:06:07] Closing hostapd and cleaning up ...

I have identified kernel module iwlwifi:

thomas@pc8-nb:~/Scripte/krackattacks-scripts$ sudo modinfo iwlwifi
filename:       /lib/modules/4.13.0-kali1-amd64/kernel/drivers/net/wireless/intel/iwlwifi/iwlwifi.ko
license:        GPL
author:         Copyright(c) 2003- 2015 Intel Corporation <linuxwifi@intel.com>
description:    Intel(R) Wireless WiFi driver for Linux
firmware:       iwlwifi-100-5.ucode
firmware:       iwlwifi-1000-5.ucode
firmware:       iwlwifi-135-6.ucode
firmware:       iwlwifi-105-6.ucode
firmware:       iwlwifi-2030-6.ucode
firmware:       iwlwifi-2000-6.ucode
firmware:       iwlwifi-5150-2.ucode
firmware:       iwlwifi-5000-5.ucode
firmware:       iwlwifi-6000g2b-6.ucode
firmware:       iwlwifi-6000g2a-6.ucode
firmware:       iwlwifi-6050-5.ucode
firmware:       iwlwifi-6000-4.ucode
firmware:       iwlwifi-7265D-29.ucode
firmware:       iwlwifi-7265-17.ucode
firmware:       iwlwifi-3168-29.ucode
firmware:       iwlwifi-3160-17.ucode
firmware:       iwlwifi-7260-17.ucode
firmware:       iwlwifi-8265-33.ucode
firmware:       iwlwifi-8000C-33.ucode
firmware:       iwlwifi-9260-th-b0-jf-b0--33.ucode
firmware:       iwlwifi-9260-th-a0-jf-a0--33.ucode
firmware:       iwlwifi-9000-pu-a0-jf-b0--33.ucode
firmware:       iwlwifi-9000-pu-a0-jf-a0--33.ucode
firmware:       iwlwifi-Qu-a0-jf-b0--33.ucode
firmware:       iwlwifi-Qu-a0-hr-a0--33.ucode
alias:          pci:v00008086d00002720sv*sd00001080bc*sc*i*
[...]
alias:          pci:v00008086d00004232sv*sd00001201bc*sc*i*
depends:        cfg80211
intree:         Y
name:           iwlwifi
vermagic:       4.13.0-kali1-amd64 SMP mod_unload modversions 
parm:           swcrypto:using crypto in software (default 0 [hardware]) (int)
parm:           11n_disable:disable 11n functionality, bitmap: 1: full, 2: disable agg TX, 4: disable agg RX, 8 enable agg TX (uint)
parm:           amsdu_size:amsdu size 0: 12K for multi Rx queue devices, 4K for other devices 1:4K 2:8K 3:12K (default 0) (int)
parm:           fw_restart:restart firmware in case of error (default true) (bool)
parm:           antenna_coupling:specify antenna coupling in dB (default: 0 dB) (int)
parm:           nvm_file:NVM file name (charp)
parm:           d0i3_disable:disable d0i3 functionality (default: Y) (bool)
parm:           lar_disable:disable LAR functionality (default: N) (bool)
parm:           uapsd_disable:disable U-APSD functionality bitmap 1: BSS 2: P2P Client (default: 3) (uint)
parm:           bt_coex_active:enable wifi/bt co-exist (default: enable) (bool)
parm:           led_mode:0=system default, 1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0) (int)
parm:           power_save:enable WiFi power management (default: disable) (bool)
parm:           power_level:default power save level (range from 1 - 5, default: 1) (int)
parm:           fw_monitor:firmware monitor - to debug FW (default: false - needs lots of memory) (bool)
parm:           d0i3_timeout:Timeout to D0i3 entry when idle (ms) (uint)
parm:           disable_11ac:Disable VHT capabilities (default: false) (bool)

thomas@pc8-nb:~/Scripte/krackattacks-scripts$ systool -vm iwlwifi
Module = "iwlwifi"

  Attributes:
    coresize            = "167936"
    initsize            = "0"
    initstate           = "live"
    refcnt              = "1"
    taint               = ""
    uevent              = <store method only>

  Parameters:
    11n_disable         = "0"
    amsdu_size          = "0"
    antenna_coupling    = "0"
    bt_coex_active      = "Y"
    d0i3_disable        = "Y"
    d0i3_timeout        = "1000"
    disable_11ac        = "N"
    fw_monitor          = "N"
    fw_restart          = "Y"
    lar_disable         = "N"
    led_mode            = "0"
    nvm_file            = "(null)"
    power_level         = "0"
    power_save          = "N"
    swcrypto            = "1"
    uapsd_disable       = "3"

  Sections:
    .altinstr_replacement= "0xffffffffc0bf940a"
    .altinstructions    = "0xffffffffc0c05690"
    .bss                = "0xffffffffc0c06d40"
    .data.unlikely      = "0xffffffffc0c069cc"
    .data               = "0xffffffffc0c06000"
    .exit.text          = "0xffffffffc0bf9405"
    .gnu.linkonce.this_module= "0xffffffffc0c06a00"
    .init.text          = "0xffffffffc0c0e000"
    .note.gnu.build-id  = "0xffffffffc0bfa000"
    .parainstructions   = "0xffffffffc0c05808"
    .rodata.str1.1      = "0xffffffffc0c015f0"
    .rodata.str1.8      = "0xffffffffc0c02410"
    .rodata             = "0xffffffffc0bfa3e0"
    .smp_locks          = "0xffffffffc0c056ac"
    .strtab             = "0xffffffffc0c16320"
    .symtab             = "0xffffffffc0c0f000"
    .text               = "0xffffffffc0be4000"
    __bug_table         = "0xffffffffc0c062b8"
    __kcrctab_gpl       = "0xffffffffc0bfa310"
    __ksymtab_gpl       = "0xffffffffc0bfa030"
    __ksymtab_strings   = "0xffffffffc0c04a44"
    __mcount_loc        = "0xffffffffc0c04db0"
    __param             = "0xffffffffc0c05410"

How can I fix this?

THX

vanhoefm commented 6 years ago

Is your wifi interface called wlan0? Execute ip link or ifconfig -a to find the name of the wireless interface name, and replace wlan0 in hostapd.conf with the wireless interface name.

cmonty14 commented 6 years ago

The name of the interface is: wlan0

thomas@pc8-nb:~$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
    link/ether f0:de:f1:42:30:19 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
    link/ether 58:94:6b:a4:2a:cc brd ff:ff:ff:ff:ff:ff

This interface name is already configured in krackattacks-scripts/hostapd/hostapd.conf. Please check the attached file in my initial posting.

vanhoefm commented 6 years ago

Another process seems to be using the wlan0 interface. Run airmon-ng check kill to try to determine which process this is, and then kill it. Also try googling for the hostapd error nl80211: Could not configure driver mode .

cmonty14 commented 6 years ago

18

There was a running _wpasupplicant process running.

thomas@pc8-nb:~$ sudo airmon-ng check kill

Killing these processes:

  PID Name
  587 wpa_supplicant

thomas@pc8-nb:~$ ps -ea | grep wpa

However, this won't resolve the error (see below), but there's another interface listed: wlan0mon

thomas@pc8-nb:~/Scripte/krackattacks-scripts/hostapd$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
    link/ether f0:de:f1:42:30:19 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
    link/ether 58:94:6b:a4:2a:cc brd ff:ff:ff:ff:ff:ff
4: wlan0mon: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UNKNOWN mode DEFAULT group default qlen 1000
    link/ieee802.11/radiotap 58:94:6b:a4:2a:cc brd ff:ff:ff:ff:ff:ff
thomas@pc8-nb:~$ cd Scripte/krackattacks-scripts/hostapd/
thomas@pc8-nb:~/Scripte/krackattacks-scripts/hostapd$ sudo ~/Scripte/krackattacks-scripts/krackattack/krack-test-client.py 
[00:55:37] Note: disable Wi-Fi in network manager & disable hardware encryption. Both may interfere with this script.
[00:55:38] Starting hostapd ...
Configuration file: hostapd.conf
nl80211: Could not configure driver mode
nl80211: deinit ifname=wlan0 disabled_11b_rates=0
nl80211 driver initialization failed.
wlan0: interface state UNINITIALIZED->DISABLED
wlan0: AP-DISABLED 
hostapd_free_hapd_data: Interface wlan0 wasn't started
connect exception  hostapd_ctrl/wlan0 9877
[00:55:39] It seems hostapd did not start properly, please inspect its output.
[00:55:39] Did you disable Wi-Fi in the network manager? Otherwise hostapd won't work.
Traceback (most recent call last):
  File "/home/thomas/Scripte/krackattacks-scripts/krackattack/krack-test-client.py", line 612, in <module>
    attack.run(test_grouphs=test_grouphs, test_tptk=test_tptk)
  File "/home/thomas/Scripte/krackattacks-scripts/krackattack/krack-test-client.py", line 474, in run
    self.hostapd_ctrl = Ctrl("hostapd_ctrl/" + self.nic_iface)
  File "/home/thomas/Scripte/krackattacks-scripts/krackattack/wpaspy.py", line 49, in __init__
    socket.SOCK_DGRAM)
socket.gaierror: [Errno -3] Temporary failure in name resolution
[00:55:39] Closing hostapd and cleaning up ...
vanhoefm commented 6 years ago

Try to manually start a hostapd instance yourself first. From the krackattack directory execute sudo ../hostapd/hostapd hostapd.conf. If that fails, the problem is with hostapd itself and/or your system and/or the wireless card.

cmonty14 commented 6 years ago

I found some info...

thomas@pc8-nb:~$ lspci -k | grep -A 3 -i "network"
00:19.0 Ethernet controller: Intel Corporation 82577LM Gigabit Network Connection (rev 06)
    Subsystem: Lenovo 82577LM Gigabit Network Connection
    Kernel driver in use: e1000e
    Kernel modules: e1000e
00:1a.0 USB controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 06)
--
03:00.0 Network controller: Intel Corporation Centrino Advanced-N 6200 (rev 35)
    Subsystem: Intel Corporation Centrino Advanced-N 6200 2x2 AGN
    Kernel driver in use: iwlwifi
    Kernel modules: iwlwifi
thomas@pc8-nb:~$ modinfo iwlwifi | grep 'depend'
bash: modinfo: Kommando nicht gefunden.
thomas@pc8-nb:~$ sudo modinfo iwlwifi | grep 'depend'
depends:        cfg80211

My understanding is that my wifi network controller "Intel Corporation Centrino Advanced-N 6200" does only support kernel driver cfg80211 and not mac80211 interface which is supported by hostapd.

However this should work with nl80211 according to this wiki if hostapd is compiled with nl80211 driver support.

cmonty14 commented 6 years ago

I conclude that this issue is related to hostapd only and I will continue testing with the hostapd release provided by my linux distrubution "Kali Linux 17.2".

vanhoefm commented 6 years ago

For other users viewing this issue: as 74cmonty mentioned in #18, the root cause is likely that the WLAN card does not support AP mode.

The Arch documentation on a software access points describes this in more detail, and explains how to check if your card supports AP mod. Simplified, execute:

iw list | grep AP$

and see if AP mode is listed

bus7d commented 5 years ago

Hello there , I stumped into the same issue and I followed this thread to try to debug it and nothing can resolve it./// If anyone have an idea? arf...thx

Distro: Archlinux

_Interface name: OK _AP MODE: OK _hostadp-wpe hostap.conf: OK _hostapd.conf and hostapd-wpe.conf have same config : OK _airmon-ng check kill:OK

so the error:

ioctl[PRISM2_IOCTL_PRISM2_PARAM]: Operation not supported
could not enable hostapd mode for interface wlp2s0
hostap driver initialization failed.
hostapd_free_hapd_data: Interface wlp2s0 wasn't started

thx

ptdropper commented 5 years ago

Hi bus7d

I am no expert at the krackattacks-scripts just a user of them. BUT I am a long time Linux driver developer. The first line of the error message indicates that the scripts are sending a special message to the wireless driver to doe something and that driver does not have the ability to perform the special function. Using the krackattack scripts, I had issues with various wireless hardware and driver combinations on my 2 different laptops. I then read through the various readme files in the code to find the short list of known working hardware and I bought one. They are cheap and they work. But as the code shows not all hardware can support the special features necessary to run the krackattack-scripts. The scripts use special features to inject issues to force the problem. Just my opinion,

On Wed, Dec 26, 2018 at 3:50 PM bus7d notifications@github.com wrote:

Hello there , I stumped into the same issue and I followed this thread to try to debug it and nothing can resolve it./// If anyone have an idea? arf...thx

Distro: Archlinux

_Interface name: OK _AP MODE: OK _hostadp-wpe hostap.conf : OK _airmon-ng check kill:OK

so the error:

ioctl[PRISM2_IOCTL_PRISM2_PARAM]: Operation not supported could not enable hostapd mode for interface wlp2s0 hostap driver initialization failed. hostapd_free_hapd_data: Interface wlp2s0 wasn't started

thx

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vanhoefm/krackattacks-scripts/issues/17#issuecomment-450024503, or mute the thread https://github.com/notifications/unsubscribe-auth/AG_1NWsSy2VX6A43vA_t9jU8kux2T1hdks5u8-EogaJpZM4Qaz84 .

-- Robert Smigielski

bus7d commented 5 years ago

Thx ptdropper, the problem was solved by moving to kali linux live and specifying the driver "nl80211" in hostapd.conf.

sliddjur commented 5 years ago

Hello, sorry for repoening this issue. I have the same problem with:

OS: kali linux 2019.3 Card: awus036ach and awus036nha Card name: wlan0 Driver: rtl88xxau (from Package: realtek-rtl88xxau-dkms, Version: 5.2.20.2~20190617-0kali1)

Any suggestions?

root@kali:~/eaphammer# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Vendor Specific Class, Driver=rtl88xxau, 5000M

This test is with ach card, but the same issue occur with nha card.


                     .__                                         
  ____ _____  ______ |  |__ _____    _____   _____   ___________ 
_/ __ \\__  \ \____ \|  |  \\__  \  /     \ /     \_/ __ \_  __ \
\  ___/ / __ \|  |_> >   Y  \/ __ \|  Y Y  \  Y Y  \  ___/|  | \/
 \___  >____  /   __/|___|  (____  /__|_|  /__|_|  /\___  >__|   
     \/     \/|__|        \/     \/      \/      \/     \/       

                        Rogue AP attacks for operators.

                             Version:  1.7.0
                            Codename:  Power Overwhelming
                              Author:  @s0lst1c3
                             Contact:  gryan@specterops.io

[?] Am I root?
[*] Checking for rootness...
[*] I AM ROOOOOOOOOOOOT
[*] Root privs confirmed! 8D
[*] Saving current iptables configuration...
[*] Reticulating radio frequency splines...

[*] Using nmcli to tell NetworkManager not to manage wlan0...

100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:01<00:00,  1.00s/it]

[*] Success: wlan0 no longer controlled by NetworkManager.
[*] WPA handshakes will be saved to /root/eaphammer/loot/wpa_handshake_capture-2019-09-02-05-31-12-yXTMKvo3oGQD8fMAA4GZxSCZAf8WAlqP.hccapx

Configuration file: /root/eaphammer/tmp/hostapd-2019-09-02-05-31-12-w1G4flGsszMlyIoZoXD8uIVe9zgu3nGB.conf
[hostapd] AP starting...

nl80211: deinit ifname=wlan0 disabled_11b_rates=0
nl80211 driver initialization failed.
wlan0: interface state UNINITIALIZED->DISABLED
wlan0: AP-DISABLED 
wlan0: CTRL-EVENT-TERMINATING 
hostapd_free_hapd_data: Interface wlan0 wasn't started

I did read this: https://github.com/sensepost/mana/issues/13 and did airmon-ng check and then pkill $process on the ones that ran.

DJ8whd2w8dshd3csbmsab22 commented 4 years ago

Hi, it's rather complicated but i have an answer for u regarding the awus036ach and awus036nha wireless cards with the realtek-rtl88xxau-dkms driver.

Simple answer: AWUS036ACH AND AWUS036NHA ADAPTERS ARE NOT HOSTAPD COMPATIBLE!!

Why?!: The awus036ach and awus036nha adapters both do not support AP mode. Well they do support IBSS mode which can offer the exact same. But the problem lies in hostapd compatibillity.

hostapd needs "AP" mode and not "IBSS" mode. You can fix this by using airbase-ng instead of hostapd to setup fake access-points and evil-twins. Or by using different adapters. (i know it sucks).

This means that some scripts like EAPHAMMER and Airgeddon can not use these wifi adapters because they both use hostapd to start the accesspoints.

(Maybe a driver patch could fix this but i have no clue, but i just wanted to put this out here. ow and please correct me if I'm wrong)

Collin ;)

cyrxdzj commented 2 years ago

I think this article can solve this problem. However, this article is written in Chinese. https://www.cnblogs.com/dakewei/p/5735141.html