Skip to content

Commit 1c715da

Browse files
authored
Update
Added Hash Checks Added App Data Added Automatic initialization when class is initialized aka no longer have to call the init function yourself *Credits to @xFGhoul for the idea*
1 parent a9fd8e2 commit 1c715da

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

keyauth.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import time # sleep before exit
44

55
import binascii # hex encoding
6+
import hashlib
67

78
# https requests
89

@@ -12,8 +13,8 @@
1213
import subprocess
1314
import datetime
1415
import sys
15-
import requests
1616
import os
17+
import requests
1718
from requests_toolbelt.adapters.fingerprint import FingerprintAdapter
1819

1920
try:
@@ -28,9 +29,6 @@
2829
time.sleep(1.5)
2930
exit(0)
3031

31-
32-
33-
3432
class api:
3533
name = ownerid = secret = version = ""
3634

@@ -42,19 +40,25 @@ def __init__(self, name, ownerid, secret, version):
4240
self.secret = secret
4341

4442
self.version = version
43+
self.init()
4544

4645
sessionid = enckey = ""
4746
initialized = False
4847

4948
def init(self):
50-
49+
if sessionid != "":
50+
print("You've already initialized!")
51+
time.sleep(2)
52+
exit(0)
53+
5154
init_iv = SHA256.new(str(uuid4())[:8].encode()).hexdigest()
5255

5356
self.enckey = SHA256.new(str(uuid4())[:8].encode()).hexdigest()
5457

5558
post_data = {
5659
"type": binascii.hexlify(("init").encode()),
5760
"ver": encryption.encrypt(self.version, self.secret, init_iv),
61+
"hash": self.getchecksum(),
5862
"enckey": encryption.encrypt(self.enckey, self.secret, init_iv),
5963
"name": binascii.hexlify(self.name.encode()),
6064
"ownerid": binascii.hexlify(self.ownerid.encode()),
@@ -86,6 +90,7 @@ def init(self):
8690

8791
self.sessionid = json["sessionid"]
8892
self.initialized = True
93+
self.__load_app_data(json["appinfo"])
8994

9095

9196

@@ -410,7 +415,18 @@ def checkinit(self):
410415
if not self.initialized:
411416
print("Initialize first, in order to use the functions")
412417
sys.exit()
413-
418+
419+
def getchecksum(self):
420+
path = os.path.realpath(__file__)
421+
md5_hash = hashlib.md5()
422+
423+
a_file = open(path, "rb")
424+
content = a_file.read()
425+
md5_hash.update(content)
426+
427+
digest = md5_hash.hexdigest()
428+
return digest
429+
414430
def __do_request(self, post_data):
415431

416432
rq_out = requests.post(
@@ -419,11 +435,21 @@ def __do_request(self, post_data):
419435

420436
return rq_out.text
421437

438+
class application_data_class:
439+
numUsers = numKeys = app_ver = customer_panel = onlineUsers = ""
422440
# region user_data
423441
class user_data_class:
424442
username = ip = hwid = expires = createdate = lastlogin = subscription = ""
425443

426444
user_data = user_data_class()
445+
app_data = application_data_class()
446+
447+
def __load_app_data(self, data):
448+
self.app_data.numUsers = data["numUsers"]
449+
self.app_data.numKeys = data["numKeys"]
450+
self.app_data.app_ver = data["version"]
451+
self.app_data.customer_panel = data["customerPanelLink"]
452+
self.app_data.onlineUsers = data["numOnlineUsers"]
427453

428454
def __load_user_data(self, data):
429455
self.user_data.username = data["username"]

0 commit comments

Comments
 (0)