1313from Crypto .Util .Padding import pad , unpad
1414# aes + padding, sha256
1515
16- import webbrowser , platform , subprocess , datetime
16+ import webbrowser
17+ import platform
18+ import subprocess
19+ import datetime
20+ import sys
1721
1822from requests_toolbelt .adapters .fingerprint import FingerprintAdapter
1923
24+
25+ KEYSAVE_PATH = "C:\\ ProgramData\\ keysave.txt"
26+
27+
2028class api :
2129 name = ownerid = secret = ""
2230
@@ -35,9 +43,9 @@ def init(self):
3543 init_iv = SHA256 .new (self .session_iv .encode ()).hexdigest ()
3644
3745 post_data = {
38- "type" : binascii .hexlify (("init" ).encode ()),
46+ "type" : binascii .hexlify (("init" ).encode ()),
3947 "name" : binascii .hexlify (self .name .encode ()),
40- "ownerid" : binascii .hexlify (self .ownerid .encode ()),
48+ "ownerid" : binascii .hexlify (self .ownerid .encode ()),
4149 "init_iv" : init_iv
4250 }
4351
@@ -53,58 +61,55 @@ def init(self):
5361 else :
5462 print ("The program key you tried to use doesn't exist" )
5563 sys .exit ()
56-
5764
5865 def login (self , key , hwid = None ):
59- if hwid is None : hwid = others .get_hwid ()
60-
66+ if hwid is None :
67+ hwid = others .get_hwid ()
68+
6169 self .session_iv = str (uuid4 ())[:8 ]
6270
6371 init_iv = SHA256 .new (self .session_iv .encode ()).hexdigest ()
6472
6573 post_data = {
66- "type" : binascii .hexlify (("login" ).encode ()),
74+ "type" : binascii .hexlify (("login" ).encode ()),
6775 "key" : encryption .encrypt (key , self .secret , init_iv ),
6876 "hwid" : encryption .encrypt (hwid , self .secret , init_iv ),
6977 "name" : binascii .hexlify (self .name .encode ()),
70- "ownerid" : binascii .hexlify (self .ownerid .encode ()),
78+ "ownerid" : binascii .hexlify (self .ownerid .encode ()),
7179 "init_iv" : init_iv
7280 }
7381
7482 response = self .__do_request (post_data )
75-
83+
7684 response = encryption .decrypt (response , self .secret , init_iv )
77-
85+
7886 if response == "KeyAuth_Valid" :
7987 print ("Logged in" )
8088 if response == "KeyAuth_Invalid" :
8189 print ("Key not found" )
82- if os .path .exists ('C: \\ ProgramData \\ keysave.txt' ):
83- os .remove ("C: \\ ProgramData \\ keysave.txt" )
90+ if os .path .exists (KEYSAVE_PATH ):
91+ os .remove (KEYSAVE_PATH )
8492 sys .exit ()
8593 if response == "KeyAuth_InvalidHWID" :
8694 print ("This computer doesn't match the computer the key is locked to. If you reset your computer, contact the application owner" )
87- if os .path .exists ('C: \\ ProgramData \\ keysave.txt' ):
88- os .remove ("C: \\ ProgramData \\ keysave.txt" )
95+ if os .path .exists (KEYSAVE_PATH ):
96+ os .remove (KEYSAVE_PATH )
8997 sys .exit ()
9098 if response == "KeyAuth_Expired" :
9199 print ("This key is expired" )
92- if os .path .exists ('C: \\ ProgramData \\ keysave.txt' ):
93- os .remove ("C: \\ ProgramData \\ keysave.txt" )
100+ if os .path .exists (KEYSAVE_PATH ):
101+ os .remove (KEYSAVE_PATH )
94102 sys .exit ()
95103 else :
96104 print ("Application Failed To Connect. Try again or contact application owner" )
97- if os .path .exists ('C: \\ ProgramData \\ keysave.txt' ):
98- os .remove ("C: \\ ProgramData \\ keysave.txt" )
105+ if os .path .exists (KEYSAVE_PATH ):
106+ os .remove (KEYSAVE_PATH )
99107 sys .exit ()
100-
101108
102109 def __do_request (self , post_data ):
103110 headers = {"User-Agent" : "KeyAuth" }
104111
105- rq = requests .Session ()
106-
107- rq_out = rq .post (
112+ rq_out = requests .post (
108113 "https://keyauth.com/api/" , data = post_data , headers = headers , verify = False
109114 )
110115
@@ -117,9 +122,10 @@ def get_hwid():
117122 if platform .system () != "Windows" :
118123 return "None"
119124
120- cmd = subprocess .Popen ("wmic useraccount where name='%username%' get sid" , stdout = subprocess .PIPE , shell = True )
125+ cmd = subprocess .Popen (
126+ "wmic useraccount where name='%username%' get sid" , stdout = subprocess .PIPE , shell = True )
121127
122- (suppost_sid , error ) = cmd .communicate ()
128+ (suppost_sid , _error ) = cmd .communicate ()
123129
124130 suppost_sid = suppost_sid .split (b'\n ' )[1 ].strip ()
125131
0 commit comments