diff --git a/LICENSE b/LICENSE index ae153be..5849551 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 KeyAuth +Copyright (c) 2022 KeyAuth Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 85624a1..0b8338c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # KeyAuth-Python-Example -KeyAuth Python Example For The https://keyauth.win Authentication system. +KeyAuth Python Example For The https://keyauth.cc Authentication system. # Instructions @@ -20,4 +20,4 @@ Setup video: https://www.youtube.com/watch?v=L2eAQOmuUiA **What is KeyAuth?** KeyAuth is a GameChanging authentication system. We have never-seen before features, and we listen to our customers. -Feel free to join https://keyauth.win/discord/ if you have questions or suggestions. +Feel free to join https://keyauth.cc/discord/ if you have questions or suggestions. diff --git a/keyauth.py b/keyauth.py index df8c854..7e283eb 100644 --- a/keyauth.py +++ b/keyauth.py @@ -412,6 +412,78 @@ def log(self, message): } self.__do_request(post_data) + + def fetchOnline(self): + self.checkinit() + init_iv = SHA256.new(str(uuid4())[:8].encode()).hexdigest() + + post_data = { + "type": binascii.hexlify(("fetchOnline").encode()), + "sessionid": binascii.hexlify(self.sessionid.encode()), + "name": binascii.hexlify(self.name.encode()), + "ownerid": binascii.hexlify(self.ownerid.encode()), + "init_iv": init_iv + } + + response = self.__do_request(post_data) + response = encryption.decrypt(response, self.enckey, init_iv) + + json = jsond.loads(response) + + if json["success"]: + if json["users"]["0"]: + return None ## THIS IS ISSUE ON KEYAUTH SERVER SIDE 6.8.2022 so it will return none if it is not an array. + else: + return json["users"] + else: + return None + + def chatGet(self, channel): + self.checkinit() + init_iv = SHA256.new(str(uuid4())[:8].encode()).hexdigest() + + post_data = { + "type": binascii.hexlify(("chatget").encode()), + "channel": encryption.encrypt(channel, self.enckey, init_iv), + "sessionid": binascii.hexlify(self.sessionid.encode()), + "name": binascii.hexlify(self.name.encode()), + "ownerid": binascii.hexlify(self.ownerid.encode()), + "init_iv": init_iv + } + + response = self.__do_request(post_data) + response = encryption.decrypt(response, self.enckey, init_iv) + + json = jsond.loads(response) + + if json["success"]: + return json["messages"] + else: + return None + + def chatSend(self, message, channel): + self.checkinit() + init_iv = SHA256.new(str(uuid4())[:8].encode()).hexdigest() + + post_data = { + "type": binascii.hexlify(("chatsend").encode()), + "message": encryption.encrypt(message, self.enckey, init_iv), + "channel": encryption.encrypt(channel, self.enckey, init_iv), + "sessionid": binascii.hexlify(self.sessionid.encode()), + "name": binascii.hexlify(self.name.encode()), + "ownerid": binascii.hexlify(self.ownerid.encode()), + "init_iv": init_iv + } + + response = self.__do_request(post_data) + response = encryption.decrypt(response, self.enckey, init_iv) + + json = jsond.loads(response) + + if json["success"]: + return True + else: + return False def checkinit(self): if not self.initialized: @@ -430,7 +502,7 @@ class application_data_class: numUsers = numKeys = app_ver = customer_panel = onlineUsers = "" # region user_data class user_data_class: - username = ip = hwid = expires = createdate = lastlogin = subscription = "" + username = ip = hwid = expires = createdate = lastlogin = subscription = subscriptions "" user_data = user_data_class() app_data = application_data_class() diff --git a/main.py b/main.py index 508e17d..50f3115 100644 --- a/main.py +++ b/main.py @@ -29,6 +29,7 @@ def getchecksum(): version = "1.0", hash_to_check = getchecksum() ) + print(f""" App data: Number of users: {keyauthapp.app_data.numUsers} @@ -101,6 +102,18 @@ def getchecksum(): #* example to send normal request with no POST data #data = keyauthapp.webhook("WebhookID", "?type=resetuser&user=username") +#* Get chat messages +#messages = keyauthapp.chatGet("CHANNEL") + +#Messages = "" +#for i in range(len(messages)): +# Messages += datetime.utcfromtimestamp(int(messages[i]["timestamp"])).strftime('%Y-%m-%d %H:%M:%S') + " - " + messages[i]["author"] + ": " + messages[i]["message"] + "\n" + +#print("\n\n" + Messages) + +#* Send chat message +#keyauthapp.chatSend("MESSAGE", "CHANNEL") + #endregion print("\nUser data: ") @@ -117,6 +130,16 @@ def getchecksum(): print(f"[{i + 1} / {len(subs)}] | Subscription: {sub} - Expiry: {expiry} - Timeleft: {timeleft}") +onlineUsers = keyauthapp.fetchOnline() +OU = "" ## KEEP THIS EMPTY FOR NOW, THIS WILL BE USED TO CREATE ONLINE USER STRING. +if onlineUsers == None: + OU = "No online users" +else: + for i in range(len(onlineUsers)): + OU += onlineUsers[i]["credential"] + " " + +print("\n" + OU + "\n") + print("Created at: " + datetime.utcfromtimestamp(int(keyauthapp.user_data.createdate)).strftime('%Y-%m-%d %H:%M:%S')) print("Last login at: " + datetime.utcfromtimestamp(int(keyauthapp.user_data.lastlogin)).strftime('%Y-%m-%d %H:%M:%S'))