LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-12-2012, 03:08 PM   #1
oneindelijk
Member
 
Registered: Oct 2012
Location: Belgium
Distribution: Xubuntu
Posts: 32

Rep: Reputation: Disabled
script for interacting with a router's admin website


Hi,

We are testing a wireless device on a lot of commonly used wireless routers.
For that purpose it would be efficient if we could somehow automate the process of changing the routers parameters to different settings and save them.
They're not high-end routers so they don't have snmp or terminal functionality.

What possible options could we try ?

Edit: I think one way to do it would be to send the html commands to the router on port 8080 (or 80 for some)
Is that possible ?

Last edited by oneindelijk; 10-12-2012 at 03:26 PM.
 
Old 10-14-2012, 03:21 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
you would - at least - say the type of that router. jdownloader has a similar functionality, it is implemented in java, probably you can get some tips from there.
 
Old 10-14-2012, 09:44 AM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Many different kinds of devices these days have built-in HTTP servers to provide a monitoring and/or configuration tool for end users. In many cases, it is fairly simple to craft an HTTP client that interacts independently with the server (device; router in your case). However, many devices rely on the likes of Javascript, Java applets, and other client-side scripting, and some even rely on browser-specific behavior (came across one the other day that wouldn't work without Internet Explorer).
It should be easy to see whether your device uses these languages. Just use wget or curl to fetch a page or two from the device, and examine the reply. If it is all plain HTML (some CSS is okay), then you're probably good to go. If there is Javascript &/or Java applets uploaded, then you're probably hooped. Once you've established feasibility, you will need to use a combination of your wget/curl tool set, as well as a conventional browser to see what URLs and arguments are used.
Creating a smart HTTP client requires a reasonably complete programming language such as Perl, Python, or C. You will need to be able to parse HTML, and this can be tricky, but there are existing libraries for most languages to help out. Perl is my preferred tool for this task. You will need to divine by inspection and trial and error, what responses the device expects, as well as how to send them; what port(s) to use, what HTTP methods are used, and what parameters and values are required. With luck, most of the possibilities will be evident by looking at the HTML that you capture from the device.

--- rod.
 
1 members found this post helpful.
Old 10-15-2012, 05:04 AM   #4
oneindelijk
Member
 
Registered: Oct 2012
Location: Belgium
Distribution: Xubuntu
Posts: 32

Original Poster
Rep: Reputation: Disabled
Question

Quote:
Originally Posted by pan64 View Post
you would - at least - say the type of that router. jdownloader has a similar functionality, it is implemented in java, probably you can get some tips from there.
I don't understand your answer...
After visiting the site, I still don't (and I can read spanish!).
Could you clarify a bit ?
 
Old 10-15-2012, 05:08 AM   #5
oneindelijk
Member
 
Registered: Oct 2012
Location: Belgium
Distribution: Xubuntu
Posts: 32

Original Poster
Rep: Reputation: Disabled
Thumbs up

Quote:
Originally Posted by theNbomr View Post
Creating a smart HTTP client requires a reasonably complete programming language such as Perl, Python, or C. You will need to be able to parse HTML, and this can be tricky, but there are existing libraries for most languages to help out. Perl is my preferred tool for this task. You will need to divine by inspection and trial and error, what responses the device expects, as well as how to send them; what port(s) to use, what HTTP methods are used, and what parameters and values are required. With luck, most of the possibilities will be evident by looking at the HTML that you capture from the device.
Thanks for your fast and complete response.
However, we don't have the time and skills to take this approach.
We've decided to simply export the different configurations from the routers and have an autoclicker load these different files on command...
 
Old 10-15-2012, 05:47 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
Quote:
Originally Posted by oneindelijk View Post
I don't understand your answer...
After visiting the site, I still don't (and I can read spanish!).
Could you clarify a bit ?
jDownloader includes a feature similar you requested. There is also a script generator to be able to handle any kind of router. So actually the problem is solved, you only need to use that solution (if it was really suitable).

Another solution could be to upgrade the software of the router (that's why I asked the type). In this case you may have ssh into the router.
 
Old 10-22-2012, 02:51 PM   #7
oneindelijk
Member
 
Registered: Oct 2012
Location: Belgium
Distribution: Xubuntu
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
Another solution could be to upgrade the software of the router (that's why I asked the type). In this case you may have ssh into the router.
We are testing our device for consumers. So we need to test it with the routers in their default firmwares.
What do you mean that jDownloader can 'handle' the routers ? Can it automatically load a previously saved configuration file ?
(Automatically means in this case, triggered by a command from another script ?)
 
Old 10-23-2012, 08:50 AM   #8
asimba
Member
 
Registered: Mar 2005
Location: 127.0.0.0
Distribution: Red Hat / Fedora
Posts: 355

Rep: Reputation: 42
you could use one of the linux boxes for this.

You could write a script which would telnet/ssh into this kinda router - get environemnt variables/set environement variables - check for changes/make changes and logout.

I dont think it is that cumbersome.
 
Old 10-23-2012, 09:28 AM   #9
oneindelijk
Member
 
Registered: Oct 2012
Location: Belgium
Distribution: Xubuntu
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by asimba View Post
you could use one of the linux boxes for this.

You could write a script which would telnet/ssh into this kinda router - get environemnt variables/set environement variables - check for changes/make changes and logout.

I dont think it is that cumbersome.
I think most routers don't support ssh ?
I've been trying to use curl, mainly to upload a previously saved configuration file (we saved several, all with different settings), but I can't figure out the correct syntax.
This is the command I've deducted from the http header, but I don't think it is correct.
If anyone would be able to correct this syntax, it would be a huge step forward
curl --trace -F restore=@Radio_OFF.cfg -F submit_button=Restore -F wait_time=21 http://192.168.1.103:8080/restore.cgi -u adminassword

This is the http header:
Code:
POST /restore.cgi HTTP/1.1
Host: 192.168.1.103:8080
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:16.0) Gecko/20100101 Firefox/16.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Referer: http://192.168.1.103:8080/Restore.asp
Authorization: Basic YWRtaW46cGFzc3dvcmQ=
Content-Type: multipart/form-data; boundary=---------------------------18061178356874499221977202731
Content-Length: 9214
-----------------------------18061178356874499221977202731
Content-Disposition: form-data; name="submit_button"

Restore
-----------------------------18061178356874499221977202731
Content-Disposition: form-data; name="small_screen"


-----------------------------18061178356874499221977202731
Content-Disposition: form-data; name="wait_time"

21
-----------------------------18061178356874499221977202731
Content-Disposition: form-data; name="restore"; filename="Radio_OFF.cfg"
Content-Type: text/txt

Salted__.Sx~*S_!l3Uak&2*lw\.@w*bEʾ.=a94$Y0n}yG
:s-'Jʆr
E7l6A<.k+;g,y0.F~r7S:$AHןO8FH
< 18VZft%/{*Jt
\3}(, ~iFρ[MVX|j'
GJx/òՖdUbE!U<DI/E)͵/ta3"MpP_8%
 
  


Reply

Tags
routers, scripting



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Interacting with a website using Perl and LWP saldon Programming 2 05-09-2011 09:27 AM
website blocker that can't be defeated by admin? newbiesforever Linux - Software 8 11-16-2008 08:54 PM
Remote Admin through router ? waynep Linux - Networking 3 02-18-2005 04:06 PM
Admin Tools on a website / proxies randyriver10 General 0 07-19-2004 11:56 AM
Pretty neat web admin piece for my website.... Whitehat General 5 12-14-2003 02:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration