Skip to content

Commit 82c00fa

Browse files
authored
Add Config File for keygen, so theres no manual command required.
1 parent 8c49e29 commit 82c00fa

File tree

4 files changed

+89
-20
lines changed

4 files changed

+89
-20
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"file_path": "/your/ableton/path.exe",
3+
"hwid": "1111-1111-1111-1111-1111-1111",
4+
"edition": "Suite",
5+
"version": 11,
6+
7+
"_comment1": "Don't change if you dont know what youre doing!",
8+
9+
"authorize_file_output": "Authorize.auz",
310
"old_signkey":"33303832303142373330383230313242303630373241383634384345333830343031333038323031314530323831383130304343454441393938434243363636463044323836313133333230454130344342374431424236364345384243323230364331303933354534353134314534373846303639363543313141464241303944343043463943323145364345354231324439414433384532433842424430453444464641413642373239314432464230333230334639343543354145463231423745433238383134373132353144324231363344364444374539414245313344413938363933314646423436384537353243444641423038303845364142363437304442373438443746444638433038434533414346423833463646323338373543353232373945433938353230304430323135303038304437423338413141324438413843324141363843434136444341313738433637433630363335303238313830303532394431443946373637443735423745364435393838444438373445323942314531314635413638413831443233453934353130354346464635363637463235453445324335323736313341303230303833443746334533363430384139463442383444384338454242364134443041383241393236313238353833313443424339464338463235364142353131353142344246394333364637353242424241353534394642333234344233343539424346453243324132464342313032373534333542414136323531463643423539393536424638453946363033343443444532423333413743334333313842393345424541454246333542463642423033383138353030303238313831303039313836443932453734433530373034334339374438454136394638314436313132454643343439313638374635333431463932443641424134464337363445304346424143443943364436443533353738423146413838383231374646364442433743433538303934413832434434433141384238364245353734353739414639364637343035364433343741344131353145323339443443443238394146354238394144433741413338373246444541444538363533453945374144393736373844354330343239314438424134423137373534393036353644363243374433354232413642363044463144373131393142313442453537433238454436",
411
"new_signkey":"33303832303142373330383230313243303630373241383634384345333830343031333038323031314630323831383130304241423541313039373046303833453236364131323532383937444141433144363733373437313245373944334446314243384330384133343933433641413941324646333342453435313344384236373637414236414145324146364343393130373937364641373546454531333445384237424530334437384343363445303839433834353230374433303641363033354631373243354237353032373546303042443343413233333142384135394435344645373933393338353444443838344238443333344435353342333842433545383836433041324444304534454333324637443838444531413743394446354334323445453742314345364430323135303043333742453930453346384536344530334134324341384436384144354338334542343744334139303238313831303041333343383733374634324532353136413135323535343445363131443731323935383035434544393444323630443537373744423937364636373231463532343739313538453234373745464230454136464633304433344431354232333636394630393637443239413243373436323838454534324338443931464534444245373941373345453838333132353141333536363836343835384535383941444344343143333836334541313138464242434446333442443634454630453741453230423030313932373039413833343643383136423534413531443830344136453036464345314441344230343343324235323730443445343431363232303338313834303030323831383033334644313246443435394645364335433142433039393145393135463842463439393937373136424445354333424446394130393642444342463741343235454636413439353638334343383446334441464142374131443543463946333737464441383443303432453437453743363038323938433639313741334341414234304233433632363235353946453639393039314335424236414338444530314630413946383837433733394646413341314138353830303046383541313831314543333341323139303036333334314538433230414241303638423930333833463843413237443330414138394144463430444539434537333544454442"
512
}

keygen.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import argparse
1+
import json
22
import re
33
from random import randint
44

@@ -14,29 +14,23 @@
1414
"Suite": 2,
1515
}
1616

