|
1 | 1 | # KeyAuth-Python-Example
|
2 | 2 | KeyAuth Python Example For The https://keyauth.cc Authentication system.
|
3 | 3 |
|
4 |
| -# Instructions |
| 4 | +**What is KeyAuth?** |
5 | 5 |
|
6 |
| -Install [Python](https://www.python.org/downloads/) (make sure to add to PATH) |
| 6 | +KeyAuth is an Open source authentication system with cloud hosting plans as well. Client SDKs available for C++, C#, Python, Rust, PHP, JS, GO, Ruby and VB.NET. KeyAuth has several unique features such as memory streaming, webhook function where you can send requests to API without leaking the API, discord webhook notifications, ban the user securely through the application at your discretion. Feel free to join https://keyauth.cc/discord/ If you are experiencing account issues. |
7 | 7 |
|
8 |
| -Open Command Prompt |
| 8 | +**Customer connection issues?** |
9 | 9 |
|
10 |
| -use the cd command to navigate to the path of the KeyAuth files |
| 10 | +This is common amongst all authentication systems. Program obfuscation causes false positives in virus scanners, and with the scale of KeyAuth this is perceived as a malicious domain. So, `keyauth.com` and `keyauth.win` have been blocked by many internet providers. for dashbord, reseller panel, customer panel, use `keyauth.cc` |
11 | 11 |
|
12 |
| -run `pip install -r requirements.txt` |
| 12 | +For API, `keyauth.cc` will not work because I purposefully blocked it on there so `keyauth.cc` doesn't get blocked also. So, you should create your own domain and follow this tutorial video https://www.youtube.com/watch?v=a2SROFJ0eYc. The tutorial video shows you how to create a domain name for 100% free if you don't want to purchase one. |
13 | 13 |
|
14 |
| -set your application information in main.py |
| 14 | +**`KeyAuthApp` instance definition** |
15 | 15 |
|
16 |
| -then run `python main.py` |
| 16 | +Visit and select your application, then click on the **C#** tab |
17 | 17 |
|
18 |
| -Setup video: https://www.youtube.com/watch?v=L2eAQOmuUiA |
| 18 | +It'll provide you with the code which you should replace with in the `Program.cs` file (or `Login.cs` file if using Form example) |
19 | 19 |
|
20 |
| -**What is KeyAuth?** |
| 20 | +```PY |
| 21 | +keyauthapp = api( |
| 22 | + name = "example", #App name (Manage Applications --> Application name) |
| 23 | + ownerid = "JjPMBVlIOd", #Owner ID (Account-Settings --> OwnerID) |
| 24 | + secret = "db40d586f4b189e04e5c18c3c94b7e72221be3f6551995adc05236948d1762bc", #App secret(Manage Applications --> App credentials code) |
| 25 | + version = "1.0", |
| 26 | + hash_to_check = getchecksum() |
| 27 | +) |
| 28 | +``` |
| 29 | + |
| 30 | +**Initialize application** |
| 31 | + |
| 32 | +You don't need to add any code to initalize. KeyAuth will initalize when the instance definition is made. |
| 33 | + |
| 34 | +**Display application information** |
| 35 | + |
| 36 | +```py |
| 37 | +print(f""" |
| 38 | +App data: |
| 39 | +Number of users: {keyauthapp.app_data.numUsers} |
| 40 | +Number of online users: {keyauthapp.app_data.onlineUsers} |
| 41 | +Number of keys: {keyauthapp.app_data.numKeys} |
| 42 | +Application Version: {keyauthapp.app_data.app_ver} |
| 43 | +Customer panel link: {keyauthapp.app_data.customer_panel} |
| 44 | +""") |
| 45 | +``` |
| 46 | + |
| 47 | +**Check session validation** |
| 48 | + |
| 49 | +Use this to see if the user is logged in or not. |
| 50 | + |
| 51 | +```py |
| 52 | +print(f"Current Session Validation Status: {keyauthapp.check()}") |
| 53 | +``` |
| 54 | + |
| 55 | +**Check blacklist status** |
| 56 | + |
| 57 | +Check if HWID or IP Address is blacklisted. You can add this if you want, just to make sure nobody can open your program for less than a second if they're blacklisted. Though, if you don't mind a blacklisted user having the program for a few seconds until they try to login and register, and you care about having the quickest program for your users, you shouldn't use this function then. If a blacklisted user tries to login/register, the KeyAuth server will check if they're blacklisted and deny entry if so. So the check blacklist function is just auxiliary function that's optional. |
| 58 | + |
| 59 | +```py |
| 60 | +if(keyauthapp.checkblacklist()) { |
| 61 | + os._exit(1) |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +**Login with username/password** |
| 66 | + |
| 67 | +```py |
| 68 | +user = input('Provide username: ') |
| 69 | +password = input('Provide password: ') |
| 70 | +keyauthapp.login(user, password) |
| 71 | +``` |
| 72 | + |
| 73 | +**Register with username/password/key** |
| 74 | + |
| 75 | +```py |
| 76 | +user = input('Provide username: ') |
| 77 | +password = input('Provide password: ') |
| 78 | +license = input('Provide License: ') |
| 79 | +keyauthapp.register(user, password, license) |
| 80 | +``` |
| 81 | + |
| 82 | +**Upgrade user username/key** |
| 83 | + |
| 84 | +Used so the user can add extra time to their account by claiming new key. |
| 85 | + |
| 86 | +> **Warning** |
| 87 | +> No password is needed to upgrade account. So, unlike login, register, and license functions - you should **not** log user in after successful upgrade. |
| 88 | +
|
| 89 | +```py |
| 90 | +user = input('Provide username: ') |
| 91 | +license = input('Provide License: ') |
| 92 | +keyauthapp.upgrade(user, license) |
| 93 | +``` |
| 94 | + |
| 95 | +**Login with just license key** |
| 96 | + |
| 97 | +Users can use this function if their license key has never been used before, and if it has been used before. So if you plan to just allow users to use keys, you can remove the login and register functions from your code. |
| 98 | + |
| 99 | +```py |
| 100 | +key = input('Enter your license: ') |
| 101 | +keyauthapp.license(key) |
| 102 | +``` |
| 103 | + |
| 104 | +**User Data** |
| 105 | + |
| 106 | +Show information for current logged-in user. |
| 107 | + |
| 108 | +```py |
| 109 | +print("\nUser data: ") |
| 110 | +print("Username: " + keyauthapp.user_data.username) |
| 111 | +print("IP address: " + keyauthapp.user_data.ip) |
| 112 | +print("Hardware-Id: " + keyauthapp.user_data.hwid) |
| 113 | + |
| 114 | +subs = keyauthapp.user_data.subscriptions # Get all Subscription names, expiry, and timeleft |
| 115 | +for i in range(len(subs)): |
| 116 | + sub = subs[i]["subscription"] # Subscription from every Sub |
| 117 | + expiry = datetime.utcfromtimestamp(int(subs[i]["expiry"])).strftime( |
| 118 | + '%Y-%m-%d %H:%M:%S') # Expiry date from every Sub |
| 119 | + timeleft = subs[i]["timeleft"] # Timeleft from every Sub |
| 120 | + |
| 121 | + print(f"[{i + 1} / {len(subs)}] | Subscription: {sub} - Expiry: {expiry} - Timeleft: {timeleft}") |
| 122 | +print("Created at: " + datetime.utcfromtimestamp(int(keyauthapp.user_data.createdate)).strftime('%Y-%m-%d %H:%M:%S')) |
| 123 | +print("Last login at: " + datetime.utcfromtimestamp(int(keyauthapp.user_data.lastlogin)).strftime('%Y-%m-%d %H:%M:%S')) |
| 124 | +print("Expires at: " + datetime.utcfromtimestamp(int(keyauthapp.user_data.expires)).strftime('%Y-%m-%d %H:%M:%S')) |
| 125 | +print(f"Current Session Validation Status: {keyauthapp.check()}") |
| 126 | +``` |
| 127 | + |
| 128 | +**Show list of online users** |
| 129 | + |
| 130 | +```py |
| 131 | +onlineUsers = keyauthapp.fetchOnline() |
| 132 | +OU = "" # KEEP THIS EMPTY FOR NOW, THIS WILL BE USED TO CREATE ONLINE USER STRING. |
| 133 | +if onlineUsers is None: |
| 134 | + OU = "No online users" |
| 135 | +else: |
| 136 | + for i in range(len(onlineUsers)): |
| 137 | + OU += onlineUsers[i]["credential"] + " " |
| 138 | + |
| 139 | +print("\n" + OU + "\n") |
| 140 | +``` |
| 141 | + |
| 142 | +**Application variables** |
| 143 | + |
| 144 | +A string that is kept on the server-side of KeyAuth. On the dashboard you can choose for each variable to be authenticated (only logged in users can access), or not authenticated (any user can access before login). These are global and static for all users, unlike User Variables which will be dicussed below this section. |
| 145 | + |
| 146 | +```py |
| 147 | +* Get normal variable and print it |
| 148 | +data = keyauthapp.var("varName") |
| 149 | +print(data) |
| 150 | +``` |
| 151 | + |
| 152 | +**User Variables** |
| 153 | + |
| 154 | +User variables are strings kept on the server-side of KeyAuth. They are specific to users. They can be set on Dashboard in the Users tab, via SellerAPI, or via your loader using the code below. `discord` is the user variable name you fetch the user variable by. `test#0001` is the variable data you get when fetching the user variable. |
| 155 | + |
| 156 | +```py |
| 157 | +* Set up user variable |
| 158 | +keyauthapp.setvar("varName", "varValue") |
| 159 | +``` |
| 160 | + |
| 161 | +And here's how you fetch the user variable: |
| 162 | + |
| 163 | +```py |
| 164 | +* Get user variable and print it |
| 165 | +data = keyauthapp.getvar("varName") |
| 166 | +print(data) |
| 167 | +``` |
| 168 | + |
| 169 | +**Application Logs** |
| 170 | + |
| 171 | +Can be used to log data. Good for anti-debug alerts and maybe error debugging. If you set Discord webhook in the app settings of the Dashboard, it will send log messages to your Discord webhook rather than store them on site. It's recommended that you set Discord webhook, as logs on site may be deleted after a couple months of their creation. |
| 172 | + |
| 173 | +You can use the log function before login & after login. |
| 174 | + |
| 175 | +```py |
| 176 | +* Log message to the server and then to your webhook what is set on app settings |
| 177 | +keyauthapp.log("Message") |
| 178 | +``` |
| 179 | + |
| 180 | +**Ban the user** |
| 181 | + |
| 182 | +Ban the user and blacklist their HWID and IP Address. Good function to call upon if you use anti-debug and have detected an intrusion attempt. |
| 183 | + |
| 184 | +Function only works after login. |
| 185 | + |
| 186 | +```py |
| 187 | +keyauthapp.ban(); |
| 188 | +``` |
| 189 | + |
| 190 | +**Server-sided webhooks** |
| 191 | + |
| 192 | +Tutorial video https://www.youtube.com/watch?v=ENRaNPPYJbc |
| 193 | + |
| 194 | +Send HTTP requests to URLs securely without leaking the URL in your application. You should definitely use if you want to send requests to SellerAPI from your application, otherwise if you don't use you'll be leaking your seller key to everyone. And then someone can mess up your application. |
| 195 | + |
| 196 | +1st example is how to send request with no POST data. just a GET request to the URL. `7kR0UedlVI` is the webhook ID, `https://keyauth.win/api/seller/?sellerkey=sellerkeyhere&type=black` is what you should put as the webhook endpoint on the dashboard. This is the part you don't want users to see. And then you have `&ip=1.1.1.1&hwid=abc` in your program code which will be added to the webhook endpoint on the keyauth server and then the request will be sent. |
| 197 | + |
| 198 | +2nd example includes post data. it is form data. it is an example request to the KeyAuth API. `7kR0UedlVI` is the webhook ID, `https://keyauth.win/api/1.2/` is the webhook endpoint. |
| 199 | + |
| 200 | +3rd examples included post data though it's JSON. It's an example reques to Discord webhook `7kR0UedlVI` is the webhook ID, `https://discord.com/api/webhooks/...` is the webhook endpoint. |
| 201 | + |
| 202 | +```py |
| 203 | +* example to send normal request with no POST data |
| 204 | +data = keyauthapp.webhook("7kR0UedlVI", "&ip=1.1.1.1&hwid=abc") |
| 205 | + |
| 206 | +* example to send form data |
| 207 | +data = keyauthapp.webhook("7kR0UedlVI", "", "type=init&name=test&ownerid=j9Gj0FTemM", "application/x-www-form-urlencoded") |
| 208 | + |
| 209 | +* example to send JSON |
| 210 | +data = keyauthapp.webhook("7kR0UedlVI", "", "{\"content\": \"webhook message here\",\"embeds\": null}", "application/json") |
| 211 | +``` |
| 212 | + |
| 213 | +**Download file** |
| 214 | + |
| 215 | +Keep files secure by providing KeyAuth your file download link on the KeyAuth dashboard. Make sure this is a direct download link (as soon as you go to the link, it starts downloading without you clicking anything). The KeyAuth download function provides the bytes, and then you get to decide what to do with those. This example shows how to write it to a file named `text.txt` in the same folder as the program, though you could execute with RunPE or whatever you want. |
| 216 | + |
| 217 | +`385624` is the file ID you get from the dashboard after adding file. |
| 218 | + |
| 219 | +```py |
| 220 | +* Download Files form the server to your computer using the download function in the api class |
| 221 | +bytes = keyauthapp.file("385624") |
| 222 | +f = open("example.exe", "wb") |
| 223 | +f.write(bytes) |
| 224 | +f.close() |
| 225 | +``` |
| 226 | + |
| 227 | +**Chat channels** |
| 228 | + |
| 229 | +Allow users to communicate amongst themselves in your program. |
| 230 | + |
| 231 | +Example from the form example on how to fetch the chat messages. |
| 232 | + |
| 233 | +```py |
| 234 | +* Get chat messages |
| 235 | +messages = keyauthapp.chatGet("CHANNEL") |
| 236 | + |
| 237 | +Messages = "" |
| 238 | +for i in range(len(messages)): |
| 239 | +Messages += datetime.utcfromtimestamp(int(messages[i]["timestamp"])).strftime('%Y-%m-%d %H:%M:%S') + " - " + messages[i]["author"] + ": " + messages[i]["message"] + "\n" |
| 240 | + |
| 241 | +print("\n\n" + Messages) |
| 242 | +``` |
| 243 | + |
| 244 | +Example on how to send chat message. |
21 | 245 |
|
22 |
| -KeyAuth is a GameChanging authentication system. We have never-seen before features, and we listen to our customers. |
23 |
| -Feel free to join https://keyauth.cc/discord/ if you have questions or suggestions. |
| 246 | +```py |
| 247 | +* Send chat message |
| 248 | +keyauthapp.chatSend("MESSAGE", "CHANNEL") |
| 249 | +``` |
0 commit comments