1- import os
2-
31import json # json
42
53import binascii # hex encoding
1311from Crypto .Util .Padding import pad , unpad
1412# aes + padding, sha256
1513
16- import webbrowser
17- import platform
18- import subprocess
19- import datetime
20- import sys
14+ import webbrowser , platform , subprocess , datetime , datetime , sys
2115
2216from requests_toolbelt .adapters .fingerprint import FingerprintAdapter
2317
@@ -53,21 +47,21 @@ def init(self):
5347
5448 response = self .__do_request (post_data )
5549
50+ if response == "program_doesnt_exist" :
51+ print ("The application doesnt exist" )
52+ sys .exit ()
53+
5654 response = encryption .decrypt (response , self .secret , init_iv )
5755
58- if response == "KeyAuth_Disabled" :
59- print ("The program key you tried to use doesn't exist" )
60- sys .exit ()
61- if response == "KeyAuth_Initialized" :
62- print ("Initialized" )
63- else :
64- print ("The program key you tried to use doesn't exist" )
56+ json = json .loads (response )
57+
58+ if not json ["success" ]:
59+ print (json ["message" ])
6560 sys .exit ()
6661
6762 def login (self , key , hwid = None ):
68- if hwid is None :
69- hwid = others .get_hwid ()
70-
63+ if hwid is None : hwid = others .get_hwid ()
64+
7165 self .session_iv = str (uuid4 ())[:8 ]
7266
7367 init_iv = SHA256 .new (self .session_iv .encode ()).hexdigest ()
@@ -85,25 +79,12 @@ def login(self, key, hwid=None):
8579
8680 response = encryption .decrypt (response , self .secret , init_iv )
8781
88- if response == "KeyAuth_Valid" :
89- print ("Logged in" )
90- elif response == "KeyAuth_Invalid" :
91- print ("Key not found" )
92- if os .path .exists (KEYSAVE_PATH ):
93- os .remove (KEYSAVE_PATH )
94- sys .exit ()
95- elif response == "KeyAuth_InvalidHWID" :
96- print ("This computer doesn't match the computer the key is locked to. If you reset your computer, contact the application owner" )
97- if os .path .exists (KEYSAVE_PATH ):
98- os .remove (KEYSAVE_PATH )
99- sys .exit ()
100- elif response == "KeyAuth_Expired" :
101- print ("This key is expired" )
102- if os .path .exists (KEYSAVE_PATH ):
103- os .remove (KEYSAVE_PATH )
104- sys .exit ()
82+ json = json .loads (response )
83+
84+ if json ["success" ]:
85+ self .__load_user_data (json ["info" ])
10586 else :
106- print ("Application Failed To Connect. Try again or contact application owner" )
87+ print (json [ "message" ] )
10788 if os .path .exists (KEYSAVE_PATH ):
10889 os .remove (KEYSAVE_PATH )
10990 sys .exit ()
@@ -112,22 +93,36 @@ def __do_request(self, post_data):
11293 headers = {"User-Agent" : "KeyAuth" }
11394
11495 rq_out = requests .post (
115- "https://keyauth.com/api/" , data = post_data , headers = headers , verify = "keyauth.pem"
96+ "https://keyauth.com/api/v2/ " , data = post_data , headers = headers , verify = "keyauth.pem"
11697 )
11798
11899 return rq_out .text
119100
101+ # region user_data
102+ class user_data_class :
103+ key = ""
104+ expiry = datetime .datetime .now ()
105+ level = 0
106+
107+ user_data = user_data_class ()
108+
109+ def __load_user_data (self , data ):
110+ self .user_data .key = data ["key" ]
111+
112+ self .user_data .expiry = datetime .datetime .fromtimestamp (int (data ["expiry" ]))
113+
114+ self .user_data .level = data ["level" ]
115+
120116
121117class others :
122118 @staticmethod
123119 def get_hwid ():
124120 if platform .system () != "Windows" :
125121 return "None"
126122
127- cmd = subprocess .Popen (
128- "wmic useraccount where name='%username%' get sid" , stdout = subprocess .PIPE , shell = True )
123+ cmd = subprocess .Popen ("wmic useraccount where name='%username%' get sid" , stdout = subprocess .PIPE , shell = True )
129124
130- (suppost_sid , _error ) = cmd .communicate ()
125+ (suppost_sid , error ) = cmd .communicate ()
131126
132127 suppost_sid = suppost_sid .split (b'\n ' )[1 ].strip ()
133128
@@ -164,7 +159,7 @@ def encrypt(message, enc_key, iv):
164159
165160 return encryption .encrypt_string (message .encode (), _key .encode (), _iv .encode ()).decode ()
166161 except :
167- print ("Invalid App Secret " )
162+ print ("Invalid Application Information. Long text is secret short text is ownerid. Name is supposed to be app name not username " )
168163 sys .exit ()
169164
170165 @staticmethod
@@ -176,5 +171,5 @@ def decrypt(message, enc_key, iv):
176171
177172 return encryption .decrypt_string (message .encode (), _key .encode (), _iv .encode ()).decode ()
178173 except :
179- print ("Invalid App Secret " )
174+ print ("Invalid Application Information. Long text is secret short text is ownerid. Name is supposed to be app name not username " )
180175 sys .exit ()
0 commit comments