karljorgensen / virgin-media-hub3 Goto Github PK
View Code? Open in Web Editor NEWPython API and command line interface to the Virgin Media Hub 3 broadband router
License: GNU General Public License v3.0
Python API and command line interface to the Virgin Media Hub 3 broadband router
License: GNU General Public License v3.0
Attempting to use the tool returns a 500 internal server error. This seems to be due to the fact that the /logon page of the router is no longer used.
Now I'm in Modem Mode on my VM Router, im not too surprised there's a small bug:
billy@Billys-MBP virgin-media-hub3 % python3 hub info
modelname : TG2492LG-85
family : 852
hardware_version : 10
serial_number : [REDACTED]
bootcode_version : 4.2.0.45
firmware_version : 9.1.1802.613
name : Home
current_time_status : TODStatus.RETRIEVED
current_time : 2019-10-11 23:54:17
uptime : 16:00:49.920000
first_install_wizard_completed : True
wan_ip_prov_mode : 1
wan_current_ipaddr_ipv4 : None
wan_current_ipaddr_ipv6 : None
/Users/billy/Downloads/virgin-media-hub3/snmp.py:767: UserWarning: SNMP Walk of '1.3.6.1.4.1.4115.1.20.1.1.1.11.2.1' yielded no results
warnings.warn("SNMP Walk of '%s' yielded no results" % table_oid)
/Users/billy/Downloads/virgin-media-hub3/snmp.py:815: UserWarning: SMTP walk of 1.3.6.1.4.1.4115.1.20.1.1.1.11.2.1 resulted in zero rows
% table_oid)
dns_servers :
+
|
+
+
I'm going to presume this is likely due to me being in Modem Mode c:
I've tried to install this project both on my MacBook Pro and on my Raspberry, but I always get this error when I launch the hub command:
pi@glasgy:/virgin-media-hub3 $ ./hub info/virgin-media-hub3 $ ./hub
Traceback (most recent call last):
File "./hub", line 9, in
import netaddr
ImportError: No module named 'netaddr'
pi@glasgy:
Traceback (most recent call last):
File "./hub", line 9, in
import netaddr
ImportError: No module named 'netaddr'
The list for port forwarding does not show any UPnP forwarded ports (when enabled) - the real web interfaces requests OID 1.3.6.1.4.1.4115.1.20.1.1.4.53
and gets back:
{
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.2.1": "0",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.2.2": "0",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.2.3": "1",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.2.4": "0",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.3.1": "192.168.0.28",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.3.2": "192.168.0.28",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.3.3": "192.168.0.19",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.3.4": "192.168.0.19",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.4.1": "9308",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.4.2": "3659",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.4.3": "2622",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.4.4": "2622",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.5.1": "9308",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.5.2": "3659",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.5.3": "2622",
"1.3.6.1.4.1.4115.1.20.1.1.4.53.1.5.4": "2622"
}
In the Web UI, I see:
192.168.0.28 | 9308 | 9308 | UDP | Automatically added by UPnP
192.168.0.28 | 3659 | 3659 | UDP | Automatically added by UPnP
192.168.0.19 | 2622 | 2622 | TCP | Automatically added by UPnP
192.168.0.19 | 2622 | 2622 | UDP | Automatically added by UPnP
I just found your project whilst researching the Hub 3 as a fellow sufferer of the rather subpar Liberty Global/Arris firmware work and am rather impressed by what you've done so far!
However, when attempting to try this out with my Hub (firmware version 9.1.1802.613), login fails (empty response) despite using the correct password.
After a bit of tinkering, I found that the web client appends two extra query string parameters to the request:
_n
. which is a random five-digit nonce which persists across a session from login to logout (stored in session storage as ar_nonce
)_
, which seems to be the current Unix epoch timestamp (to prevent caching, I imagine; this parameter is apparently optional)The _n
nonce parameter is of particular interest as login requests fail on my Hub unless it is set. Here is the relevant code for generating it, from the web client (in base_95x.js):
function getNonce() {
var n = getSessionStorage("ar_nonce");
if (!n) {
n = "_n="+(""+Math.random()).substr(2,5);
setSessionStorage("ar_nonce", n);
}
return n;
}
Based on this, it looks like we can just generate a random 5-digit integer for this at login and unset it following logout - I'll try to write a patch to do this when I get a moment.
In any case, fabulous work (:
I'm getting the following warning and error:
The only difference I see from Supported Routers is the firmware version.
Steps to reproduce
Result
$ ./hub info
modelname : TG2492LG-85
family : 852
hardware_version : 10
serial_number : AAAP72630959
bootcode_version : 4.2.0.45
firmware_version : 9.1.1912.302
name : Home
current_time_status : TODStatus.RETRIEVED
current_time : 2020-10-23 14:47:56
uptime : 11:38:21.750000
first_install_wizard_completed : True
wan_ip_prov_mode : 1
wan_current_ipaddr_ipv4 : 82.27.120.223
wan_current_ipaddr_ipv6 : None
dns_servers :
+------------+---------------+
| ip_version | ipaddr |
+------------+---------------+
| IPv4 | 194.168.4.100 |
| IPv4 | 194.168.8.100 |
+------------+---------------+
/home/pablo/virgin-media-hub3/virginmedia.py:126: UserWarning: Got http status 500 - retrying after 1 seconds
% (resp.status_code, sleep))
Traceback (most recent call last):
File "./hub", line 611, in <module>
main()
File "./hub", line 606, in main
args.func(hub, args)
File "/home/pablo/virgin-media-hub3/virginmedia.py", line 231, in __exit__
self.logout()
File "/home/pablo/virgin-media-hub3/virginmedia.py", line 209, in logout
self._get('logout', retry401=0, params=self._nonce)
File "/home/pablo/virgin-media-hub3/virginmedia.py", line 131, in _get
resp.raise_for_status()
File "/home/pablo/.local/lib/python3.7/site-packages/requests/models.py", line 941, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://192.168.0.1/logout?_=1603460867528&_n=87128
First of all, great script!
I was wonderig however how to set the DNS (dns_servers) in my Arris version of the Dutch ConnectBox. With the command --help I only receive the parameter 'value' (along with three times the list retreived from property-list).
It seems that the script isn't happy with certain things :P
When trying to run hub info
on my VM Router:
modelname : TG2492LG-85
family : 852
hardware_version : 10
serial_number : REDACTED
bootcode_version : 4.2.0.45
firmware_version : 9.1.1802.613
name : Home
current_time_status : TODStatus.RETRIEVED
current_time : 2019-09-27 20:11:53
uptime : 28 days, 3:04:10.320000
first_install_wizard_completed : True
wan_ip_prov_mode : 1
Traceback (most recent call last):
File "hub", line 611, in <module>
main()
File "hub", line 606, in main
args.func(hub, args)
File "hub", line 75, in info
"dns_servers"
File "hub", line 49, in dump_properties
res = getattr(hub, prop)
File "D:\Git\virgin-media-hub3\snmp.py", line 612, in __get__
return self._translator.pyvalue(RawAttribute.__get__(self, instance, owner))
File "D:\Git\virgin-media-hub3\snmp.py", line 373, in pyvalue
raise ValueError("Value '%s' is not an SNMP IPv4Address" % snmp_value)
ValueError: Value 'Qkl9' is not an SNMP IPv4Address
That Qkl9
text is also seemingly used for ddns-status:
D:\Git\virgin-media-hub3>python hub ddns-status
ddns_enabled : False
ddns_type : 2
ddns_username : None
ddns_password : None
ddns_domain_name : None
ddns_addr_type : IPVersion.IPv4
ddns_address : Qkl9 is not an SNMP representation of an IP address!?
ddns_current_status : disabled
Perhaps an update has been made to the firmware since the tool was created, but it's no longer possible to forward UDP port 53. I've tried multiple ways to do this, including manually editing a successfully created rule via snmp-set to remap it to UDP 53. Seems there's some internal validation now preventing the rowstatus being set to "1"/Active if the range includes port 53.
Not really an issue with the tool, but a nudge to update the description as it specifically calls out the ability to forward port 53.
Sorry if this is not an 'issue' but if someone would enlighten me with the command (property or SNMP OID range) to print out all of the modems stats as I would like to convert the output into a csv file to be read into my new project of an excel spreadsheet that calculates good, bad and average values from the modem stats (dBvM power and SNR dB) and colourizes them via conditional formatting. Informing the user on if they should buy a downstream attenuator, amplifier, remove a splitter or contact their ISP.
Thanks.
Great work by the way :)
Is there any chance that support for Virgin Media HUB 5 will be added?
In particular I am interested in setting the CPU governor in performance mode.
Does anyone know if it's even possible?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.