13
13
from Crypto .Util .Padding import pad , unpad
14
14
# aes + padding, sha256
15
15
16
- import webbrowser , platform , subprocess , datetime
16
+ import webbrowser
17
+ import platform
18
+ import subprocess
19
+ import datetime
20
+ import sys
17
21
18
22
from requests_toolbelt .adapters .fingerprint import FingerprintAdapter
19
23
24
+
25
+ KEYSAVE_PATH = "C:\\ ProgramData\\ keysave.txt"
26
+
27
+
20
28
class api :
21
29
name = ownerid = secret = ""
22
30
@@ -35,9 +43,9 @@ def init(self):
35
43
init_iv = SHA256 .new (self .session_iv .encode ()).hexdigest ()
36
44
37
45
post_data = {
38
- "type" : binascii .hexlify (("init" ).encode ()),
46
+ "type" : binascii .hexlify (("init" ).encode ()),
39
47
"name" : binascii .hexlify (self .name .encode ()),
40
- "ownerid" : binascii .hexlify (self .ownerid .encode ()),
48
+ "ownerid" : binascii .hexlify (self .ownerid .encode ()),
41
49
"init_iv" : init_iv
42
50
}
43
51
@@ -53,58 +61,55 @@ def init(self):
53
61
else :
54
62
print ("The program key you tried to use doesn't exist" )
55
63
sys .exit ()
56
-
57
64
58
65
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
+
61
69
self .session_iv = str (uuid4 ())[:8 ]
62
70
63
71
init_iv = SHA256 .new (self .session_iv .encode ()).hexdigest ()
64
72
65
73
post_data = {
66
- "type" : binascii .hexlify (("login" ).encode ()),
74
+ "type" : binascii .hexlify (("login" ).encode ()),
67
75
"key" : encryption .encrypt (key , self .secret , init_iv ),
68
76
"hwid" : encryption .encrypt (hwid , self .secret , init_iv ),
69
77
"name" : binascii .hexlify (self .name .encode ()),
70
- "ownerid" : binascii .hexlify (self .ownerid .encode ()),
78
+ "ownerid" : binascii .hexlify (self .ownerid .encode ()),
71
79
"init_iv" : init_iv
72
80
}
73
81
74
82
response = self .__do_request (post_data )
75
-
83
+
76
84
response = encryption .decrypt (response , self .secret , init_iv )
77
-
85
+
78
86
if response == "KeyAuth_Valid" :
79
87
print ("Logged in" )
80
88
if response == "KeyAuth_Invalid" :
81
89
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 )
84
92
sys .exit ()
85
93
if response == "KeyAuth_InvalidHWID" :
86
94
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 )
89
97
sys .exit ()
90
98
if response == "KeyAuth_Expired" :
91
99
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 )
94
102
sys .exit ()
95
103
else :
96
104
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 )
99
107
sys .exit ()
100
-
101
108
102
109
def __do_request (self , post_data ):
103
110
headers = {"User-Agent" : "KeyAuth" }
104
111
105
- rq = requests .Session ()
106
-
107
- rq_out = rq .post (
112
+ rq_out = requests .post (
108
113
"https://keyauth.com/api/" , data = post_data , headers = headers , verify = False
109
114
)
110
115
@@ -117,9 +122,10 @@ def get_hwid():
117
122
if platform .system () != "Windows" :
118
123
return "None"
119
124
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 )
121
127
122
- (suppost_sid , error ) = cmd .communicate ()
128
+ (suppost_sid , _error ) = cmd .communicate ()
123
129
124
130
suppost_sid = suppost_sid .split (b'\n ' )[1 ].strip ()
125
131
0 commit comments