Skip to content

Commit 4bc1a5e

Browse files
committed
1 parent 77a3a21 commit 4bc1a5e

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

licensing/methods.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,39 @@ def create_session(token, payment_form_id, currency, expires, price=None,\
13611361
return (jobj, "")
13621362

13631363
class Helpers:
1364+
1365+
1366+
def __read_registry_value(key, subkey, value_name):
1367+
1368+
import winreg
1369+
1370+
"""
1371+
Reads a value from the Windows Registry.
1372+
1373+
Parameters:
1374+
key (int): The registry root key (e.g., winreg.HKEY_LOCAL_MACHINE).
1375+
subkey (str): The path to the subkey.
1376+
value_name (str): The name of the value to read.
1377+
1378+
Returns:
1379+
str: The value read from the registry, or an error message if not found.
1380+
"""
1381+
try:
1382+
# Open the registry key
1383+
registry_key = winreg.OpenKey(key, subkey, 0, winreg.KEY_READ)
1384+
1385+
# Query the value
1386+
value, reg_type = winreg.QueryValueEx(registry_key, value_name)
1387+
1388+
# Close the registry key
1389+
winreg.CloseKey(registry_key)
1390+
1391+
return value
1392+
1393+
except FileNotFoundError:
1394+
return None
1395+
except Exception as e:
1396+
return None //str(e)
13641397

13651398
@staticmethod
13661399
def GetMachineCode(v=1):
@@ -1374,15 +1407,21 @@ def GetMachineCode(v=1):
13741407
"""
13751408

13761409
if "windows" in platform.platform().lower():
1377-
1410+
1411+
import winreg
1412+
13781413
seed = ""
13791414

13801415
if v==2:
13811416
seed = HelperMethods.start_process_ps_v2()
13821417
else:
13831418
seed = HelperMethods.start_process(["cmd.exe", "/C", "wmic","csproduct", "get", "uuid"],v)
1384-
1419+
13851420
if seed == "":
1421+
machineGUID = Helpers.__read_registry_value(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Cryptography", "MachineGuid")
1422+
1423+
if machineGUID != None and machineGUID != "":
1424+
return machineGUID //HelperMethods.get_SHA256(machineGUID)
13861425
return None
13871426
else:
13881427
return HelperMethods.get_SHA256(seed)

0 commit comments

Comments
 (0)