Fritz Data
Fritz Data
/usr/bin/python
import sys
import time
import datetime
import json
import requests
import argparse
import hashlib
from urllib.request import urlopen
from xml.etree.ElementTree import parse
password='LOLOLOL'
sleepVar=3
dsbps="&dsbps=nqos:settings/stat0/ds_current_bps"
bps="&bps=nqos:settings/stat0/current_bps"
bsentLow="&bsentLow=inetstat:status/Today/BytesSentLow"
brecLow="&brecLow=inetstat:status/Today/BytesReceivedLow"
bsentHigh="&bsentHigh=inetstat:status/Today/BytesSentHigh"
brecHigh="&brecHigh=inetstat:status/Today/BytesReceivedHigh"
bsentLowMonth="&bsentLowMonth=inetstat:status/ThisMonth/BytesSentLow"
brecLowMonth="&brecLowMonth=inetstat:status/ThisMonth/BytesReceivedLow"
bsentHighMonth="&bsentHighMonth=inetstat:status/ThisMonth/BytesSentHigh"
brecHighMonth="&brecHighMonth=inetstat:status/ThisMonth/BytesReceivedHigh"
uptime_hours="&uptime_hours=logic:status/uptime_hours"
uptime_minutes="&uptime_minutes=logic:status/uptime_minutes"
statcpu="&statcpu=cpu:status/StatCPU"
statramcacheused="&statramcacheused=cpu:status/StatRAMCacheUsed"
statramphysfree="&statramphysfree=cpu:status/StatRAMPhysFree"
statramstrictlyused="&statramstrictlyused=cpu:status/StatRAMStrictlyUsed"
sumact="&sumact=power:status/rate_sumact"
wlandevs="&wlandevs=wlan:settings/wlanlist/list(state)"
ethdevs="ðdevs=power:status/rate_ethact"
temp="&temp=power:status/act_temperature"
cmd = dsbps + bps + bsentLow + brecLow + bsentHigh + brecHigh + bsentLowMonth +
brecLowMonth + bsentHighMonth + brecHighMonth + uptime_hours + uptime_minutes +
statcpu + statramcacheused + statramphysfree + statramstrictlyused + sumact + wl
andevs + ethdevs + temp
def execute():
with urlopen('http://fritz/login_sid.lua') as f:
dom = parse(f)
sid = dom.findtext('./SID')
challenge = dom.findtext('./Challenge')
if sid == '0000000000000000':
md5 = hashlib.md5()
md5.update(challenge.encode('utf-16le'))
md5.update('-'.encode('utf-16le'))
md5.update(password.encode('utf-16le'))
response = challenge + '-' + md5.hexdigest()
uri = 'http://fritz/login_sid.lua?&response=' + response
with urlopen(uri) as f:
dom = parse(f)
sid = dom.findtext('./SID')
if sid == '0000000000000000':
raise PermissionError('access denied')