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

SSID and password first configuration methods non working (workaround provided) #456

Open
leophys opened this issue Aug 1, 2023 · 1 comment

Comments

@leophys
Copy link

leophys commented Aug 1, 2023

Hi, and thanks for this!

I tried and succeeded after a lot of effort to install the v0.2.0 hacks on my Camera (model iSC5P).
What really blocked me at the beginning was that none of the methods described in the wikl was working, nor the QR code generated by the app. I tried to inspect the latter, but an opaque string at the end prevented me to replicate its algorithm.

I then inspected the js code here and realized that the Fang option was not working.
I am not so capable with javascript, but can python somehow. So I assembled the following script

# coding: utf-8
import argparse
import base64
import random
import string

KEY = "89JFSjo8HUbhou5776NJOMp9i90ghg7Y78G78t68899y79HY7g7y87y9ED45Ew30"


def get_random_string(length):
    # choose from all lowercase letter
    letters = string.ascii_letters + string.digits + "-_"
    return "".join(random.choice(letters) for i in range(length))


def xor_strings(value, key):
    c = ""
    k_len = len(key)
    for i in range(len(value)):
        c += chr(ord(value[i]) ^ ord(key[i % k_len]))

    return bytes(c, "ascii")


def build_string(ssid, password, tz):
    rand = get_random_string(16)
    b_ssid = base64.b64encode(bytes(ssid, "ascii")).decode("ascii")
    b_secret = base64.b64encode(xor_strings(password, KEY)).decode("ascii")
    return f"b={rand}&s={b_ssid}&p={b_secret}&t={tz}"


if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        prog="fang-code",
        description="generate the string to be fed to the Xiaofang",
    )

    parser.add_argument("ssid")
    parser.add_argument("password")
    parser.add_argument("--tz", default="America/New York", help="Set the timezone")

    args = parser.parse_args()

    print(build_string(args.ssid, args.password, args.tz))

The help is clear

usage: fang-code [-h] [--tz TZ] ssid password

generate the string to be fed to the Xiaofang

positional arguments:
  ssid
  password

options:
  -h, --help  show this help message and exit
  --tz TZ     Set the timezone

To generate a QR code, I combine it with qrencode

qrencode -o wifi.png $(python qrcode.py <ssid> <password>)

Have a great day!

@kfix
Copy link

kfix commented Feb 3, 2024

This worked for me on my very old iSC5, the Fang codes on the codepen generator did not.

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

2 participants