Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 30 additions & 24 deletions keyauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@
from Crypto.Util.Padding import pad, unpad
# aes + padding, sha256

import webbrowser, platform, subprocess, datetime
import webbrowser
import platform
import subprocess
import datetime
import sys

from requests_toolbelt.adapters.fingerprint import FingerprintAdapter


KEYSAVE_PATH = "C:\\ProgramData\\keysave.txt"


class api:
name = ownerid = secret = ""

Expand All @@ -35,9 +43,9 @@ def init(self):
init_iv = SHA256.new(self.session_iv.encode()).hexdigest()

post_data = {
"type": binascii.hexlify(("init").encode()),
"type": binascii.hexlify(("init").encode()),
"name": binascii.hexlify(self.name.encode()),
"ownerid": binascii.hexlify(self.ownerid.encode()),
"ownerid": binascii.hexlify(self.ownerid.encode()),
"init_iv": init_iv
}

Expand All @@ -53,58 +61,55 @@ def init(self):
else:
print("The program key you tried to use doesn't exist")
sys.exit()


def login(self, key, hwid=None):
if hwid is None: hwid = others.get_hwid()

if hwid is None:
hwid = others.get_hwid()

self.session_iv = str(uuid4())[:8]

init_iv = SHA256.new(self.session_iv.encode()).hexdigest()

post_data = {
"type": binascii.hexlify(("login").encode()),
"type": binascii.hexlify(("login").encode()),
"key": encryption.encrypt(key, self.secret, init_iv),
"hwid": encryption.encrypt(hwid, self.secret, init_iv),
"name": binascii.hexlify(self.name.encode()),
"ownerid": binascii.hexlify(self.ownerid.encode()),
"ownerid": binascii.hexlify(self.ownerid.encode()),
"init_iv": init_iv
}

response = self.__do_request(post_data)

response = encryption.decrypt(response, self.secret, init_iv)

if response == "KeyAuth_Valid":
print("Logged in")
if response == "KeyAuth_Invalid":
print("Key not found")
if os.path.exists('C:\\ProgramData\\keysave.txt'):
os.remove("C:\\ProgramData\\keysave.txt")
if os.path.exists(KEYSAVE_PATH):
os.remove(KEYSAVE_PATH)
sys.exit()
if response == "KeyAuth_InvalidHWID":
print("This computer doesn't match the computer the key is locked to. If you reset your computer, contact the application owner")
if os.path.exists('C:\\ProgramData\\keysave.txt'):
os.remove("C:\\ProgramData\\keysave.txt")
if os.path.exists(KEYSAVE_PATH):
os.remove(KEYSAVE_PATH)
sys.exit()
if response == "KeyAuth_Expired":
print("This key is expired")
if os.path.exists('C:\\ProgramData\\keysave.txt'):
os.remove("C:\\ProgramData\\keysave.txt")
if os.path.exists(KEYSAVE_PATH):
os.remove(KEYSAVE_PATH)
sys.exit()
else:
print("Application Failed To Connect. Try again or contact application owner")
if os.path.exists('C:\\ProgramData\\keysave.txt'):
os.remove("C:\\ProgramData\\keysave.txt")
if os.path.exists(KEYSAVE_PATH):
os.remove(KEYSAVE_PATH)
sys.exit()


def __do_request(self, post_data):
headers = {"User-Agent": "KeyAuth"}

rq = requests.Session()

rq_out = rq.post(
rq_out = requests.post(
"https://keyauth.com/api/", data=post_data, headers=headers, verify=False
)

Expand All @@ -117,9 +122,10 @@ def get_hwid():
if platform.system() != "Windows":
return "None"

cmd = subprocess.Popen("wmic useraccount where name='%username%' get sid", stdout=subprocess.PIPE, shell=True)
cmd = subprocess.Popen(
"wmic useraccount where name='%username%' get sid", stdout=subprocess.PIPE, shell=True)

(suppost_sid, error) = cmd.communicate()
(suppost_sid, _error) = cmd.communicate()

suppost_sid = suppost_sid.split(b'\n')[1].strip()

Expand Down
19 changes: 10 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
import os
import os.path

KEYSAVE_PATH = "C:\\ProgramData\\keysave.txt"

keyauthapp = api("your app name here", "your ownerid here", "your app secret here")

print("Initializing")
keyauthapp.init()

if os.path.exists('C:\\ProgramData\\keysave.txt'):
with open ("C:\\ProgramData\\keysave.txt", "r") as file:
data=file.readlines()
if os.path.exists(KEYSAVE_PATH):
with open (KEYSAVE_PATH, "r") as file:
data = file.readlines()
keyauthapp.login(data)
else:
_key = input('Enter your key: ')
keyauthapp.login(_key)

keysave = open("C:\\ProgramData\\keysave.txt", "w")
n = keysave.write(_key)
keysave.close()
key = input('Enter your key: ')
keyauthapp.login(key)
keysave = open(KEYSAVE_PATH, "w")
n = keysave.write(key)
keysave.close()
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests,
requests_toolbelt,
pycryptodome,
requests
requests_toolbelt
pycryptodome