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
hostapdis not already auto-started somewhere else and it's not actually your script doing the down/up later?