diff --git a/keyauth.py b/keyauth.py index b34596b..df8c854 100644 --- a/keyauth.py +++ b/keyauth.py @@ -1,3 +1,4 @@ +import win32security #get sid import json as jsond # json import time # sleep before exit @@ -456,19 +457,16 @@ def __load_user_data(self, data): class others: @staticmethod def get_hwid(): + winuser = os.getlogin() if platform.system() != "Windows": with open("/etc/machine-id") as f: hwid = f.read() return hwid - cmd = subprocess.Popen( - "wmic useraccount where name='%username%' get sid", stdout=subprocess.PIPE, shell=True) + sid = win32security.LookupAccountName(None, winuser)[0] + sidstr = win32security.ConvertSidToStringSid(sid) - (suppost_sid, error) = cmd.communicate() - - suppost_sid = suppost_sid.split(b'\n')[1].strip() - - return suppost_sid.decode() + return sidstr class encryption: @@ -514,4 +512,4 @@ def decrypt(message, enc_key, iv): return encryption.decrypt_string(message.encode(), _key.encode(), _iv.encode()).decode() except: print("Invalid Application Information. Long text is secret short text is ownerid. Name is supposed to be app name not username") - sys.exit() \ No newline at end of file + sys.exit() diff --git a/requirements.txt b/requirements.txt index f3a56f4..1c19e06 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ requests requests_toolbelt pycryptodome +pywin32