WRT54G/Tomato 1.21++ Reconnect-Batchfile

UPDATE! I’ve updated the script to work for Tomato 1.25 (and hopefully upwards) – links below updated.

Some of you pirating people are downloading stuff from Rapidshare. Rapidshare, among other providers of free online storage and downloads, employ a policy that lets the user download a certain amount of data and then forces him to wait for a couple of hours before being able to again download something.

People (who are on dynamic ip connections) usually circumvent this by restarting (also ‘resetting’) their router. Some are clever enough to utilize tools for that task that log into your router and reset the connection.

People using Tomato however have been unable to use some of the Software written for that task, because as of Tomato 1.14 (changelog), in which the author fixed a cross site scripting vulnerability, just calling a URL on the Web-Interface won’t do it anymore.

I have written a php-script started by a batchfile that will let you reconnect your Tomato-running router with one click and no other tools than the ones provided.

The thing that Jon, the author of the Tomato and previously Tofu Firmware did was the following: He introduced a POST-variable into every form of the Web-Interface that would be transmitted upon clicking a button. As the content of this variable is created randomly after the first bootup of your router, a perpetrator using javascript to access your router’s WebIf would have no way of executing anything, as he doesn’t know that particular, 19 character long code.

You only do get to see this code when you log into your router’s WebIf – for which you need your router’s password – and view the source code. Since you probably want to save yourself the trouble of everytime hitting a shitload of buttons to reconnect your router, i wrote a script that retrieves that aforementioned POST-variable by logging into your router’s WebIf and afterwards submitting the commands for disconnection of the WAN-port and consecutive reconnection of the latter.

A short explanation on the files contained in the package:

  • routerreconnect.php
    the script that i wrote and does all the work – edit this for your webif-password and router ip
  • routerreconnect.bat
    the batch-file that calls the script
  • exec – a folder containing files required for the script to work
    • php.exe, php.ini, php5ts.dll
      a very rudimentary distribution of php5(.2.6) – the ini file is the recommended version with curl-support edited into it – PHP License 3.0.1
    • php_curl.dll
      the curl php module required to send the commands to the router – PHP License 3.0.1
    • ssleay32.dll, libeay32.dll – Apache-style licence
      openssl files that are required for the curl extension to run (we’re not accessing ssl sites, but go on and try to disable that function in the module!)

I have tested this combination on computers that run neither php, nor openssl and it should work just fine on yours as well. This script has been tested with Tomato 1.19 and 1.21 (the latest one at the time of this posting) and worked well with both of them. As the WebIf doesn’t return any data after triggering its reconnection-function, it’s hard to debug if something goes wrong, hence i didn’t include any real status messages.

Anyway, here’s the download: router_reconnect_for_tomato_1.25.zip (2,92MiB from Rapidshare)
Mirrors: Megaupload

I’m not guaranteeing anything, but since the script shouldn’t break anything either, just try it, alright?

Advertisements

