1

My hostapd, after some minutes of execution, it does this:

wlan1: INTERFACE-DISABLED
wlan1: INTERFACE-ENABLED

then, connected clients lose connection and, if i try reconnecting, it wont't connect anymore. I also tried with WPA2, but if reconnecting it says wrong password.

My hostapd.conf:

interface=wlan1
driver=nl80211
ssid=the-bash-guy
hw_mode=g
channel=6
macaddr_acl=0
ignore_broadcast_ssid=0
ieee80211n=1
wme_enabled=1

My dnsmasq.conf:

interface=wlan1
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
server=8.8.4.4
log-queries
log-dhcp
listen-address=127.0.0.1

Before starting hostapd, i did these (.sh file):

echo "BEFORE MONITOR MODE\n\n"
iwconfig wlan1
ifconfig wlan1 down
iwconfig wlan1 mode monitor
ifconfig wlan1 up
echo "AFTER MONITOR MODE\n\n"
iwconfig wlan1
echo "\n\nSTART HOSTAPD!\n\n"
ifconfig wlan1 192.168.1.1 netmask 255.255.255.0
hostapd ./hostapd.conf

then:

iptables --table nat --append POSTROUTING --out-interface wlan0 -j MASQUERADE
iptables --append FORWARD --in-interface wlan1 -j ACCEPT
dnsmasq -C dnsmasq.conf -d

(wlan0 is Intel Wi-Fi AX200)

