Well, it seems nobody actually finished an auth script, or they missed
this thread. Sooo, I wrote one myself. You are welcome to
use/change/patch this script. Criticisms are welcome.

The username and password are read from the file 'byuwireless.passwd' in
the current directory (not really a good standard place to put it, not
even in $HOME because it could be run by root, you, waproamd, etc, you
get the idea). The passwd file is in yaml and looks like this:
username: joeschmoe
password: judy
EOF

I have the script living in /etc/waproamd/scripts and I run it from
essid:byuc0ug4rs after sourcing default (all in the same directory).
This gets run automagically by waproamd when connecting to a WAP with
essid byuc0ug4rs.
NOTE: I had to take out the 'exit 0' at the end of the default script
for this to work.

You can do whatever you want with the script. Put it in a cron job, have
it run from boot, whatever.

The first thing the script does is download google's homepage and check
if the title is google, if so all is good and it exits. So you could
even run it by the minute, and it wouldn't even hurt anybody.

Enjoy

/me makes a point not to forget to attatch the file...

Von Fugal

P.S.
The script is in ruby, and uses yaml, so you'll have to install the
necesarry packages/libraries
#! /usr/bin/ruby
require 'yaml'

if `wget www.google.com -O - 2> /dev/null`[/<title>google/i] then
  puts "Already authenticated or authentication not needed"
  exit 0
end

passwd = YAML.load(File.read('byuwireless.passwd'))

page1=`wget www.google.com -O - 2> /dev/null | grep -o 'https://connect[^?]*' | 
head -n 1`
$login=`wget #{page1.chomp} -O - 2> /dev/null`

# this handles all the different authentication pages for different
# sites on campus (connect1, connect2, etc)

authpage = page1[/(https:..connect[^"']*\/).*/,1] + "perfigo_validate.jsp"

def value(x)
  reg = eval "/name=.#{x}[^>]*value=.([^\"\']*)/"
  $login[reg,1]
end

def post(x)
  "#{x}=#{value x}"
end

vars = ['reqFrom','userip','os','index','vlan','provider','login_submit']

post_string = [vars.map{|x| post x},
  "username=#{passwd['username']}&password=#{passwd['password']}"].join('&')
puts 'SUCCESS' if `wget --post-data="#{post_string}" "#{authpage}" -O - 2> 
/dev/null`[/<title>google/i]

Attachment: signature.asc
Description: Digital signature

____________________
BYU Unix Users Group 
http://uug.byu.edu/ 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to