1. import win32crypt, win32con, win32api;
  2. def get_regkey():
  3. try:
  4. accessRead = win32con.KEY_READ | win32con.KEY_ENUMERATE_SUB_KEYS | win32con.KEY_QUERY_VALUE
  5. keyPath = 'Licenses\\5C505A59-E312-4B89-9508-E162F8150517\\08878'
  6. try:
  7. hkey = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, keyPath, 0, accessRead)
  8. except Exception as e:
  9. print (e)
  10. return ''
  11. num = win32api.RegQueryInfoKey(hkey)[1]
  12. k = win32api.RegEnumValue(hkey, 0)
  13. if k:
  14. key = k[1]
  15. return win32crypt.CryptUnprotectData(key, None, None, None, 0)[1]
  16. except Exception as e:
  17. print (e)
  18. return 'failed'
  19. encKey = get_regkey()
  20. print(encKey);
  21. plainKey = encKey.decode('windows-1252');
  22. print(plainKey);