Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Captive Portal Page with MITM

I have a micro-computer designed to show customers a portal page when they sign-in the Wi-Fi network.

The problem is that for some reason they don't get the usual popup from the phone/pc where as when I do the same with my router it works.

I'm doing the whole process by transferring all dns request to a local network (i.e 10.0.0.2).

When going to the browser they get the portal page, but the behaviour is missing. (connecting to the Wi-Fi then an automatic popup appears saying that you need to log in to the network).

on the local apache i have a simple index.php file with status code of 401 (unauthorised).


The micro-computer is connected via Ethernet port to the router, and I have full-control of the router, yet I want the captive portal be managed from the micro-computer itself, thats why I'm not using router based captive portals.

Tal.

like image 653
Jentel Avatar asked Jun 01 '15 14:06

Jentel


People also ask

What is a captive portal page?

A captive portal is a web page to which a client is redirected when they connect to a guest SSID. The client can gain access to the Internet after they successfully authenticate or accept the terms of use on the portal page.

Can you bypass a captive portal?

In order for a client to bypass the captive portal, they need prior preparation. The client must have an external server pre-configured to act as an endpoint for their different bypass methods.

How do you connect to a captive portal?

Join a captive Wi-Fi networkTap Settings > Wi-Fi. Tap the name of the network, then wait for a login screen to appear. Or tap next to the network's name, then tap Join Network. If prompted, enter a user name and password, enter an email address, or acknowledge terms and conditions.


1 Answers

Your question isn't very clear to me.

Are you using a browser on the phone/pc or an application? Can you provide a screenshot of the expected behavior?

I'll try to answer it from what I think you are asking: For a browser, you can use your DNS or ICMP to redirect a client to your Captive Portal. ICMP is layer 3 protocol and some platforms (like Android) might automatically trigger a native notification to the user, like "Hey you need to sign in". But the DNS redirect won't trigger this, it requires user interaction with a browser after connecting to the network. They'll open a browser, try to go to stack overflow.com and get redirect to your captive portal.

Also, for an application on Android, you have to check a URL connection. Here is an example taken from AOSP:

private static final String mWalledGardenUrl = "http://clients3.google.com/generate_204";
private static final int WALLED_GARDEN_SOCKET_TIMEOUT_MS = 10000;

private boolean isWalledGardenConnection() {
    HttpURLConnection urlConnection = null;
    try {
        URL url = new URL(mWalledGardenUrl); // "http://clients3.google.com/generate_204"
        urlConnection = (HttpURLConnection) url.openConnection();
        urlConnection.setInstanceFollowRedirects(false);
        urlConnection.setConnectTimeout(WALLED_GARDEN_SOCKET_TIMEOUT_MS);
        urlConnection.setReadTimeout(WALLED_GARDEN_SOCKET_TIMEOUT_MS);
        urlConnection.setUseCaches(false);
        urlConnection.getInputStream();
        // We got a valid response, but not from the real google
        return urlConnection.getResponseCode() != 204;
    } catch (IOException e) {
        if (DBG) {
            log("Walled garden check - probably not a portal: exception "
                    + e);
        }
        return false;
    } finally {
        if (urlConnection != null) {
            urlConnection.disconnect();
        }
    }
}
like image 113
Cookster Avatar answered Oct 12 '22 13:10

Cookster