Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Captive portal on android device

Tags:

I am using my android device as a mobile web server. I want to direct every user that connects through my portable Android hotspot to a specific wellcome page.

Does anybody know how to implement this technique in my device (I believe this is called the captive portal technique)?

like image 898
Panayotis Avatar asked Apr 18 '14 08:04

Panayotis


People also ask

What is captive portal on my Android phone?

The captive portal feature is a software implementation that blocks clients from accessing the network until user verification has been established. You can set up verification to allow access for both guests and authenticated users.

Why is captive portal on my phone?

Captive portal login is what public Wi-Fi routers use to grant access. When you connect to a public Wi-Fi and it redirects you to a screen asking you to agree to the terms of use, that is the captive portal login in action. Welcome to Android Central!

Why is my wi-fi captive portal?

A captive portal is a web page displayed to newly connected users of a WiFi network. It requires some sort of interaction before granting access to network resources. In other words – if you want to connect to a network that runs that, you need to go through a captive portal first.


2 Answers

I answer my own question until someone shares some useful information on how to implement the captive portal in a non-rooted device.

At the moment I am not aware of such working solution.

Captive portal works by intercepting most network packets (using a firewall), regardless of address or port, until the user opens a browser and tries to access the web. At that time the browser is redirected to a web page which may require authentication et.c.

So for a captive portal solution to exist, many parts like a software firewall/router/webserver need to integrate and cooperate. Given the current restrictions/permissions in a non-rooted phone, I now believe that such application won't likely exist.

@mmm2006: However, if you do have a rooted device there are apps like Paywall that can do the trick for you.

You can also try to implement your own captive portal solution. It's not trivial but since Android is based on the Linux kernel, you could try something like these:

  • Captive Portal Using PHP and iptables Firewall on Linux
  • Using iptables and PHP to create a captive portal
like image 145
Panayotis Avatar answered Nov 02 '22 16:11

Panayotis


I'm not sure about doing this on android devices (I got here searching how to disable the android check for captivate), but I setup dnsmasq on a raspberry pi, operating as a WiFi access point using hostapd, so that all traffic would come to the device (and then use nginx to either offer either a default page or a domain-specific virtualhost setup).

This seems to trigger my Android 7.0 into believing there is a captivate portal (which weirdly directs me to captivate.apple.com, which shows me my default URL).

Perhaps this will help you to assess the underlying linux system components you need to implement something similar. Sorry it doesn't fully answer your question.

like image 30
MrMesees Avatar answered Nov 02 '22 18:11

MrMesees