Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This bash script reboots TP-Link routers
@sn1p3r46
Copy link
Author

sn1p3r46 commented Apr 7, 2016

TP-Link Reboot Bash Script

AUTHOR: Andrea Galloni (Twitter or Web)

E-Mail: andreagalloni92[at]gmail{dot}com


This bash script reboots my TP-Link TD-W8960N router,

first of all it looks for the session key from the administration panel of the router, then, it uses it to reboot the machine.
You can launch it from your Linux host connected from the LAN.

It could work also with other models, but honestly I did not try.

If you have some improvements or suggestions, please create a pull request or write to me at: andreagalloni92{at}gmail[dot]com

Andrea Galloni

@coolbit2021
Copy link

coolbit2021 commented Sep 11, 2018

does not work, what should I do?

@pablen
Copy link

pablen commented Jan 11, 2019

In my case it seems the sessionKey is not always of the same length and the reboot fails.

You might want to update line 19 with something like this:

sessionKey=$(curl -ks --user $username:$password $uri_containing_sessionKey | awk '/sessionKey/{ match($3, /[0-9]+/); print substr($3, RSTART, RLENGTH); exit}')

;-)

@sn1p3r46
Copy link
Author

sn1p3r46 commented Jul 2, 2019

Thanks a lot for the contribution @pablen! Is the router the same model?

@pablen
Copy link

pablen commented Jul 2, 2019

I think so! The device info page reads:

Firmware Version: 1.4.0 Build 110620 Rel.52053n
Hardware Version: TD-W8960N v3 0x00000002

@win32u
Copy link

win32u commented Dec 10, 2019

it says permission denied. i also tried run as administrator
Screenshot_1
Screenshot_4

@sn1p3r46
Copy link
Author

sn1p3r46 commented Feb 18, 2020

@Prime-Nobel have you tried using @pablen solution?
PLEASE Lemmie know which was the issue if solved! (maybe it was a credential issue?)

p.s.: I don't have this router anymore, thus I can't test. :S

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment