Bambu Lab Authorization Control System: Difference between revisions
How to decrypt and reverse engineer Bambu Connect Tags: Reverted Visual edit: Switched |
→Extracting certs and private key: Code was missing Tag: Reverted |
||
Line 153: | Line 153: | ||
Example Python reimplementation to extract the secrets, easy to run. Copy the content of t from function cy() in main.js and paste it here. After running, you have a private key from Bambu Lab. | Example Python reimplementation to extract the secrets, easy to run. Copy the content of t from function cy() in main.js and paste it here. After running, you have a private key from Bambu Lab. | ||
<code> | <code> | ||
import urllib.parse | |||
def cy(): | |||
t = [ | |||
# copy from main.js | |||
] | |||
return t | |||
def ure(t, e): | |||
# RC4 implementation | |||
r = list(range(256)) | |||
n = 0 | |||
s = "" | |||
# Key-scheduling algorithm (KSA) | |||
for o in range(256): | |||
n = (n + r[o] + ord(e[o % len(e)])) % 256 | |||
r[o], r[n] = r[n], r[o] | |||
# Pseudo-random generation algorithm (PRGA) | |||
o = n = 0 | |||
for byte in t: | |||
o = (o + 1) % 256 | |||
n = (n + r[o]) % 256 | |||
r[o], r[n] = r[n], r[o] | |||
k = r[(r[o] + r[n]) % 256] | |||
s += chr(byte ^ k) | |||
return s | |||
def lt(t, e): | |||
r = cy() | |||
n = t - 106 | |||
s = r[n] | |||
s = ure(s, e) | |||
return urllib.parse.unquote(s) | |||
def extract_certs_and_key(): | |||
try: | |||
result = {} | |||
result["Are"] = lt(106, "1o9B") | |||
result["fre"] = lt(107, "FT2A") | |||
result["private_key"] = lt(108, "Tlj0") | |||
result["cert"] = lt(109, "NPub") | |||
result["crl"] = lt(110, "x077") | |||
except Exception as e: | |||
print(f"Error extracting certs/key: {e}") | |||
for key, value in result.items(): | |||
print(f"{key}:\n{value}\n") | |||
if __name__ == "__main__": | |||
extract_certs_and_key() | |||
</code> | |||
== Community tools and scripts == | == Community tools and scripts == |