6. Project Atropa: Creating a Captive Portal
![]()
Raspberry Pi Hacks – Facebook – In the sixth part of our series on creating “rogue Raspberries” for social engineering attacks, we will show how to create a web application that poses as an authentication captive portal and attempts to trick users into revealing login credentials for popular services. We will use ASP.NET 5 and MVC 6. The application is fairly trivial, and the same result could undoubtedly be achieved using simpler means. I chose ASP.NET 5 and MVC 6 because I wanted to try the new platform and also try running something a little more substantial than the obligatory “Hello World!” in .NET on Linux.
Non-destructive
deterrence of
rodents,
wildlife
and snakes.
User Experience
What will our application do? When a user connects to the open Wi-Fi hotspot, every HTTP request will be routed to our application. It shows a neat dialog and offers Internet access if the user signs in through services such as Facebook, Twitter, Google Account, Microsoft Account or the local Seznam.cz:

The list of services is configurable; to make changes, simply edit config.json and add an appropriately named image file. After the user selects a service by clicking it, a login dialog appears and asks for a username or password for that service:

Regardless of the password entered, the following error page will be displayed after submission:

In my opinion, everything looks very elegant and professional. Frankly, at least in terms of appearance and mobile device support, the application is better designed than most real login portals.
Unlike those portals, however, it does not give the user Internet access; it simply records the entered username and password in a plain text file.
Application Configuration
The application is written in ASP.NET 5 and MVC 6, in Visual Studio 2015. It is very simple: it contains one controller with four actions, three views and a whole one model. You can find the source code on GitHub. Two releases are available. Version 1.0.0-alpha is an absolutely minimal implementation in which everything is hard-coded and the application has no graphics worth mentioning. Version 1.0.0 is already a complete application with configuration and graphics.
The application’s configuration is a key component, because it determines what will actually happen. I use the new configuration system in ASP.NET 5, which is quite well designed but poorly documented. I will devote a separate article to how it works; here, I will only explain how to use it. The application is controlled by config.json, which looks like this by default:
{
"ForceHostName": "www.wifigate-login.local",
"OutputFileName": "wwwroot/passwords.txt",
"MaximumPasswordLength": 4,
"IdentityProviders": [
{
"Id": "facebook",
"Title": "Facebook"
},
{
"Id": "google",
"Title": "Google Account"
},
{
"Id": "twitter",
"Title": "Twitter"
},
{
"Id": "microsoft",
"Title": "Microsoft Account"
},
{
"Id": "seznam",
"Title": "Seznam.cz"
}
]
}
The configuration values mean the following:
- ForceHostName is the server name to which the user will be redirected after reaching the application. The purpose is to make the interface more credible, because authorization portals usually behave this way. You can enter any address here – existing, non-existent, even one with an invented top-level domain. Or, like me, you can use the standardized “.local” domain for local networks. After the configuration described in the previous part, any DNS query will resolve to our honeypot’s address anyway. This parameter is optional: if its value is empty or absent, no redirection takes place. It is also disabled when the application runs in the development environment.
- OutputFileName is the name of the output file where captured passwords will be saved. The path is relative to the application’s root. In this example, the data will be saved in a file available at http: //adresa-honeypotu/passwords.txt.
- MaximumPasswordLength is the number of characters of the password that will be stored. Since I intend to use the entire application for teaching purposes and show users the results online, I do not want to store complete passwords. Only the first few characters (four here) will be saved; the rest of the password will be replaced with asterisks.
- IdentityProviders is the list of services through which we want to allow login (whose login credentials we want to obtain). For each, we specify its Id and Title. The Id parameter forms part of the URL and is also used as the filename of the logo image. It should therefore be a “safe” string that can be used as a filename and path. Title is the human-readable name of the service. The number of identity providers is unlimited; I chose the four most popular services plus the local favorite, Seznam.cz.
How Does the Application Work?
I will write a more detailed article about developing applications in ASP.NET 5 another time; for now, briefly:
- project.json is extremely important because it holds the whole application together. It can be described as a cross between the .csproj and packages.config files from previous versions. It contains a list of NuGet packages as well as build instructions. My file is more or less in its default state; I only added support for Kestrel, which we will need to run on Linux.
- Startup.cs is the OWIN Startup Class. Its code runs first when the application starts and initializes the entire application. It is a kind of cross between Global.asax and web.config in previous versions. In its constructor, I load the configuration described above. In ConfigureServices, I register the services that will later be used for dependency injection. In Configure, I specify which OWIN middleware components (the equivalent of HTTP modules and handlers in older versions) will be used, and so on.
- hosting.ini is a file left over from the default template and, frankly, I have not yet worked out what it is for. I will have to look into it later.
- GlobalSuppressions.cs does not affect the running of the application. In Visual Studio 2015, I use the Refactoring Essentials plugin, which monitors adherence to coding standards and offers refactoring for common violations. I dislike some of its rules, and this file lets me disable them at project level.
- WifiGateOptions.cs is the model used for configuration.
The remaining files are standard and do not differ substantially from a normal ASP.NET MVC application.
Deploying to the Honeypot
Connect the Raspberry prepared according to the previous parts of the series to the same wired network as the control computer and switch it on. We need to copy the application onto it, which can be done in many ways. I will use SCP, which transfers files over SSH. If you installed PuTTY, as I encouraged you to do in part two, you have the pscp.exe command-line utility available.
On the Raspberry Pi, delete the contents of the folder containing the web server files, / home / pi / www / wifigate, but not the folder itself. You can do this, for example, using rm -rf / home / pi / www / wifigate / *.
Then use pscp.exe to copy the source code of the WifiGate application. Use the following command, but run it on Windows:
pscp -r -batch -C -pw raspberry "C:\Users\Altair\Source\Repos\WifiGate\src\WifiGate\*" pi@10.7.0.103:/home/pi/www/wifigate
The parameters mean the following:
–r works recursively, copying subdirectories as well.
–batch does not prompt before overwriting files.
–C uses compression during transfer.
–pw raspberry lets you specify the password (raspberry in this case).
“C: \ Users \ … \ *” specifies which files to transfer. Here, everything in the WifiGate folder; quotation marks are required if the path contains spaces.
The final parameter specifies where the data should be copied. The format is user @ host: path. Here, I connect as user pi to the computer at 10.7.0.103 and save to / home / pi / www / wifigate.
After copying the files, reconnect to the Raspberry and restore the NuGet packages using dnu restore / home / pi / www / wifigate.
Now restart the Raspberry and wait for it to boot. If you have done everything correctly, after restarting the honeypot will broadcast an open network called Internet. When you connect to it, any HTTP request will be redirected to the fake portal address, and you will be prompted to enter a password. You will find the captured passwords at the gateway address in passwords.txt.
In the final part of the series, we will show how to defend against this type of attack from the user’s and the server author’s perspectives.
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?










