23ewrdtf/Captive-Portal

Allow access

dneufville opened this issue · 8 comments

Hi Great script,
I'm trying to close the splash page and then browse the local site on the client device browser.

So would it be possible to submit a form on the splash page. That will then trick the device to thinking its online. Or simply close the splash page. Effectively an on/off switch controlled within the browser?

Hi, I'll check and come back to you. It might be next week.

Thank you.

I'm not 100% sure but I think the logic of Captive Portal is that once Android/IOS can connect to one of its sites: www.apple.com, captive.apple.com, clients3.google.com, www.msftconnecttest.com, etc then the Captive Portal browser will be closed.
We need to add a button to the site that will "spoof" those servers so Android will think that it has internet.
Not sure yet how. Something to think about.

Yes your right. the button idea is perfect. The problem i have trouble wrapping my head round, is how to make the php back end talk to dnsmaq and iptables to dynamically change those settings for just that session.

I checked links in this issue: #3 and a few more on the internet and I think I would be able to do it.
I would have to check what IOS and Android expect. If they only check the IP address of the domain then it shouldn't be that difficult. If they expect a website then it's more complex.

Someone here also mentioned that: https://stackoverflow.com/questions/23553449/remain-connected-to-wifi-network-that-has-a-captive-portal/26058667

changing http header status to 200 will make most devices think they are connected to the internet. some iso devices need success written into a standard html page as well.

In order to detect a that it has connected to a Wi-Fi network with a captive portal, iOS contacts a number of endpoints hosted by Apple — an example being https://www.apple.com/library/test/success.html. Each endpoint hosts a small HTML page of the form:

<TITLE>Success</TITLE> Success here is more than one way to implement a captive portal.

HTTP redirect
A common method is to direct all World Wide Web traffic to a web server, which returns an HTTP redirect to a captive portal. [3] When a modern, internet-enabled device first connects to a network, it sends out an HTTP request to a detection URL predefined by its vendor and expects an HTTP status code of 200. If the device receives a HTTP 200 status code, it assumes it has unlimited internet access. Captive portal prompts are displayed when you are able to manipulate this first HTTP message to return a HTTP status code of 302 (redirect) to the captive portal of your choice.[4][5]

so for example in your nginx config file you have 302 redirect headers. That's what makes the captive portal screen pop up. if you replace them with 200 and put

success

in the index.php file. then no CP will pop up. But how can this be achieved dynamically for each session?

I think I need to add an option to the script to make it more configurable, and if no parameters are provided it will install with defaults.

Options like: SSID name and mode in which the captive portal would operate.

for example:

captiveportal.sh SSID MODE

Where MODE:

  • default: as it currently is.
  • offline: It would display a button that would close the CP browser but keep connection to the Raspbery pi. No internet access.
  • online: most difficult to do. It would display a button that would close the CP browser but keep connection to the Raspbery pi and allow internet access.

I'm not sure how to achieve this. It would be easier to use python but I want to keep it simple and I don't know python 😄
I can think of a few ways of doing it but those are more stupid hacks than proper way. I'll need to think more about this, and maybe ask stackoverflow 😄

If there is anyone able to help implementing this I'll be glad but I won't be able to do it on my own. Time constraints and skills.