Skip to content

Commit 755f77f

Browse files
committed
Fix req.txt, chainged .py files to fit convention
1 parent 38acf8b commit 755f77f

File tree

3 files changed

+43
-36
lines changed

3 files changed

+43
-36
lines changed

keyauth.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@
1313
from 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

1822
from requests_toolbelt.adapters.fingerprint import FingerprintAdapter
1923

24+
25+
KEYSAVE_PATH = "C:\\ProgramData\\keysave.txt"
26+
27+
2028
class 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

main.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
import os
44
import os.path
55

6+
KEYSAVE_PATH = "C:\\ProgramData\\keysave.txt"
7+
68
keyauthapp = api("your app name here", "your ownerid here", "your app secret here")
79

810
print("Initializing")
911
keyauthapp.init()
1012

11-
if os.path.exists('C:\\ProgramData\\keysave.txt'):
12-
with open ("C:\\ProgramData\\keysave.txt", "r") as file:
13-
data=file.readlines()
13+
if os.path.exists(KEYSAVE_PATH):
14+
with open (KEYSAVE_PATH, "r") as file:
15+
data = file.readlines()
1416
keyauthapp.login(data)
1517
else:
16-
_key = input('Enter your key: ')
17-
keyauthapp.login(_key)
18-
19-
keysave = open("C:\\ProgramData\\keysave.txt", "w")
20-
n = keysave.write(_key)
21-
keysave.close()
18+
key = input('Enter your key: ')
19+
keyauthapp.login(key)
20+
keysave = open(KEYSAVE_PATH, "w")
21+
n = keysave.write(key)
22+
keysave.close()

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
requests,
2-
requests_toolbelt,
3-
pycryptodome,
1+
requests
2+
requests_toolbelt
3+
pycryptodome

0 commit comments

Comments
 (0)