-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_unique_address.py
More file actions
57 lines (45 loc) · 1.39 KB
/
get_unique_address.py
File metadata and controls
57 lines (45 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import time
import psutil
import winreg
from traceback import print_exc
from utils import read_reg, write_reg, get_hash_str, str_fill
def secret_get_unique_address() -> str:
try:
board_id = read_reg(
winreg.HKEY_LOCAL_MACHINE,
r"SYSTEM\HardwareConfig",
"LastConfig",
"Unknown"
).upper().strip("{}")
identify = read_reg(
winreg.HKEY_CURRENT_USER,
r"Software\PCL",
"Identify",
""
)
if len(identify) < 3:
tick = int(time.time() * 1000)
mem = psutil.virtual_memory().available
identify = f"{tick}{mem}"
write_reg(
winreg.HKEY_CURRENT_USER,
r"Software\PCL",
"Identify",
identify
)
h = int(get_hash_str(board_id + identify))
hex_str = str_fill(format(h, "X"), "0", 16)
result = (
f"{hex_str[4:8]}-"
f"{hex_str[12:16]}-"
f"{hex_str[0:4]}-"
f"{hex_str[8:12]}"
)
return result
except Exception as e:
print(f"ERROR get_unique_addr: {e}")
print_exc()
print("WARNING get_unique_addr: Returning value 0000-0000-0000-0000 which is invalid.")
return "0000-0000-0000-0000"
if __name__ == "__main__":
print(secret_get_unique_address())