how can I automatically log into a network with a captive portal in Windows?

15

I have a WI-FI network at the office that requires logging in with a captive portal (requires logging in with username and password).

I would like to somehow run a script that automatically logs in as soon as I connect to the network (without having to start my browser and keep it open).

Oddly enough, I managed to find such a client for Android (CoovaAX which is no longer available), but not one for windows (I have Windows 7, if it matters).

Does anybody have a simple solution for this? I'd rather not have to spend time to code my own tool for this.

Assaf Stone

Posted 2012-05-31T12:21:59.353

Reputation: 273

@JessRiedel I've posted a new answer that works now and includes a link to a complete guide.

– Menasheh – 2016-11-28T20:19:16.163

Has anyone released a program to solve this problem in the intervening two years? There exist reasonable solutions for Android (https://play.google.com/store/apps/details?id=co.uk.syslynx.wifiwebloginapp&hl=en) and iOS).

– Jess Riedel – 2014-04-24T19:35:52.787

Also, Meta: how do I draw attention to this question? I can't ask my own version since it would be a duplicate, but the answer here is completely out of date and I would like fresh eyes to take a look. – Jess Riedel – 2014-04-24T19:36:52.237

Answers

7

I don't know about simple... I use a tool called webinject.pl in order to test web sites. It's a perl script that allows you to specify inputs and expected results and could easily be configured for this. It might take you an hour to make it work.

As for how to automate it. The Windows Task Scheduler is pretty robust and can trigger on a myriad of events. You could tie it to a logon event or event log entry, or simply have it run every 5 minutes (that's a bit painful). For instance, I get an event 32 in the system log when I establish a network connection. That might do it.

uSlackr

Posted 2012-05-31T12:21:59.353

Reputation: 8 755

@uSlackr Would you be able to provide the code you used for this? – Cameron – 2016-03-16T11:31:56.283

@Cameron Which code? The webinject.pl is available for download. the XML config file will be specific to your use case. – uSlackr – 2016-03-17T15:27:05.837

Yeah could I see the XML as an example? Thanks – Cameron – 2016-03-17T20:58:50.420

Thanks. I don't know if this solves my issue completely, I guess it could connect to the site and send my credentials, but I'd still need to automatically fire it up when I connect to the company's wifi network. Any idea how to do that? Could I catch an event with Scheduler, perhaps? – Assaf Stone – 2012-05-31T12:49:44.793

I added more detail on triggering it. – uSlackr – 2012-05-31T14:31:48.163

5

You can use lynx (the version with SSL support) - a text based browser - with a cmd_args script file containing the commands needed to log in. You can generate such a script file by logging in to the wifi with lynx once and logging the input. Do this by calling lynx with the following argument:

lynx.exe -cmd_log=%USERPROFILE%\lynxlog.txt`

Then you can rename that file and use it by calling lynx as follows:

lynx.exe -cmd_script=FILENAME_HERE

Put this in a batch file. (Either use the full path to the lynx executable or set that path in the PATH environment variable.)

Once you get that working, make a scheduled task triggered by event id 10000 in source NetworkProfile of log Microsoft-Windows-NetworkProfile/Operational which calls it:

Task Scheduler trigger example

Personally, I bundle that with iexpress.exe to run it hidden in the background and make sure the scheduled task is set to run even if I'm not logged on. I just set this up on my computer a few weeks ago and it's been working great!

Source: My article on How to Automate Captive Portal Login.

Menasheh

Posted 2012-05-31T12:21:59.353

Reputation: 180

1

I've done this in the past with Windows task scheduler and a php+mysqllite script. The php+mysqllite script just checked to see if it could reach google, if it got redirected, it checked to see if it had a routine for the domain it got redirected to, if so, it ran it. The mysqllite was to keep the cookies for the headless browser I implemented in php. It would probably be a lot less work to just use a greasemonkey equivalent to do the log-in. (with the down side being the browser would pop up and do things every time your scheduler gets tripped.)

The task scheduler trigger will vary from machine to machine. I had one laptop that would log wifi connections as events and they included the ssid so I could filter to only trigger on the ones I cared about.

On my current laptop, it seems the only event that reliably gets fired is the DHCP client connect. Of course, this fries every time I get an IP address and doesn't tell me an SSID.

You can check what events are available for you to trigger off of with the windows event viewer. I just turned on and off my wifi 3 times and checked what events were triggered 3 times in the last hour.

Rick

Posted 2012-05-31T12:21:59.353

Reputation: 264