• Welcome to Computer Association of SIUE - Forums.
 

SIUE Wireless Network Login Script

Started by Justin Camerer, 2007-08-31T12:34:41-05:00 (Friday)

Previous topic - Next topic

Justin Camerer

Is it just me, or does that wireless network login screen piss everyone off? Well, I am sick of seeing it, so I wrote a little script that will remedy that problem. Basically, it just attempts to go to google.com, and if it sees the login page, it just posts your username and password. After this logs in, you are free to browse the internet as you wish. I'm not sure if it'll work for me yet, but its a start.

The script is as follows:


#!/usr/bin/env ruby

require 'rubygems'
require 'mechanize'

m = WWW::Mechanize.new
m.get('http://www.google.com')

if m.page.body.index('REGISTERED USER')
  m.page.forms[0].user     = "jcamere"
  m.page.forms[0].password = "thisismypassword"
  m.page.forms[0].submit
end


To run it, you must have Ruby, Ruby Gems, and the WWW::Mechanize gem (which can be installed with sudo gem install mechanize after you have Ruby gems installed).

After you do this, make the file executable with chmod, and set up a cron job to run this script every once in a while.
Justin Camerer
Do yo' chain hang low?

JR

Retired President of CAOS

Kit

QuoteTo run it, you must have Ruby, Ruby Gems, and the WWW::Mechanize gem (which can be installed with sudo gem install mechanize after you have Ruby gems installed).  After you do this, make the file executable with chmod, and set up a cron job to run this script every once in a while.

That's it? Really?  :roll:
SIUe Computer Science Graduate

William Grim

I'm not there to test that and see if it works with their HTTPS protocol, but if it does, you should package it into an exe with a config file for Windows users.  Either way, nice script.
William Grim
IT Associate, Morgan Stanley

Justin Camerer

Haha. Yeah, thats it. But, ruby is a great thing to have installed on your system anyway. Sorry, this was my 5 minute solution.
Justin Camerer
Do yo' chain hang low?

Tony

#5
Not sure about most of you, but for some reason most of the time when I am trying to get the Login screen to pop up by accessing a website, it doesn't always work the first time.  So, I just put this script in a loop that will keep trying to access google until it gets the login page.

Thanks, Justin!

#!/usr/bin/env ruby

require 'rubygems'
require 'mechanize'

m = WWW::Mechanize.new
m.get('http://www.google.com')


m.get('http://www.google.com') until m.page.body.index('REGISTERED USER')
m.page.forms[0].user     = "apieri"
m.page.forms[0].password = "yourpassword"
m.page.forms[0].submit

puts "\nDone!"
I would rather be hated for doing what I believe in, than loved for doing what I don't.