Guide Reconnecting your router (Any make, get new IP)

Status
Not open for further replies.
In this tutorial I will show you how to automate reconnect and acquire a new IP address. The technique used is a bit more complex but the results justify the work :) .

The whole procedure will take you somewhere around 10-15 minutes.
(I will demonstrate the procedure using Netgear WGR614 wireless router)

Getting the required software

Curl for windows: http://www.gknw.net/mirror/curl/win32/curl-7.18.2-ssl-sspi-zlib-static-bin-w32.zip
We will use this for automating requests to the router

NirCmd: http://www.nirsoft.net/utils/nircmd.zip
This utility will be used to hide the console window and do the task in background

LiveHTTPHeaders: http://downloads.mozdev.org/livehttpheaders/livehttpheaders-0.14.xpi
Use this to easily retrieve variables used in POST request

Overview of the whole procedure

  • Grab the information from routers reconnection page to get the variables
  • Use these variables with curl to automate disconnection and connection
  • Use NirCmd to hide the whole procedure so that you don’t get disturbed every time reconnection takes place.
[BREAK=Retrieving Information]

Every router reconnects through a web interface it does so when user clicks and a HTTP (post/get) request is sent. We will catch the POST request and view the variables that are being passed. You can either view the source of the file and get the information or use the LiveHTTPHeaders from Mozilla FireFox to make the job a lot easier.

1.jpg


2-disconnect.jpg


Here we can see that a variable was sent which disconnected the router.
Variable Name: ConMethod
Variable Value: Disconnect


3.jpg


Now we have the variables for the Connection method also.
Variable Name: ConMethod
Variable Value: Connect


[BREAK=Final Touch : Using Curl & NirCmd]

Using Curl

Since we will be sending HTTP requests to the router we will send using CURL.
General syntax :

Code:
Curl  -d “param1=value1†–u username:password <router address>/<file name>

Disconnection
Code:
Curl –d “ConMethod=Disconnect†–u admin:pass 192.168.1.1/st_poe.cgi

When you type this command the output will be the webpage, you don’t need to do anything with that just ignore it.

Connecting

Code:
Curl –d “ConMethod= Connect †–u admin:pass 192.168.1.1/st_poe.cgi

Or if you have enabled automatic connection from your router pages you can use this command instead of connection
Code:
Ping –n 1 [url]www.google.com[/url]

Compiling it all in a Batch file
Create new textfile and rename it to cl.bat
I am assuming that you have the curl in the folder c:\curl
Contents of cl.bat

Code:
Curl –d “ConMethod=Disconnect†–u admin:pass 192.168.1.1/st_poe.cgi
Curl –d “ConMethod= Connect †–u admin:pass 192.168.1.1/st_poe.cgi

Or if you have automatic reconnection enabled

Code:
Curl –d “ConMethod=Disconnect†–u admin:pass 192.168.1.1/st_poe.cgi
Ping –n 1 [url]www.google.com[/url]

Using NirCmd to hide all the output

Extract the Nircmd in the folder of curl (i.e. c:\curl\)
Create a batch file named Reconnect.bat and following will be the contents of it.

Code:
Nircmd exec2 hide “c:\curl†“c:\curl\cl.batâ€

Now you can use this batch file to reconnect or schedule this in windows.

Your comments and suggestions are welcome :)
 
  • Like
Reactions: 2 people
How to make this work for those who have no disconnect option in my billion router there is only one option that is to restart not anything else.
 
Status
Not open for further replies.