(wlan1 is RTL8812BU with the following driver: https://github.com/morrownr/88x2bu-20210702)

OS: 5.16.0-kali7-amd64

5
  • Are you sure your hostapd is not already auto-started somewhere else and it's not actually your script doing the down/up later? Commented Apr 22, 2022 at 9:54
  • Yes, the hostapd service is masked. Commented Apr 22, 2022 at 9:57
  • not really about the problem: monitor mode isn't AP mode: hostapd will set it in AP mode anyway later. Is there a reason you're doing this? Commented Apr 22, 2022 at 20:12
  • wanted to pentest my devices for fun Commented Apr 23, 2022 at 19:29
  • setting the interface in unmanaged mode seems to work Commented Apr 23, 2022 at 21:25

1 Answer 1

0

After a few hours I figured something out that works for me.
First of all, I just want a WarDrive.

Normally you just start your Pi and done. Everything is stored on a USB-Drive.
But I don't like that idea. So an AP, without Internet would be nice.
But with the Onboard Wifi Chip !!!(WLAN0)!!!
Here I use an RPI4 2GB

And Yes...
Every 5 mins there is a DISABLED/ENABLED

>┌──(kali㉿kali-raspberry-pi)-[~/start]  
└─$ date  
Sat Jan 28 10:37:17 AM GMT 2023
>
>┌──(kali㉿kali-raspberry-pi)-[~/start]  
└─$ sudo hostapd /etc/hostapd/hostapd.conf
>
>wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE  
wlan0: interface state COUNTRY_UPDATE->ENABLED  
wlan0: AP-ENABLED
wlan0: INTERFACE-DISABLED
wlan0: INTERFACE-ENABLED
wlan0: INTERFACE-DISABLED
wlan0: INTERFACE-ENABLED
wlan0: interface state ENABLED->DISABLED
wlan0: AP-DISABLED
wlan0: CTRL-EVENT-TERMINATING
>                                                                                                                    
>┌──(kali㉿kali-raspberry-pi)-[~/start]  
└─$ date  
Sat Jan 28 10:51:50 AM GMT 2023

That sucks...

I searched for an Timeout/Release in every config.
Changed much and nothing helps...
Even sudo hostapd -dd /etc/hostapd/hostapd.conf doesn't give useful information. Or a log file...

So I installed a clean Kali. I use the Release: 2022.4

After the installation I used:

sudo apt update && sudo apt upgrade -y && reboot now

I also installed

sudo apt install dnsmasq  
sudo apt install hostapd 

My dnsmasq.conf (/etc/dnsmasq.conf) looks like this:

>interface=wlan0  
dhcp-range=192.168.100.2,192.168.100.10,24h  
dhcp-option=option:dns-server,192.168.100.1

My hostapd.conf (/etc/hostapd/hostapd.conf) looks like this:

>interface=wlan0  
#driver=nl80211  
country_code=AT  
ssid=WarDrive  
hw_mode=g  
ieee80211n=1  
channel=13  
macaddr_acl=0  
auth_algs=1  
wpa=2  
wpa_passphrase=12345678  
wpa_key_mgmt=WPA-PSK  
wpa_pairwise=TKIP  
rsn_pairwise=CCMP  

As there is no Internet on the Raspi I don't need an IP table forwarding.

The dnsmasq gets an auto start by using:

sudo systemctl enable dnsmasq

I have to set the IP range for my WLAN0 manually:

sudo ifconfig wlan0 up 192.168.100.1 netmask 255.255.255.0

My iwconfig

>┌──(kali㉿kali-raspberry-pi)-[~/start]  
>└─$ iwconfig  
>lo        no wireless extensions.
>
>eth0      no wireless extensions.
>
>wlan0     IEEE 802.11  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=31 dBm  
          Retry short limit:7   RTS thr:off   Fragment thr:off  
          Power Management:on

The wlan0 is in Managed mode. And no Access Point is Associated.

Now we can start the hostapd, but in this state its Disabling/Enabling itself.
So I decided to stop there and dont use the RPI as an AP...

If you want it as an WarDrive you can use airmon.
To start airmon you have to check processes that could cause troubles.

>┌──(kali㉿kali-raspberry-pi)-[~/start]  
>└─$ sudo airmon-ng check  
>
>Found 3 processes that could cause trouble.  
>Kill them using 'airmon-ng check kill' before putting  
>the card in monitor mode, they will interfere by changing channels  
>and sometimes putting the interface back in managed mode  
>  
>    PID Name  
>    306 dhclient  
>    459 NetworkManager  
>    494 wpa_supplicant  
>

To go on, we use command sudo airmon-ng check kill That kills dhclient and wpa_supplicant.
NetworkManager is still running.

And that's it!

I really accidentally started hostapd. And it stays Enabled ^.-
(sudo hostapd /etc/hostapd/hostapd.conf)

I rebooted and started hostapd again. And it won't work DISABLED/ENABLED
I used sudo airmon-ng check kill again and started hostapd.
And it stays ENABLED ....

>┌──(kali㉿kali-raspberry-pi)-[~/start]  
>└─$ date  
>Sat Jan 28 11:58:15 AM GMT 2023  
>
>┌──(kali㉿kali-raspberry-pi)-[~/start] 
>└─$ sudo hostapd /etc/hostapd/hostapd.conf  
>wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE  
>wlan0: interface state COUNTRY_UPDATE->ENABLED  
>wlan0: AP-ENABLED  
>wlan0: STA de:26:19:22:36:93 IEEE 802.11: associated  
>wlan0: AP-STA-CONNECTED de:26:19:22:36:93  
>wlan0: STA de:26:19:22:36:93 RADIUS: starting accounting session 9B9C755AB07529A0  
>wlan0: STA de:26:19:22:36:93 WPA: pairwise key handshake completed (RSN)  
>wlan0: EAPOL-4WAY-HS-COMPLETED de:26:19:22:36:93  
>wlan0: STA de:26:19:22:36:93 IEEE 802.11: disassociated  
>wlan0: AP-STA-DISCONNECTED de:26:19:22:36:93  
>wlan0: STA de:26:19:22:36:93 IEEE 802.11: associated  
>wlan0: AP-STA-CONNECTED de:26:19:22:36:93  
>wlan0: STA de:26:19:22:36:93 RADIUS: starting accounting session 71C186FC5DB118F4  
wlan0: STA de:26:19:22:36:93 WPA: pairwise key handshake completed (RSN)  
wlan0: EAPOL-4WAY-HS-COMPLETED de:26:19:22:36:93  
wlan0: interface state ENABLED->DISABLED  
wlan0: AP-STA-DISCONNECTED de:26:19:22:36:93  
wlan0: AP-DISABLED  
wlan0: CTRL-EVENT-TERMINATING  
nl80211: deinit ifname=wlan0 disabled_11b_rates=0  
>
>┌──(kali㉿kali-raspberry-pi)-[~/start]    
>└─$ date  
>Sun Jan 29 01:36:20 PM GMT 2023  

Here yo can see 2 connections
One Yesterday and one today for testing if its still running.

The AP on this RPI works like a Charm even with a vncserver :1

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.