17-
parser = argparse.ArgumentParser()
18-
parser.add_argument("-i", "--hwid", help="Your hardware code", required=True)
19-
parser.add_argument("-o", "--output", help="Authorization file", default="Authorize.auz")
20-
parser.add_argument("-v", "--version", help="Ableton Live version", type=int, choices=range(9, 13), default=12)
21-
parser.add_argument("-e", "--edition", help="Ableton Live edition", type=str.capitalize, choices=EDITIONS, default="Suite")
22-
args = parser.parse_args()
23-
17+
def load_config(filename: str):
18+
with open(filename, 'r') as f:
19+
return json.load(f)
2420

2521
def construct_key(*, p, q, g, y, x) -> dsa.DSAPrivateKey:
2622
params = dsa.DSAParameterNumbers(p, q, g)
2723
pub = dsa.DSAPublicNumbers(y, params)
2824
priv = dsa.DSAPrivateNumbers(x, pub)
2925
return priv.private_key(backend=default_backend())
3026

31-
3227
def sign(k: dsa.DSAPrivateKey, m: str) -> str:
3328
"""P1363 format sig over m as a string of hex digits"""
3429
assert k.key_size == 1024
3530
sig = k.sign(m.encode(), SHA1())
3631
r, s = decode_dss_signature(sig)
3732
return "{:040X}{:040X}".format(r, s)
3833

39-
4034
def fix_group_checksum(group_number: int, n: int) -> int:
4135
checksum = n >> 4 & 0xf ^ \
4236
n >> 5 & 0x8 ^ \
@@ -46,21 +40,18 @@ def fix_group_checksum(group_number: int, n: int) -> int:
4640
group_number
4741
return n & 0xfff0 | checksum
4842

49-
5043
def overall_checksum(groups: list[int]) -> int:
5144
r = 0
5245
for i in range(20):
5346
g, digit = divmod(i, 4)
5447
v = groups[g] >> (digit * 8) & 0xff
55-
# v is lowbyte, highbyte, 0, 0 in turn for each group
5648
r ^= v << 8
5749
for _ in range(8):
5850
r <<= 1
5951
if r & 0x10000:
6052
r ^= 0x8005
6153
return r & 0xffff
6254