30 responses to “WRT54G/Tomato 1.21++ Reconnect-Batchfile

  1. Hi,

    I’m french, excuse me my english.
    I have a Linksys WRT54G with Tomato Firmware (v1.23), and JDownloader for downloading.

    Thank you very much, your script works great !!!

    Bye bye 🙂

  2. Not working for my Tomato v_19

    cmd :

    oida reconnecten
    PHP Notice: Undefined variable: key in I:\jdownloader\Wrt54GL script\routerreconnect.php on line 28
    PHP Notice: Undefined index: in I:\jdownloader\Wrt54
    GL script\routerreconnect.php on line 28
    PHP Notice: Undefined offset: 1 in I:\jdownloader\Wrt
    54GL script\routerreconnect.php on line 29

  3. The script is working just fine, after an update to the v_23 firmware, AND changing my big mistake in the php file :

    $router_login=”admin”; // standard
    $router_pw=”admin2″; // pw des webif
    $router_ip=”192.168.2.1″; // nach moeglichkeit ip und nicht den hostnamen, resolven isn umstand

    NO -> You have to leave “root” as “router_login !!!

    so it has to be like this :

    $router_login=”root”; // standard
    $router_pw=”admin2″; // pw des webif
    $router_ip=”192.168.2.1″; // nach moeglichkeit ip und nicht den hostnamen, resolven isn umstand

    Many thanks to “bogderpirat” who helped me out

    Best regards

    -Kleeschen-

  4. Hello,

    Does anyone know if inputting the username/password info into JDownload or other downloaders will compromise the user’s pc security? Does that info gets sent anywhere?

  5. i have this feeling that comment might be more fitting for something jdownload-related…
    if you are referring to the script: only to your router.

    as for “compromising pc security”… security is a concept that in terms of network security, is made up of a great many of modular issues that, each for itself, has to be made certain to not be of any threat. you might say, the script provided here makes your home network “less secure”, in that it saves the login to your router on your computer in plain text. if however your computer is somewhat secure against intrusion and spying of your hdd, this script does not make your pc or network as a whole any more vulnerable than it already is. it just adds functionality.

    • did you make sure that:
      1. you entered both the username (usually “root”) and the password as well as
      2. the router’s ip
      correctly in the .php file as the instructions say?

  6. in the latest version of jdownloader, there is a router

    preset for tomato 1.19.XXXX.

    after changing the TID code in the preset srcipt (it should be different for different routes).

    i can use the modified preset to reset my WRT54GS tomato 1.19 router and obtain new ips correctly.

    so i think maybe this php script will be not necessary for the latest jdownloader.

    anyway, i still should say thanks to you, because i use your script before and it works as expected.

    cheers.

  7. i idid it the same way with Tomato 1.23VPN.

    used tomato 1.19 script and changed ALL TIDs.
    the TID from your router appears after logging out from the web interface in the addressline.

  8. Hi,
    thanks for the script. It helped me complete a small project for one of my client. I needed to tweak the script a bit ( I know quite a bit of php & html) to automate mac address randomization but i guess, i would not have been able to login without it.

    Thanks. I owe you some bucks. Feel free to ask for a favor if you need any of my help.

    • i’ve been trying desperately to find a way to automate the mac address change, could you please share your work, it would be greatly appreciated. thanks.

  9. glad i could help!

    as for the two guys for whom it does not work:
    @tatoosh are you using the HTTPS-only login method? (administration/admin access) have you changed the port? if no, any other particular changes to the default setup of the firmware? from the error messages, it appears that the router’s page cannot be parsed in order to obtain the correct TID.

    as for tomato 1.25… i will look into adapting the script as soon as i upgrade my router to 1.25. … which will have to wait until this lazy victek person upgrades his firmware mod. 🙂

  10. i’ve optimized and thus repaired the script, something went awry after the update to 1.25. should now work very well, except if something major changes (this wasn’t the case from 1.23->1.25 apparently).

  11. Hi,

    this don’t work for me: –> Tomato 1.23

    PHP Notice: Undefined offset: 2 in J:\routerreconnectwan\routerreco
    nect.php on line 24
    found http_id=
    disconnecting…
    waiting…
    reconnecting…
    done!

  12. Now i have Updated my Router to Tomato 1.25 but still the same problem. Any Ideas?

    I changed the Password and the IP in the routerreconect.php. Also http Access is enabled.

  13. meh 😐
    would you kindly open up routerreconnect.php in a text editor (such as wordpad) and look for the first occurrence of this line:

    curl_close($ch);

    this should be in line 20 by my count.
    right after this line, insert the following lines:

    $fh=fopen(“./debug.txt”,”w”);
    fwrite($fh, $quellkot);
    fclose($fh);

    this will create a file “debug.txt” in the directory your script resides that contains the HTML contents of the site your router sends you after you have logged in. now look at the file:
    – if it is very small (<=1KB), there might be something wrong with your configuration or your network connectivity. you should post (or email/im me, details on the contact page) both your configuration (lines 7-9 of the script) and the debug.txt output.
    – if it has a size of around 6-8KB, you should send me the debug.txt file, for the email address see the contact page.

    also, please review and add this information:
    – does the script take longer than 3 seconds to execute?
    – are you using some sort of firewall you might have blocked php.exe in?

  14. hey the reconnect.bat doesnt excecute everytime i get the error : weil msvcr71.dll nicht gefunden wurde … he cant find the msvcr71.dll
    I downloaded this dll copied it into thy \system32 folder and the reconnect folder but still the same error message ….
    any help ?

  15. still the same
    i tried this batch file 1 month ago on my last laptop using xp , which doesnt work anymore . now i got a fresh clean new one but using vista …. doesnt know if its more help

  16. uhm, well..
    did you try:
    – rebooting
    – moving the dll file to the exec\ directory
    – registering the dll file like so: start -> run -> regsvr32 x:\path\to\msvcr71.dll
    – running the batchfile as an administrator?

    i have no problem running this thing on a vanilla windows vista and windows 7 install, if any of these things help, please let me know.
    ?

  17. Is there any alternative to the tomato firmwar?

    I’m fuckin tired of searching for another reconnect method everytime the firmware gets an update. Why is this anyway?

  18. @ inb4thekill

    I don’t know what you’re talking about. This works perfectly on W7 Ult. 32-bit, Asus WL-520gu , running Tomato 1.28 ND USB mod.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s