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.
The code can be found HERE
pip install bs4 requests
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:
- Set your plain text password (line 10)
- Un-comment lines 16 & 17
- Run the script
- Copy the outputted hash value
- Paste the hash value into line 17 (between the quotes)
- Comment out lines 14-16
- Remove your plain text password (line 10)
- Save changes and run