63-
6455
def random_serial():
6556
"""
6657
3xxc-xxxc-xxxc-xxxc-xxxc-dddd
@@ -78,23 +69,20 @@ def random_serial():
7869
d = overall_checksum(groups)
7970
return "{:04X}-{:04X}-{:04X}-{:04X}-{:04X}-{:04X}".format(*groups, d)
8071

81-
8272
def generate_single(k: dsa.DSAPrivateKey, id1: int, id2: int, hwid: str) -> str:
8373
f = "{},{:02X},{:02X},Standard,{}"
8474
serial = random_serial()
8575
msg = f.format(serial, id1, id2, hwid)
8676
sig = sign(k, msg)
8777
return f.format(serial, id1, id2, sig)
8878

89-
9079
def generate_all(k: dsa.DSAPrivateKey, edition: str, version: int, hwid: str) -> str:
9180
yield generate_single(k, EDITIONS[edition], version << 4, hwid)
9281
for i in range(0x40, 0xff + 1):
9382
yield generate_single(k, i, 0x10, hwid)
9483
for i in range(0x8000, 0x80ff + 1):
9584
yield generate_single(k, i, 0x10, hwid)
9685

97-
9886
team_r2r_key = construct_key(
9987
p=0xbab5a10970f083e266a1252897daac1d67374712e79d3df1bc8c08a3493c6aa9a2ff33be4513d8b6767ab6aae2af6cc9107976fa75fee134e8b7be03d78cc64e089c845207d306a6035f172c5b750275f00bd3ca2331b8a59d54fe79393854dd884b8d334d553b38bc5e886c0a2dd0e4ec32f7d88de1a7c9df5c424ee7b1ce6d,
10088
q=0xc37be90e3f8e64e03a42ca8d68ad5c83eb47d3a9,
@@ -103,11 +91,14 @@ def generate_all(k: dsa.DSAPrivateKey, edition: str, version: int, hwid: str) ->
10391
x=0xc369ea757b46484d1df3819cc4183f6f9a9bcf3c
10492
)
10593

106-
hwid = args.hwid.upper()
94+
# Load configuration
95+
config = load_config('config.json')
96+
97+
hwid = config.get('hwid', '').upper()
10798
if len(hwid) == 24:
10899
hwid = "-".join(hwid[i:i+4] for i in range(0, 24, 4))
109100
assert re.fullmatch(r"([0-9A-F]{4}-){5}[0-9A-F]{4}", hwid), f"Expected hardware ID like 1111-1111-1111-1111-1111-1111, not {hwid}"
110101

111-
lines = generate_all(team_r2r_key, args.edition, args.version, hwid)
112-
with open(args.output, mode="w", newline="\n") as f:
102+
lines = generate_all(team_r2r_key, config.get('edition', 'Suite'), config.get('version', 12), hwid)
103+
with open(config.get('authorize_file_output', 'Authorize.auz'), mode="w", newline="\n") as f:
113104
f.write("\n".join(lines))

patcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def replace_signkey_in_file(file_path, old_signkey, new_signkey):
6262
except Exception as e:
6363
print(f"An error occurred: {e}")
6464

65-
json_file_path = 'hex.json'
65+
json_file_path = 'config.json'
6666

6767
try:
6868
file_path, old_signkey, new_signkey = read_config_from_json(json_file_path)

undoPatch.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import json
2+
import re
3+
4+
def read_config_from_json(json_file_path):
5+
try:
6+
with open(json_file_path, 'r') as json_file:
7+
data = json.load(json_file)
8+
file_path = data.get("file_path")
9+
new_signkey = data.get("old_signkey")
10+
old_signkey = data.get("new_signkey")
11+
12+
if not file_path or not old_signkey or not new_signkey:
13+
raise ValueError("JSON file must contain 'file_path', 'old_signkey', and 'new_signkey'.")
14+
15+
return file_path, old_signkey, new_signkey
16+
17+
except FileNotFoundError:
18+
print(f"The JSON file {json_file_path} was not found.")
19+
raise
20+
except json.JSONDecodeError:
21+
print(f"Error parsing the JSON file {json_file_path}.")
22+
raise
23+
24+
def replace_signkey_in_file(file_path, old_signkey, new_signkey):
25+
if len(old_signkey) != len(new_signkey):
26+
raise ValueError("The new signkey must be the same length as the old signkey.")
27+
28+
if old_signkey.startswith("0x"):
29+
old_signkey = old_signkey[2:]
30+
if new_signkey.startswith("0x"):
31+
new_signkey = new_signkey[2:]
32+
33+
if not re.fullmatch(r'[0-9a-fA-F]+', old_signkey):
34+
raise ValueError("The old signkey is not valid.")
35+
if not re.fullmatch(r'[0-9a-fA-F]+', new_signkey):
36+
raise ValueError("The new signkey is not valid.")
37+
38+
try:
39+
with open(file_path, 'rb') as file:
40+
content = file.read()
41+
42+
old_signkey_bytes = bytes.fromhex(old_signkey)
43+
new_signkey_bytes = bytes.fromhex(new_signkey)
44+
45+
if old_signkey_bytes not in content:
46+
print(f"The old signkey '{old_signkey}' was not found in the file.")
47+
else:
48+
print(f"The old signkey '{old_signkey}' was found. Replacing...")
49+
50+
content = content.replace(old_signkey_bytes, new_signkey_bytes)
51+
52+
with open(file_path, 'wb') as file:
53+
file.write(content)
54+
55+
if old_signkey_bytes in content:
56+
print("Error: The old signkey is still present in the file.")
57+
else:
58+
print("Signkey successfully replaced.")
59+
60+
except FileNotFoundError:
61+
print(f"The file '{file_path}' was not found.")
62+
except Exception as e:
63+
print(f"An error occurred: {e}")
64+
65+
json_file_path = 'config.json'
66+
67+
try:
68+
file_path, old_signkey, new_signkey = read_config_from_json(json_file_path)
69+
replace_signkey_in_file(file_path, old_signkey, new_signkey)
70+
except Exception as e:
71+
print(f"Error: {e}")

0 commit comments

Comments
 (0)