Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include "auth.hpp"
- #include <string>
- #include "utils.hpp"
- #include "skStr.h"
- std::string tm_to_readable_time(tm ctx);
- static std::time_t string_to_timet(std::string timestamp);
- static std::tm timet_to_tm(time_t timestamp);
- const std::string compilation_date = (std::string)skCrypt(__DATE__);
- const std::string compilation_time = (std::string)skCrypt(__TIME__);
- using namespace KeyAuth;
- auto name = skCrypt("test");
- auto ownerid = skCrypt("dw8LuSHasy");
- auto secret = skCrypt("c13e16a15c4d2033a9e7eca75479ef42d0c726b1691b8de339c9d5fb87f15282");
- auto version = skCrypt("1.0");
- auto url = skCrypt("https://keyauth.win/api/1.2/"); // change if you're self-hosting
- api KeyAuthApp(name.decrypt(), ownerid.decrypt(), secret.decrypt(), version.decrypt(), url.decrypt());
- int main()
- {
- // Freeing memory to prevent memory leak or memory scraping
- name.clear(); ownerid.clear(); secret.clear(); version.clear(); url.clear();
- std::string consoleTitle = skCrypt("Loader - Built at: ").decrypt() + compilation_date + " " + compilation_time;
- SetConsoleTitleA(consoleTitle.c_str());
- std::cout << skCrypt("\n\n Connecting..");
- KeyAuthApp.init();
- if (!KeyAuthApp.data.success)
- {
- std::cout << skCrypt("\n Status: ") << KeyAuthApp.data.message;
- Sleep(1500);
- exit(1);
- }
- if (std::filesystem::exists("test.json")) //change test.txt to the path of your file :smile:
- {
- if (!CheckIfJsonKeyExists("test.json", "username"))
- {
- std::string key = ReadFromJson("test.json", "license");
- KeyAuthApp.license(key);
- if (!KeyAuthApp.data.success)
- {
- std::remove("test.json");
- std::cout << skCrypt("\n Status: ") << KeyAuthApp.data.message;
- Sleep(1500);
- exit(1);
- }
- std::cout << skCrypt("\n\n Successfully Automatically Logged In\n");
- }
- else
- {
- std::string username = ReadFromJson("test.json", "username");
- std::string password = ReadFromJson("test.json", "password");
- KeyAuthApp.login(username, password);
- if (!KeyAuthApp.data.success)
- {
- std::remove("test.json");
- std::cout << skCrypt("\n Status: ") << KeyAuthApp.data.message;
- Sleep(1500);
- exit(1);
- }
- std::cout << skCrypt("\n\n Successfully Automatically Logged In\n");
- }
- }
- else
- {
- std::cout << skCrypt("\n\n [1] Login\n [2] Register\n [3] Upgrade\n [4] License key only\n\n Choose option: ");
- int option;
- std::string username;
- std::string password;
- std::string key;
- std::cin >> option;
- switch (option)
- {
- case 1:
- std::cout << skCrypt("\n\n Enter username: ");
- std::cin >> username;
- std::cout << skCrypt("\n Enter password: ");
- std::cin >> password;
- KeyAuthApp.login(username, password);
- break;
- case 2:
- std::cout << skCrypt("\n\n Enter username: ");
- std::cin >> username;
- std::cout << skCrypt("\n Enter password: ");
- std::cin >> password;
- std::cout << skCrypt("\n Enter license: ");
- std::cin >> key;
- KeyAuthApp.regstr(username, password, key);
- break;
- case 3:
- std::cout << skCrypt("\n\n Enter username: ");
- std::cin >> username;
- std::cout << skCrypt("\n Enter license: ");
- std::cin >> key;
- KeyAuthApp.upgrade(username, key);
- break;
- case 4:
- std::cout << skCrypt("\n Enter license: ");
- std::cin >> key;
- KeyAuthApp.license(key);
- break;
- default:
- std::cout << skCrypt("\n\n Status: Failure: Invalid Selection");
- Sleep(3000);
- exit(1);
- }
- if (!KeyAuthApp.data.success)
- {
- std::cout << skCrypt("\n Status: ") << KeyAuthApp.data.message;
- Sleep(1500);
- exit(1);
- }
- if (username.empty() || password.empty())
- {
- WriteToJson("test.json", "license", key, false, "", "");
- std::cout << skCrypt("Successfully Created File For Auto Login");
- }
- else
- {
- WriteToJson("test.json", "username", username, true, "password", password);
- std::cout << skCrypt("Successfully Created File For Auto Login");
- }
- }
- std::cout << skCrypt("\n User data:");
- std::cout << skCrypt("\n Username: ") << KeyAuthApp.data.username;
- std::cout << skCrypt("\n IP address: ") << KeyAuthApp.data.ip;
- std::cout << skCrypt("\n Hardware-Id: ") << KeyAuthApp.data.hwid;
- std::cout << skCrypt("\n Create date: ") << tm_to_readable_time(timet_to_tm(string_to_timet(KeyAuthApp.data.createdate)));
- std::cout << skCrypt("\n Last login: ") << tm_to_readable_time(timet_to_tm(string_to_timet(KeyAuthApp.data.lastlogin)));
- std::cout << skCrypt("\n Subscription(s): ");
- for (int i = 0; i < KeyAuthApp.data.subscriptions.size(); i++) {
- auto sub = KeyAuthApp.data.subscriptions.at(i);
- std::cout << skCrypt("\n name: ") << sub.name;
- std::cout << skCrypt(" : expiry: ") << tm_to_readable_time(timet_to_tm(string_to_timet(sub.expiry)));
- }
- std::cout << skCrypt("\n\n Closing in five seconds...");
- Sleep(5000);
- return 0;
- }
- std::string tm_to_readable_time(tm ctx) {
- char buffer[80];
- strftime(buffer, sizeof(buffer), "%a %m/%d/%y %H:%M:%S %Z", &ctx);
- return std::string(buffer);
- }
- static std::time_t string_to_timet(std::string timestamp) {
- auto cv = strtol(timestamp.c_str(), NULL, 10); // long
- return (time_t)cv;
- }
- static std::tm timet_to_tm(time_t timestamp) {
- std::tm context;
- localtime_s(&context, ×tamp);
- return context;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement