PDA

View Full Version : Automate login to public access WiFi hotspots? Fon / BTWiFi


magick777
2013-07-19, 16:01
Until recently, the availability of free or reciprocal WiFi hotspots in the United Kingdom (e.g. Fon / BTWiFi) was not something that one could rely on. So, whilst I've been sharing Internet access via Fon since 2008, my N900 isn't configured to connect to the hotspots that it finds because it hasn't been worth the hassle. As of 2013, this has changed; after a few years of BT's policy of including Fon into its stock routers and opting customers in by default, BTWiFi hotspots can be found within reach of many/most residential dwellings (in London at least).

Still, having the N900 connect to them automatically remains a nuisance. At best, we log on to a network that requires manual authentication to proceed further, knocking the phone offline. At worst, we log on to open networks simply because they're there and not because we intended to, which is a waste of battery and a real nuisance when travelling. How do we fix this, so that using public hotspots becomes a viable proposition from an N900? What do we need to take into account?

Obviously we need some sort of auto-login functionality, akin to autowifi (http://www.manatlan.com/page/autowifi), but we need it to work well for the typical user of a N900, which means we don't want it to interfere with the use of private wireless networks, and we don't want it to interfere with the use of 3G unless we're in a situation where that is going to be helpful - perhaps this is quite a tall order.

Before trying to hack up anything, I'd welcome some input from other seasoned N900 users. Should we do this as a "one-shot" manual connection script that bypasses (and leaves untouched) the N900 settings, configures the wireless interface manually, automates the login, and (optionally) loads a browser pointed to the logout page? In other words: hit the Fon button when desired and the phone does the rest.

Should we favour a fully automated approach, where we do configure the hotspot SSID in the N900 such that it connects automatically and logs in automatically? If so, how shall we have it do this only when we wanted it to? Perhaps perform a manual scan, and only activate the auto-login for APs with a pre-approved MAC address? Might be useful for having it only work automatically in particular locations against particular hotspots.

Perhaps both of the above; a "suck-it-and-see" script that searches for a BTWiFi connection, and keeps a list of "good APs" and "bad APs" based on successful connection, plus auto-connect ability either for known-good APs or for whatever's available.

I'd also like to hear some international perspectives on this; I'm thinking about what's available in London, but it should not be any different, in principle, to support comparable hotspot networks in other countries. Please comment on what is available locally to you, whether you're interested in improving automated access to it, and how you might see that working...

Mric
2013-07-19, 19:21
Yep this app is also needed for the N9 here in Scotland.

Android_808
2013-07-19, 20:07
wonder where my message went. duh! typed in address bar

i imagine connecting to the hotspot and automatically submitting credentials form would suffice. this *could* be as easy as a cleverly constructed bookmark or .desktop file. could launch a script to submit info in background. could rely on a signal (dbus or qt) to submit once connected.

ideal world would be to modify internet connections wizard to allow a hotspot category to submit automatically on.

maybe start by finding whats required fields from forms

magick777
2013-07-19, 20:39
i imagine connecting to the hotspot and automatically submitting credentials form would suffice. this *could* be as easy as a cleverly constructed bookmark or .desktop file. could launch a script to submit info in background. could rely on a signal (dbus or qt) to submit once connected.

ideal world would be to modify internet connections wizard to allow a hotspot category to submit automatically on.

maybe start by finding whats required fields from forms

This is the (relatively) easy part. The login form requires a POST, but it will be fairly simple to whip up an auto-login using curl. We can trigger such an action from dbus, as you say, or possibly from an if-up script on the wireless interface.

Before I rush into doing that, though, there's a problem with when and whether to connect to a (potential) hotspot in the first place; if we have the phone connect and log in by default, then it will do that every time it encounters the given SSID. Which is dozens of times within a half hour bus journey, and for none of them could I have maintained a connection to the hotspot for long enough to use it.

It's probably too much to ask the phone to deduce whether I am on a bus or not, but this is why I am thinking that I don't want to just configure the SSID in the N900 and let it autoconnect. This favours making a more fine-grained assessment of whether we want to try to connect to an available AP or not. Once I've got that figured out (playing with wireless-tools at present) then it should be fairly easy to script up the web-based login for any given provider, but that should be a bolt-on to a means of deciding when and whether to use a hotspot. I'm working on this in the background, but would welcome any thoughts in the meantime...

magick777
2013-07-19, 20:43
Yep this app is also needed for the N9 here in Scotland.

I don't have an N9, but I guess that favours a standard approach using wireless-tools and bog-standard Linux scripting capabilities, rather than an N900-specific app. This is more or less what I had in mind anyway, as I'd like to be able to use the same capability from a laptop or tablet.

rotoflex
2013-07-19, 21:05
Is it just the same login screen at every hotspot? Some guy already created such an N900 app to automatically satisfy them a couple of years ago to log onto the net at his college. It was announced & dstributed via TMO.

Android_808
2013-07-19, 21:24
what if you have it as a menu icon, so credentials only get submitted when you want to?

i personally disable option to scan for wifi, but enable automatic connection. this way it will only try to connect when i want it to. only other way i can think of is to intercept the redirects when not signed in?

magick777
2013-07-19, 23:39
Hmm... apparently, on some further reading, the FON and BTWiFi hotspots natively support autologin via WISPr, which is used in autologin apps for Android, iOS, etc.

Crude client implementations seem to be available in perl (http://people.debian.org.tw/~chihchun/wp-content/uploads/2008/06/fon-wispr.pl) and in python (https://code.google.com/p/wisprclient/source/browse/wisprclient.py), which I am playing around with now. I'll report back if I get anywhere...

magick777
2013-07-20, 19:44
So... I have some (very limited) progress in getting WISPr authentication working against a BTWiFi hotspot. My first forays with the simple client scripts resulted in some not-very-helpful errors, and it was only when I tried a third perl client (https://github.com/matsuu/auwifispot-client/blob/master/wispr_login.pl) that it became clear that I was going to need quite a handful of perl modules to get past detecting the WISPr redirect and actually submit credentials over HTTPS.

After some messing about with CPAN to install XML::Simple and Crypt::SSLeay plus dependencies (libssl-dev needed before you start, plus some familiarity with CPAN advised) I was able to get the client to make an HTTP request, intercept the WISPr redirect, submit my login credentials... and receive "Login failed (Access REJECT)" for pretty much anything I tried.

Documentation on WISPr is pretty scant, but from reading the sources of other clients I suspected that I would need to prefix or suffix my login credentials with a string to indicate that I'm a FON customer as opposed to BTOpenzone or whatever. I'd tried prefixing with FON/ and suffixing with @fon, both without success, when I found (from the source code of the Android WISPr client) that the network prefix seems to be BTFON, so BTFON/user@email.tld as username.

And, lo and behold, it worked! Login succeeded (Access ACCEPT), plus a LogoffURL to call when we want to close the connection. And I can ping Google, so we're online.

So, if nothing else, this confirms that a WISPr login using FON credentials on a BTWiFi hotspot is possible; it should be pretty simple to make this fire automatically from DBUS although I need to figure out exactly which SSIDs it works with, and possibly how to supply credentials to/from other service providers.

There's a glaring vacancy for a WISPr client application for the N900, whether it's based on that bit of perl or not. Android has it, iPhone has it, BTWiFi supports it, I'm surprised that I could find no standard Linux clients for it and no adaptations for the N900. Hopefully, the more networks and the more sets of login credentials this works with, the more reason there is for someone to throw together an implementation of some kind.

More to follow, if I make any further headway with it...

Jaffa
2013-07-22, 03:29
Fredrik Wendt created a Maemo 5 app, Wifi Assistant (http://wiki.maemo.org/Wifi_Assistant) which would make an excellent starting point for this.

His app's behaviour was similar to that built-in to iOS and Harmattan: bringing up a browser. But since the URL was configurable, it also supported auto-login, if the login portal supported GET requests.

magick777
2013-07-22, 09:39
Thanks for this, as you say it is an excellent place to start. I'm no programmer, so for the moment I'm just trying to provide proof of concept and demonstrate a use case.

I suppose I'm also trying to re-interest people in the idea itself; when I got my N900 there just weren't enough WiFi hotspots to make automation a sensible proposition. There are now, according to BT, over five million of them in the UK, and I understand that the national telcos of France, Belgium, Germany, Poland, Brazil and others are doing likewise.

The perl client is not simple or elegant to install on the N900, because of dependencies that aren't easily met by Maemo; having understood how it works and made a successful login, I might look again at the python client as it would be easier to build into wifi assistant.

If I can come up with a "hack" solution that the average user can implement from a simple HOWTO, good enough for now, and as soon as people see the use for it, hopefully someone will build something better. I really think this could be a game-changer for the N900, who needs 4G if you can reliably get on WiFi?

magick777
2013-07-22, 13:33
Some further updates. I've given up on doing this in perl, we'll get further, faster in python, and there's a suggestion to integrate it with an app already written in python.

The python client identified in my earlier post cannot handle HTTPS and doesn't provide any useful response codes. This one does (https://bitbucket.org/tamias/pywispr/src/7b327f10b6cc?at=default), although you'll need to manually install ssl support in python if you don't have it.

However, it provides the guts of a working WISPr routine in python, which could quickly be modified to accept credentials at command line, or doubtless the issue with the XML config file can be found and fixed. I have confirmed a successful login to BTWiFi using this code, although I have not yet gone live with it on my main phone.

The logic in this client is nice; it identifies the captive portal by the domain of the login URL, so if you're presented with a recognised login portal, regardless of the SSID that got you there, then the proper credentials will be selected. It also aborts graciously if we're already connected or there's no WISPr support, so I'd have no problem with running it on every connect. More testing is needed, and maybe a rewrite to use openssl which is more readily available in Maemo, but the guts of what we need is here.

Android_808
2013-07-28, 08:33
It seems that in general support for this is pretty rubbish across Linux in general. Found some proposals for support in NetworkManager but nothing I can see in my distro (Arch) repos.

One thing I'm not sure about is how to handle automatic disconnection periods. IIRC fon/openzone logs out after 15 minutes of inactivity. As a result every now and then we will have to check the status BUT networks can allocate minutes or data restrictions, so we don't want to be checking unnecessary .

jgbreezer
2013-07-31, 02:31
Hi Magick, I'm in about same position. I have a fonera hotspot (well 2 of them actually) in London and have wanted something more automatic as its so much pain to use other people's manually when I have contract-tariff 3G thats more reliable and works as you move between towers. But that data also has its cost/issues.

There are so many non-working fon hotspots/BT ones around ("FON" prefixed SSIDs everywhere else) that I don't bother much nowadays, so only if I KNOW Im connected to a working one from previous experience, do I bother, and obviously if Im hanging out there a while/have a desparate need due to no cell signal or other reasons (eg. near my monthly quota/whatever).

Wifi assistant app was only partly useful, but I agree, should be a good start. Its too slow to start up a full browser in maemo if Im only going to check email/fetch a podcast or other feed update (common task for me). I am a programmer btw, in python and c++ and have been looking at it tonight (hence the google/tmo search that got me here). I'd love to automate a bit more and speed up the Virgin Media wifi access I have underground in the tube stations that requires hitting the landing page the first time per day (or 6hrs ish? guess..) before you can connect to anything else - thats what I've just been automating(ish) a script for. The connectnow-home-widget might (if its open source enough) also provide some useful bits, thats what I've installed recently to aid various wifi connections at a single press and it can do stuff on connect/disconnect (oh but if only I could have it run a script as well as more switching options like wifi-only mode aka tablet mode to save battery on my commute!)

I'm also trying to record my data usage for wifi - its easy on cell data via the sqlite database it gets stored in; a couple of scripts and the Desktop Command Execution Widget show me what I've used/log+reset it each tariff period. But wifi, usage per SSID (or just for one ssid), is not available and I want it! When if-down scripts run, do you still have data in /proc/net/dev available? Do we have a pre-down script too? Or do I have to poll it regularly-ish (or even iptables-plugin-like method) to avoid missing some? Bleurgh if so, polling uses more cpu/battery.

I'd have thought there would be more apps for Linux desktop/laptop PCs that did this that we could look at, although N900 (my target device) may need its own modifications to techniques.

Regarding my mobile dev skills: I wrote the basics of a simple python gtk app a while ago with a couple of screens to get an idea how the event-loop and ui handling works (a london-underground-offline-data-related thing) but never done anything with Qt. Am a pretty skilled developer otherwise though (C++ and others)

Lets do this (and excuse me rambling a bit, its late...)!

PaddyMcMoney
2014-03-23, 06:51
Hi guys, i'm probably in the same position as you guys in terms of searching and messing about trying to get this to work

what am looking to do personally is use PyWispr and then see if i can add that to a .sh file and include a "&& sleep 60" and have it loop from boot, basically i've got my machine downstairs connected to a BTWiFi-With-FON router and i then share that connection to my PS3, soley for updates etc but obviously i have to continuesly login on my main machine alot.

i've tried looking into greasemonkey scripts for the browser and combining it with a autorefresh extension, None have worked successfully so i'm just wondering if any of you guys managed to get it to work specifically in a linux environment?

sorry to bump an old thread but this is the best info i've seen on this so far and believe me i have looked.

Android_808
2014-03-23, 09:16
have you seen the wiki page?

i've been doing some digging and it appears connman supports wispr 1 and 2. maybe it would be possible to adapt thier code to work with our connection daemon.

jgbreezer
2014-03-23, 16:31
Hi guys, i'm probably in the same position as you guys in terms of searching and messing about trying to get this to work

what am looking to do personally is use PyWispr and then see if i can add that to a .sh file and include a "&& sleep 60" and have it loop from boot, basically i've got my machine downstairs connected to a BTWiFi-With-FON router and i then share that connection to my PS3, soley for updates etc but obviously i have to continuesly login on my main machine alot.

i've tried looking into greasemonkey scripts for the browser and combining it with a autorefresh extension, None have worked successfully so i'm just wondering if any of you guys managed to get it to work specifically in a linux environment?

sorry to bump an old thread but this is the best info i've seen on this so far and believe me i have looked.


That sounds like an awkward setup! Do I understand that your machine downstairs is acting as the wifi access point for your BT/FON thing (you said it was sharing the router connection to ps3)?
If that's so, Can I ask why your PS3 is not connected directly to your wifi router using your normal (not "open" fonera ssid)? Wouldn't that be way easier and in at least one way more secure?

I have a couple of Fonera's myself btw, but its pure Fon not BT router with fon support.