Automatically log into a network with a captive portal in Windows?

Solution 1:

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.

Solution 2:

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.

Solution 3:

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.