Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to retreive valid SID? #2

Open
waleedqq opened this issue Aug 2, 2023 · 0 comments
Open

How to retreive valid SID? #2

waleedqq opened this issue Aug 2, 2023 · 0 comments

Comments

@waleedqq
Copy link

waleedqq commented Aug 2, 2023

System: RasperryPi
Fritzbox: 7490,

My Fritzbox GUI url is : http://192.168.178.1/#overview with no SID in the URL. I tried to use the following link https://fritz.box/login_sid.lua?version=2 again this returned 0000000000000000. I tried many scripts until I found this, which returns a SID. When I try this in the Wireshark Fritzbox Interface Options, it errors out telling me this is an invalid SID, how will I fix this?

import requests
import urllib3
import xml.etree.ElementTree as ET
import hashlib


def fb_get_sid(fritzbox, fritz_user, fritz_pw):
    global fb_sid
    if fb_sid == "0000000000000000":
        session = requests.Session()
        http = urllib3.PoolManager()
        data = http.request("get", fritzbox + "/login_sid.lua").data
        tree = ET.fromstring(data)
        fb_sid = tree.findtext("SID")
        if fb_sid == "0000000000000000":
            challenge = tree.findtext("Challenge")
            hash_me = (challenge + "-" + fritz_pw).encode("UTF-16LE")
            hashed = hashlib.md5(hash_me).hexdigest()
            response = challenge + "-" + hashed
            ret = session.get(fritzbox + "/login_sid.lua", params={
                "username": fritz_user,
                "response": response
            }, verify=False, timeout=5)
            tree = ET.fromstring(ret.text)
            fb_sid = tree.findtext("SID")
            if fb_sid == "0000000000000000":
                print("fb_get_sid: Error getting SID")
                exit()
    return fb_sid


routerurl = "http://192.168.178.1"
username = "FOO"  # login user name e.g. fritz1234
password = "BAR"  # login password
fb_sid = "0000000000000000"


def main():
    fb_sid = fb_get_sid(routerurl, username, password)
    print("Session ID", fb_sid)


if __name__ == '__main__':
    main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant