vanhoefm / krackattacks-scripts

Other
3.3k stars 768 forks source link

ctrl_iface not found #18

Open JesGonTej opened 6 years ago

JesGonTej commented 6 years ago

Hi,

Firstly, thanks for all your hard work.

I cannot make it run.

ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:fd:30:4d brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
       valid_lft 82371sec preferred_lft 82371sec
    inet6 fe80::a00:27ff:fefd:304d/64 scope link 
       valid_lft forever preferred_lft forever
6: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 04:f0:21:0e:35:cf brd ff:ff:ff:ff:ff:ff
nano hostapd.conf
# AP netdevice name (without 'ap' postfix, i.e., wlan0 uses wlan0ap for
# management frames with the Host AP driver); wlan0 with many nl80211 drivers
# Note: This attribute can be overridden by the values supplied with the '-i'
# command line parameter.
interface=wlan0
uname -r
4.12.0-kali2-amd64

And this is what the script returns:

[15:24:49] Note: disable Wi-Fi in network manager & disable hardware encryption. Both may interfere with this script.
[15:24:50] Starting hostapd ...
Configuration file: ./hostapd.conf
Could not unlink existing ctrl_iface socket 'hostapd_ctrl/wlan0': No such file or directory
Failed to setup control interface for wlan0
wlan0: Unable to setup interface.
wlan0: interface state UNINITIALIZED->DISABLED
wlan0: AP-DISABLED 
hostapd_free_hapd_data: Interface wlan0 wasn't started
nl80211: deinit ifname=wlan0 disabled_11b_rates=0
connect exception  hostapd_ctrl/wlan0 9877
[15:24:51] It seems hostapd did not start properly, please inspect its output.
[15:24:51] Did you disable Wi-Fi in the network manager? Otherwise hostapd won't work.

It looks like it is trying to open a UDP connection as the line 25 (wpaspy/wpaspy.py) raises an exception. Then the UDP connection with the ctrl_interface cannot be established. Could you help me?

vanhoefm commented 6 years ago

Did you disable Wi-Fi in the network manager? Otherwise hostapd won't work.

JesGonTej commented 6 years ago

Thanks for the prompt response.

I did run: nmcli radio wifi off

It looks down when I run:

ip a
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 2e:8a:6c:83:9d:8f brd ff:ff:ff:ff:ff:ff
vanhoefm commented 6 years ago

Seems like another copy of wpa_supplicant is still running. You're starting the script as root? Try a killall wpa_supplicant to test things. Otherwise search for the error messages that wpa_supplicant is outputting, since this is an issue specific to wpa_supplicant.

JesGonTej commented 6 years ago

Thanks.

Yes, I am running as a root. Killall outputs that no other wpa_supplicant is running.

I searched for the specific wpa_supplicant error. I ended up in line 618 of wpa_supplicant/ctrl_iface_unix.c. If I am not mistaking, it is trying to unlink the path given by by krack-test-client.py is hostapd_ctrl/ (in my case wlan0). However it does not exist. After running the script the folder hostapd_ctrl is created. Is that the right behaviour? What is the purpose of adding hostapd_ctrl to the interface? The name of the interface should be just wlan0, right?

vanhoefm commented 6 years ago

Also try running airmon-ng check kill just to be sure. Are you executing the script from a writable directory? Hostapd must be able to create a new subdirectory. Does the directory hostapd_ctrl already exist somewhere?

JesGonTej commented 6 years ago
root@kali:~# airmon-ng check kill
ls: cannot access '/sys/class/ieee80211/': No such file or directory

Killing these processes:

  PID Name
  482 dhclient

I am running the script as root with 777 permissions in the current directory.

The only hostapd_ctrl directory I can find in the whole system is the one created after running the script. However, it is empty. What is the purpose of it?

cmonty14 commented 6 years ago

Hi! I had a similar issue and reported this #17. In my case I think the root cause is this: WLAN card is not supporting AP mode. This is documented in Debian wiki.

To verify if your WLAN adapter supports AP mode just execute:


iw list | grep AP$```
JesGonTej commented 6 years ago

Hi,

Sorry for the delay in the answer. I managed to solve the issue. There were several things:

So it is now working for me.

I appreciate your effort.

Jesus

AbeElx commented 4 years ago

I'm also trying to get around this problem. Whenever I'm running the script, it gets the "connect exception hostapd_ctrl/wlan0 9877" but when I run hostapd on it's own with the same hostapd.conf, the "rogue ap" works with no problem at all.

L1ghtsou1 commented 9 months ago

Has anyone fixed this error yet?

vanhoefm commented 9 months ago

Can you provide the exact commands you used to run the script? And the Linux distribution/version you are using?

Did you try the steps by JesGonTej?

L1ghtsou1 commented 9 months ago

My version Linux is 6.5.0-kali2-amd64.

┌──(venv)─(root㉿kali)-[/home/kali/Downloads/krackattacks-scripts/krackattack] └─# python3 krack-test-client.py [13:28:04] Note: disable Wi-Fi in network manager & disable hardware encryption. Both may interfere with this script. [13:28:05] Starting hostapd ... Configuration file: /home/kali/Downloads/krackattacks-scripts/krackattack/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 wlan0: CTRL-EVENT-TERMINATING hostapd_free_hapd_data: Interface wlan0 wasn't started connect exception hostapd_ctrl/wlan0 9877 [13:28:06] It seems hostapd did not start properly, please inspect its output. [13:28:06] Did you disable Wi-Fi in the network manager? Otherwise hostapd won't work. Traceback (most recent call last): File "/home/kali/Downloads/krackattacks-scripts/krackattack/krack-test-client.py", line 663, in attack.run(options=options) File "/home/kali/Downloads/krackattacks-scripts/krackattack/krack-test-client.py", line 481, in run self.hostapd_ctrl = Ctrl("hostapd_ctrl/" + self.nic_iface) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/kali/Downloads/krackattacks-scripts/krackattack/wpaspy.py", line 50, in init ai_list = socket.getaddrinfo(path, port, socket.AF_INET, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/socket.py", line 962, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ socket.gaierror: [Errno -2] Name or service not known [13:28:06] Closing hostapd and cleaning up ..." (^.^) Can you help fix this error, pls?

vanhoefm commented 9 months ago

Try to start hostapd directly. It might be that your Wi-Fi card doesn't support AP mode. Disable Wi-Fi in your network manager as well.