Setting Up Fake Wi-Fi Hotspots on Raspberry Pi

Mutt

Professional
Messages
1,371
Reaction score
914
Points
113
Fake Wi-Fi hotspots are created to bypass anti-fraud systems that check geolocation against neighboring Wi-Fi hotspots. To set up a fake Wi-Fi hotspot (e.g. for testing or creating a honeypot) on a Raspberry Pi, you can use tools such as hostapd and dnsmasq. Below is a step-by-step guide for setting up using a Raspberry Pi (using Raspberry Pi OS as an example). Make sure you have a Wi-Fi adapter that supports Access Point mode.

Requirements:​

  • Raspberry Pi with an OS installed (e.g. Raspberry Pi OS).
  • A Wi-Fi adapter that supports AP mode (e.g. built-in Wi-Fi on Raspberry Pi 3/4 or an external USB adapter).
  • Superuser rights (sudo).
  • Connect to the Internet (for example, via Ethernet or a second Wi-Fi adapter if you want to distribute the Internet).

Step 1: Update your system​

  1. Connect to your Raspberry Pi (via SSH or terminal).
  2. Run the commands to update the system:
    Bash:
    sudo apt update
    sudo apt upgrade -y

Step 2: Install the required packages​

Install hostapd (to create an access point) and dnsmasq (for DHCP and DNS):
Bash:
sudo apt install hostapd dnsmasq -y

Step 3: Setting up the Wi-Fi adapter​

  1. Make sure your Wi-Fi adapter supports AP mode. Check this with:
    Bash:
    iw list
    In the output, look for a line with AP in the Supported interface modes section. If it is not there, your adapter does not support access point mode.
  2. If you are using built-in Wi-Fi (eg wlan0), temporarily disable its management:
    Bash:
    sudo systemctl stop dhcpcd
    sudo nmcli radio wifi off

Step 4: Configure hostapd​

  1. Create a configuration file for hostapd:
    Bash:
    sudo nano /etc/hostapd/hostapd.conf
  2. Add the following settings (replace wlan0 with your interface if different):
    Code:
    interface=wlan0
    driver=nl80211
    ssid=FakeWiFi
    hw_mode=g
    channel=6
    macaddr_acl=0
    auth_algs=1
    ignore_broadcast_ssid=0
    wpa=2
    wpa_passphrase=YourPassword
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=TKIP
    rsn_pairwise=CCMP
    • ssid: the name of your fake Wi-Fi hotspot.
    • wpa_passphrase: password for connection (at least 8 characters).
    • channel: Wi-Fi channel (1-13, choose the least busy one).
  3. Specify the path to the configuration file:
    Bash:
    sudo nano /etc/default/hostapd
    Find the line #DAEMON_CONF="" and replace it with:
    Code:
    DAEMON_CONF="/etc/hostapd/hostapd.conf"

Step 5: Configure dnsmasq​

  1. Create a configuration file for dnsmasq:
    Bash:
    sudo nano /etc/dnsmasq.conf
  2. Add the following lines:
    Code:
    interface=wlan0
    dhcp-range=192.168.1.2,192.168.1.100,12h
  3. Set up a static IP for the Wi-Fi interface:
    Bash:
    sudo nano /etc/dhcpcd.conf
    Add to the end of the file:
    Code:
    interface wlan0
    static ip_address=192.168.1.1/24
    nohook wpa_supplicant
  4. Restart dhcpcd:
    Bash:
    sudo systemctl restart dhcpcd

Step 6: Enable Routing (Optional)​

If you want devices connected to the fake access point to have access to the Internet (via Ethernet or another interface), set up routing:
  1. Enable packet forwarding:
    Bash:
    sudo nano /etc/sysctl.conf
    Uncomment or add:
    Bash:
    net.ipv4.ip_forward=1
  2. Apply changes:
    Bash:
    sudo sysctl -p
  3. Configure NAT using iptables (replace eth0 with your internet interface):
    Bash:
    sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
    sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
  4. Save the iptables rules:
    Bash:
    sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
    Set up autoload rules:
    Bash:
    sudo nano /etc/rc.local
    Before exit 0 add:
    Bash:
    iptables-restore < /etc/iptables.ipv4.nat

Step 7: Start the services​

  1. Start hostapd and dnsmasq:
    Bash:
    sudo systemctl unmask hostapd
    sudo systemctl enable hostapd
    sudo systemctl start hostapd
    sudo systemctl enable dnsmasq
    sudo systemctl start dnsmasq
  2. Reboot your Raspberry Pi to check:
    Bash:
    sudo reboot

Step 8: Verification​

  • After rebooting, find the FakeWiFi network on your device (eg smartphone).
  • Connect using the specified password (YourPassword).
  • Make sure your device has an IP address (e.g. 192.168.1.x) and, if necessary, internet access.

Additional tips​

  • Logging connections: To analyze connections to the fake access point, you can set up logging in dnsmasq or use tools such as tcpdump:
    Bash:
    sudo tcpdump -i wlan0
  • Security: If this is a honeypot, make sure the access point is isolated from your main network to minimize risks.
  • Wi-Fi Channel: Use a tool like iwlist wlan0 scan to select the least crowded channel.

If you have any questions or problems with the settings, write and I will help!
 
Top