5. Project Atropa: Creating a Honeypot
![]()
Raspberry Pi Hacks – Facebook – In previous parts of our series on creating “rogue Raspberries,” we showed how to install the Raspbian operating system and ASP.NET 5 on a Raspberry Pi and publish the application on the Internet using Nginx. Today, we will turn the Raspberry into a Wi-Fi honeypot: a Wi-Fi access point that lets anyone connect and directs all HTTP requests to itself.
Does My Wi-Fi Adapter Support AP Mode?
The key to success is having a Wi-Fi network adapter that supports AP mode. In the introductory part, I recommended the TP-LINK TL-WN722N, which supports AP mode. If you have a different one and are not sure, check it.
Start by installing the iw utility with sudo apt-get install iw -y. Among other things, it can list your Wi-Fi adapter’s capabilities. Then use iw list to list all Wi-Fi adapters in your system and their capabilities.
Find their Supported interface modes section and look for AP mode. If you cannot find it, buy a different adapter.
Creating a Wi-Fi AP with hostapd
Throughout this guide, I will assume that your Wi-Fi adapter is called wlan0, which is probably true if you have only one adapter in the system. If you are unsure, check with iwconfig, which lists all wireless network adapters in your system:
*pi@raspberrypi ~ $* **iwconfig**
wlan0 IEEE 802.11bgn ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
lo no wireless extensions.
eth0 no wireless extensions.
Hostapd is a program that turns your Raspberry Pi into a Wi-Fi access point. Install it with sudo apt-get install hostapd -y. Then create its configuration file with sudo nano /etc/hostapd/hostapd.conf. Enter the following contents:
interface=wlan0
driver=nl80211
ssid=Internet
channel=6
Then save the changes (Ctrl + X, Y, ENTER). The parameters mean the following:
- interface is the interface name, wlan0 in our case.
- driver is the driver name. Unless you have a really old or really unusual adapter, it will be nl80211.
- ssid is the network name, Internet here.
- channel is the channel number. Choose one that will not conflict with nearby networks.
Next, we need to tell hostapd where to find the configuration. Open its startup script with sudo nano /etc/init.d/hostapd and find the line beginning DAEMON_CONF =. After the equals sign, enter the path to the configuration file. The whole line will therefore look like this:
DAEMON_CONF=/etc/hostapd/hostapd.conf
Then save the changes (Ctrl + X, Y, ENTER).
Use sudo update-rc.d hostapd defaults to make hostapd start automatically after a reboot.
We have now configured our computer as an AP for the Internet network, which is completely open (without a password). We will not start it yet, however, because clients would be unable to connect anyway, as they would not receive an address through DHCP.
Installing and Configuring dnsmasq
Dnsmasq is a program that acts as a simple DNS and DHCP server. Install it with sudo apt-get install dnsmasq -y. Then open its configuration file with sudo nano /etc/dnsmasq.conf. Add the following at the end of the file:
log-facility=/var/log/dnsmasq.log
address=/#/10.0.0.1
interface=wlan0
dhcp-range=10.0.0.10,10.0.0.250,1h
no-resolv
log-queries
Then save the changes (Ctrl + X, Y, ENTER). This configuration assigns everyone connected through the wlan0 interface an IP address in the 10.0.0.100-250 range and answers all DNS queries with 10.0.0.1. That will be our computer’s address, so whatever the user queries, they will be redirected to our local web server. We will also log all DNS queries to /var/log/dnsmasq.log.
Use sudo update-rc.d dnsmasq defaults to make dnsmasq start automatically after a reboot.
Network and Firewall Settings
We will begin by blocking all ports on the wlan0 interface in the firewall except HTTP, DHCP and DNS. Enter the following commands:
sudo iptables -F
sudo iptables -i wlan0 -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -i wlan0 -A INPUT -p udp --dport 53 -j ACCEPT
sudo iptables -i wlan0 -A INPUT -p udp --dport 67:68 -j ACCEPT
sudo iptables -i wlan0 -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -i wlan0 -A INPUT -j DROP
sudo sh -c "iptables-save > /etc/iptables.rules"
These configure the system to drop all packets except DNS (port 53 UDP), DHCP (ports 67-68 UDP) and HTTP (port 80 TCP). The settings apply only to wlan0, so you can still connect normally through wired Ethernet. The final command exports the iptables settings to /etc/iptables.rules, from which we will load them later.
Next, we will give our wireless adapter the fixed IP address 10.0.0.1 and ensure that the rules above are loaded at startup. Edit the configuration file with sudo nano / etc / network / interfaces. Delete the entire section relating to wlan0 from this file (Ctrl + K deletes a whole line). Replace it with the bold text in the following listing, which also includes the other interfaces’ configuration for reference – in other words, the entire file on my RPi:
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet manual
**iface wlan0 inet static
address 10.0.0.1
netmask 255.255.255.0
broadcast 255.0.0.0
pre-up iptables-restore < /etc/iptables.rules**
auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Then save the changes (Ctrl + X, Y, ENTER).
The final thing to ensure is that we do not become victims of our own honeypot: the Raspberry Pi itself must be able to perform working DNS resolution, rather than resolving everything to itself. We will therefore configure it to use Google’s DNS server explicitly. Open the configuration file with sudo nano /etc/resolvconf.conf, uncomment the line beginning # name_servers = and replace 127.0.0.1 with the address of the DNS server you want to use, such as 8.8.8.8. After the changes, the whole file will look like this:
# Configuration for resolvconf(8)
# See resolvconf.conf(5) for details
resolv_conf=/etc/resolv.conf
# If you run a local name server, you should uncomment the below line and
# configure your subscribers configuration files below.
**name_servers=8.8.8.8**
# Mirror the Debian package defaults for the below resolvers
# so that resolvconf integrates seemlessly.
dnsmasq_resolv=/var/run/dnsmasq/resolv.conf
pdnsd_conf=/etc/pdnsd.conf
unbound_conf=/var/cache/unbound/resolvconf_resolvers.conf
Then save the changes (Ctrl + X, Y, ENTER).
Testing the Honeypot
Begin by restarting the Raspberry with sudo reboot. Wait for it to start. Then connect to the open Internet network (or whatever you named it) and enter any web address in your browser. You will be redirected to the home page of our sample ASP.NET application.
In the next part, we will show how to configure the application to collect users’ passwords.
Link to the next – upcoming article.
- Project Artropa: How to Turn a Raspberry Pi into a Rogue Device with .NET
- Project Atropa: Setting Up Raspberry Pi and Raspbian Linux
- Project Atropa: How to Get ASP.NET 5 Running on Linux
- Project Atropa: Automatically Starting the Website and Publishing through nginx
- Project Atropa: Creating a Honeypot
- Project Atropa: Creating a Captive Portal
- Project Atropa: How to Defend Yourself?











