mirror of
https://github.com/Tafkas/fritzbox-munin.git
synced 2023-10-10 11:36:55 +00:00
Support Firtz OS 7.24
This commit is contained in:
parent
a394a3fe49
commit
72c2fbb1b5
@ -1,4 +1,7 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
##
|
||||||
|
*2021-06-14*
|
||||||
|
- Support for FRITZ!OS 7.24. Login without Username was removed.
|
||||||
|
|
||||||
## 6.83.2
|
## 6.83.2
|
||||||
*2017-09-05*
|
*2017-09-05*
|
||||||
|
@ -70,16 +70,19 @@ If you are using the scripts on a different Fritz!Box model please let me know b
|
|||||||
|
|
||||||
[fritzbox_*]
|
[fritzbox_*]
|
||||||
env.fritzbox_password <fritzbox_password>
|
env.fritzbox_password <fritzbox_password>
|
||||||
|
env.fritzbox_user <fritzbox_user> # User name is automaticly detected if you do have password only login and this value doesn't need to be set.
|
||||||
env.traffic_remove_max true # if you do not want the possible max values
|
env.traffic_remove_max true # if you do not want the possible max values
|
||||||
|
|
||||||
2. multiple fritzboxes:
|
2. multiple fritzboxes:
|
||||||
|
|
||||||
[fritzbox_<fqdn1>_*]
|
[fritzbox_<fqdn1>_*]
|
||||||
env.fritzbox_password <fritzbox_password>
|
env.fritzbox_password <fritzbox_password>
|
||||||
|
env.fritzbox_user <fritzbox_user> # User name is automaticly detected if you do have password only login and this value doesn't need to be set.
|
||||||
env.traffic_remove_max true # if you do not want the possible max values
|
env.traffic_remove_max true # if you do not want the possible max values
|
||||||
|
|
||||||
[fritzbox_<fqdn2>_*]
|
[fritzbox_<fqdn2>_*]
|
||||||
env.fritzbox_password <fritzbox_password>
|
env.fritzbox_password <fritzbox_password>
|
||||||
|
env.fritzbox_user <fritzbox_user> # User name is automaticly detected if you do have password only login and this value doesn't need to be set.
|
||||||
env.traffic_remove_max true # if you do not want the possible max values
|
env.traffic_remove_max true # if you do not want the possible max values
|
||||||
|
|
||||||
6. Create symbolic link in `/etc/munin/plugins` for `fritzbox_helper.py`.
|
6. Create symbolic link in `/etc/munin/plugins` for `fritzbox_helper.py`.
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
@ -38,12 +39,6 @@ USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:10.0) Gecko/2010010
|
|||||||
Code from https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AVM_Technical_Note_-_Session_ID_deutsch_2021-05-03.pdf
|
Code from https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AVM_Technical_Note_-_Session_ID_deutsch_2021-05-03.pdf
|
||||||
start
|
start
|
||||||
"""
|
"""
|
||||||
class LoginState:
|
|
||||||
def __init__(self, challenge: str, blocktime: int):
|
|
||||||
self.challenge = challenge
|
|
||||||
self.blocktime = blocktime
|
|
||||||
self.is_pbkdf2 = challenge.startswith("2$")
|
|
||||||
|
|
||||||
def calculate_pbkdf2_response(challenge: str, password: str) -> str:
|
def calculate_pbkdf2_response(challenge: str, password: str) -> str:
|
||||||
""" Calculate the response for a given challenge via PBKDF2 """
|
""" Calculate the response for a given challenge via PBKDF2 """
|
||||||
challenge_parts = challenge.split("$")
|
challenge_parts = challenge.split("$")
|
||||||
@ -96,11 +91,18 @@ def get_session_id(server, password, port=80):
|
|||||||
print(err)
|
print(err)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
root = etree.fromstring(r.content)
|
root = etree.fromstring(r.content)
|
||||||
session_id = root.xpath('//SessionInfo/SID/text()')[0]
|
session_id = root.xpath('//SessionInfo/SID/text()')[0]
|
||||||
user_id = root.xpath('//SessionInfo/Users/User/text()')[0]
|
|
||||||
challenge = root.xpath('//SessionInfo/Challenge/text()')[0]
|
challenge = root.xpath('//SessionInfo/Challenge/text()')[0]
|
||||||
|
new_login = True
|
||||||
|
|
||||||
|
try:
|
||||||
|
user_id = root.xpath('//SessionInfo/Users/User/text()')[0]
|
||||||
|
except IndexError:
|
||||||
|
new_login = False
|
||||||
|
|
||||||
|
if "fritzbox_user" in os.environ:
|
||||||
|
user_id = os.environ['fritzbox_user']
|
||||||
|
|
||||||
if session_id == "0000000000000000":
|
if session_id == "0000000000000000":
|
||||||
if challenge.startswith("2$"):
|
if challenge.startswith("2$"):
|
||||||
@ -114,10 +116,14 @@ def get_session_id(server, password, port=80):
|
|||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
"User-Agent": USER_AGENT}
|
"User-Agent": USER_AGENT}
|
||||||
|
|
||||||
url = 'http://{}:{}/login_sid.lua?version=2'.format(server, port)
|
|
||||||
try:
|
try:
|
||||||
data = {"username": "fritz8535", "response": response_bf}
|
if new_login:
|
||||||
|
url = 'http://{}:{}/login_sid.lua?version=2'.format(server, port)
|
||||||
|
data = {"username": user_id,"response": response_bf}
|
||||||
r = requests.post(url, urllib.parse.urlencode(data).encode(), headers=headers)
|
r = requests.post(url, urllib.parse.urlencode(data).encode(), headers=headers)
|
||||||
|
else:
|
||||||
|
url = 'http://{}:{}/login_sid.lua?&response={}'.format(server, port, response_bf)
|
||||||
|
r = requests.get(url, headers=headers)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
except requests.exceptions.HTTPError as err:
|
except requests.exceptions.HTTPError as err:
|
||||||
print(err)
|
print(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user