Programmatically Reboot Huawei HG659


Here is some quick code to allow programmatically rebooting your Huawei 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 2017-08 Vodafone firmware (V100R001C206B026).
Hopefully it also works fine on similar version firmwares.

The code first gets a CSRF token, 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:

Discussion

Support

Check out the Supporter Perks

Follow