4

I need to connect to a public wifi hotspot with a Raspberry Pi. The wifi is open but I have to authenticate through a webpage (e.g. on mac a window open with Join "Wifi_network" or on Android "sign in to wi-fi network").

However, I am running the pi headless, so I can't do this manually via a browser. How can I automate this authentication process?

goldilocks
  • 60,325
  • 17
  • 117
  • 234
hotips
  • 343
  • 1
  • 5
  • 10

3 Answers3

3

There are two steps to this. First you have to request the login page from the server, then you have to send it the reply it expects, as if from a web browser.

That may be easy or difficult, but it almost certainly requires some coding since the nature of such login pages varies widely and so the solution must be tailored to it. The first step would be to watch what happens when you do this normally. An invaluable tool for this would be something like firebug which should give you all the information you need, presuming you understand the protocols and technology involved (HTTP, HTML, and likely javascript). Wireshark might also be used.

Once you understand how the login is done, you need to write an HTTP client (most likely, one using SSL/TLS, i.e., an HTTPS client) that will request the page and automate the appropriate exchange. This may be complexified if, e.g., the server uses cookies, and you may have to be very exact in order to "fool" it, since the system may be intended to discourage bots (which is what this client program is). I am certain they cannot make it impossible, however.

Any general purpose programming language will be sufficient for this task although python, perl, ruby, or PHP will probably be the most painless, partially because these languages have a lot of libraries and support for doing things such as parsing HTML.

goldilocks
  • 60,325
  • 17
  • 117
  • 234
-1

Maybe you should write a web crawler/scrapper, there many crawling/scrapping framework that could help, specially for python, you can take a look to scrapy or grab.

Remarque: The scrapper that you write will only help for Wi-Fi routers where you know how the page look (routers) or maybe you should learn artificial intelligence and neural network to make a scrapper who will interacte with any authentication webpage.

Hope my answer helps you :)

-1

I am using puppeteer for this purpose. It is based on nodesjs and provides a javascript interface to control Chromium. It also supports a headless operation.

If you install puppeteer it will automatically install chromium. Unfortunately it will install an x86 version which will not run on raspberry.

So you have to do some additional steps which can be retrieved from

https://code-flow-hjbello.blogspot.com/2018/11/make-puppeteer-work-with-raspbian-vers.html

Martin K
  • 9
  • 1