HG659 Router | Python Reboot Code


Here is some quick code to allow programmatically rebooting your HG659 router.
This is quite a common router here in New Zealand with Spark, Vodafone, and other ISPs using it.

I have tested this working on a HG659 running Telecom Business firmware (V100R001C227B011).
Hopefully it also works fine on other firmwares.

The code first gets a CSRF token, then logs in, and then reboots.
You could easily adapt it to fetch info from the admin interface etc.

It works in Python 2 and Python 3.
2x Python libraries (Beautiful Soup and Requests) are required, these can easily be installed via pip.
pip install bs4 requests
The code can be found HERE
You will need to change the top three config variables (lines 8-10) to match your setup.


If you don't want your password stored in plain text:
  1. Set your plain text password (line 10)
  2. Un-comment lines 16 & 17
  3. Run the script
  4. Copy the outputted hash value
  5. Paste the hash value into line 17 (between the quotes)
  6. Comment out lines 14-16
  7. Remove your plain text password (line 10)
  8. Save changes and run
After the modifications, is should look something like this:



Enjoy!