For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > November 2007 > Re: Script to disconnect Linksys WRT54G wireless router on Windows









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Script to disconnect Linksys WRT54G wireless router on Windows
christoph_un@cenonet.de

2007-11-28, 7:07 pm

Hello,
I managed to reconnect my WRT54GL via perl from my Linux box.

Here is my script:

#!/usr/bin/perl -w

use strict;
use warnings;
use LWP;
use HTTP::Request::Common;

our $ua = LWP::UserAgent->new;

$ua->request(POST 'http://admin:letmein@192.168.10.10/apply.cgi',
[submit_button => 'Status_Router', submit_type => 'Disconnect_pppoe',
change_action => 'gozila_cgi', wan_proto => 'pppoe']);

sleep 5;

$ua->request(POST 'http://admin:letmein@192.168.10.10/apply.cgi',
[submit_button => 'Status_Router', submit_type => 'Connect_pppoe',
change_action => 'gozila_cgi', wan_proto => 'pppoe']);



This might not work for your router right away, but you may tweak it
to
your own needs. The important thing is setting the correct POST
variables. A network sniffer like Wireshark (www.wireshark.org) is
really handy for that. Just sniff a disconnect and right click on any
of
the packets of your HTTP Session and choose "Follow TCP stream". On
top
of the output you will find the whole header and beneath it there is a
line with all the POST variables. Mine looked like this:

submit_button=Status_Router&submit_type=Disconnect_pppoe&change_action=gozila_cgi&wan_proto=pppoe

Repeat this procedure for connecting and you are done.

Also make sure which script is called (first line of the header). My
Status_Router.asp did not call itself but apply.cgi.

Note that my way of parsing username and password via URL is really
insecure so only use it in a trusted network.

Greetings,

Christoph
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com