Skip to content

Commit 03b89d8

Browse files
committed
Update for Ableton 12
1 parent b9e2db9 commit 03b89d8

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

kg.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import argparse
12
import re
2-
import sys
33
from random import randint
44
from typing import List
55

@@ -8,6 +8,12 @@
88
from cryptography.hazmat.primitives.asymmetric.utils import decode_dss_signature
99
from cryptography.hazmat.primitives.hashes import SHA1
1010

11+
parser = argparse.ArgumentParser()
12+
parser.add_argument("-i", "--hwid", help="Your hardware code", required=True)
13+
parser.add_argument("-o", "--output", help="Authorization file", default="Authorize.auz")
14+
parser.add_argument("-v", "--version", help="9-12", type=int, choices=range(9, 13), default=12)
15+
args = parser.parse_args()
16+
1117

1218
def construct_key(*, p, q, g, y, x) -> dsa.DSAPrivateKey:
1319
params = dsa.DSAParameterNumbers(p, q, g)
@@ -74,8 +80,12 @@ def generate_single(k: dsa.DSAPrivateKey, id1: int, id2: int, hwid: str) -> str:
7480
return f.format(serial, id1, id2, sig)
7581

7682

77-
def generate_all(k: dsa.DSAPrivateKey, hwid: str) -> str:
78-
yield generate_single(k, 0x0, 0xb0, hwid)
83+
def generate_all(k: dsa.DSAPrivateKey, hwid: str, version: int) -> str:
84+
ident = { 9: 0x90,
85+
10: 0xa0,
86+
11: 0xb0,
87+
12: 0xc0}
88+
yield generate_single(k, 0x0, ident[version], hwid)
7989
for i in range(0x40, 0xff + 1):
8090
yield generate_single(k, i, 0x10, hwid)
8191
for i in range(0x8000, 0x80ff + 1):
@@ -90,9 +100,15 @@ def generate_all(k: dsa.DSAPrivateKey, hwid: str) -> str:
90100
x=0xc369ea757b46484d1df3819cc4183f6f9a9bcf3c
91101
)
92102

93-
assert len(sys.argv) == 2, "Expected hardware ID as command line argument"
94-
hwid = sys.argv[1].upper()
95-
assert re.fullmatch(r"([0-9A-F]{4}-){5}[0-9A-F]{4}", hwid), "Expected hardware ID like 1111-1111-1111-1111-1111-1111"
103+
hwid = args.hwid.upper()
104+
if len(hwid) == 24:
105+
hwid = "-".join((hwid[:4], hwid[4:8], hwid[8:12], hwid[12:16], hwid[16:20], hwid[20:]))
106+
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}"
107+
108+
out = []
109+
for line in generate_all(team_r2r_key, hwid, args.version):
110+
# print(line)
111+
out.append(line)
96112

97-
for line in generate_all(team_r2r_key, hwid):
98-
print(line)
113+
with open(args.output, mode="w", newline="\n") as f:
114+
f.write("\n".join(out))

0 commit comments

Comments
 (0)