Advertisement
whitecode12

Keyauth

Apr 3rd, 2024
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.06 KB | Cybersecurity | 0 0
  1. #include <Windows.h>
  2. #include "auth.hpp"
  3. #include <string>
  4. #include "utils.hpp"
  5. #include "skStr.h"
  6. std::string tm_to_readable_time(tm ctx);
  7. static std::time_t string_to_timet(std::string timestamp);
  8. static std::tm timet_to_tm(time_t timestamp);
  9. const std::string compilation_date = (std::string)skCrypt(__DATE__);
  10. const std::string compilation_time = (std::string)skCrypt(__TIME__);
  11.  
  12. using namespace KeyAuth;
  13.  
  14. auto name = skCrypt("test");
  15. auto ownerid = skCrypt("dw8LuSHasy");
  16. auto secret = skCrypt("c13e16a15c4d2033a9e7eca75479ef42d0c726b1691b8de339c9d5fb87f15282");
  17. auto version = skCrypt("1.0");
  18. auto url = skCrypt("https://keyauth.win/api/1.2/"); // change if you're self-hosting
  19.  
  20. api KeyAuthApp(name.decrypt(), ownerid.decrypt(), secret.decrypt(), version.decrypt(), url.decrypt());
  21.  
  22. int main()
  23. {
  24.     // Freeing memory to prevent memory leak or memory scraping
  25.     name.clear(); ownerid.clear(); secret.clear(); version.clear(); url.clear();
  26.    
  27.     std::string consoleTitle = skCrypt("Loader - Built at:  ").decrypt() + compilation_date + " " + compilation_time;
  28.     SetConsoleTitleA(consoleTitle.c_str());
  29.     std::cout << skCrypt("\n\n Connecting..");
  30.     KeyAuthApp.init();
  31.     if (!KeyAuthApp.data.success)
  32.     {
  33.         std::cout << skCrypt("\n Status: ") << KeyAuthApp.data.message;
  34.         Sleep(1500);
  35.         exit(1);
  36.     }
  37.  
  38.     if (std::filesystem::exists("test.json")) //change test.txt to the path of your file :smile:
  39.     {
  40.         if (!CheckIfJsonKeyExists("test.json", "username"))
  41.         {
  42.             std::string key = ReadFromJson("test.json", "license");
  43.             KeyAuthApp.license(key);
  44.             if (!KeyAuthApp.data.success)
  45.             {
  46.                 std::remove("test.json");
  47.                 std::cout << skCrypt("\n Status: ") << KeyAuthApp.data.message;
  48.                 Sleep(1500);
  49.                 exit(1);
  50.             }
  51.             std::cout << skCrypt("\n\n Successfully Automatically Logged In\n");
  52.         }
  53.         else
  54.         {
  55.             std::string username = ReadFromJson("test.json", "username");
  56.             std::string password = ReadFromJson("test.json", "password");
  57.             KeyAuthApp.login(username, password);
  58.             if (!KeyAuthApp.data.success)
  59.             {
  60.                 std::remove("test.json");
  61.                 std::cout << skCrypt("\n Status: ") << KeyAuthApp.data.message;
  62.                 Sleep(1500);
  63.                 exit(1);
  64.             }
  65.             std::cout << skCrypt("\n\n Successfully Automatically Logged In\n");
  66.         }
  67.     }
  68.     else
  69.     {
  70.         std::cout << skCrypt("\n\n [1] Login\n [2] Register\n [3] Upgrade\n [4] License key only\n\n Choose option: ");
  71.  
  72.         int option;
  73.         std::string username;
  74.         std::string password;
  75.         std::string key;
  76.  
  77.         std::cin >> option;
  78.         switch (option)
  79.         {
  80.         case 1:
  81.             std::cout << skCrypt("\n\n Enter username: ");
  82.             std::cin >> username;
  83.             std::cout << skCrypt("\n Enter password: ");
  84.             std::cin >> password;
  85.             KeyAuthApp.login(username, password);
  86.             break;
  87.         case 2:
  88.             std::cout << skCrypt("\n\n Enter username: ");
  89.             std::cin >> username;
  90.             std::cout << skCrypt("\n Enter password: ");
  91.             std::cin >> password;
  92.             std::cout << skCrypt("\n Enter license: ");
  93.             std::cin >> key;
  94.             KeyAuthApp.regstr(username, password, key);
  95.             break;
  96.         case 3:
  97.             std::cout << skCrypt("\n\n Enter username: ");
  98.             std::cin >> username;
  99.             std::cout << skCrypt("\n Enter license: ");
  100.             std::cin >> key;
  101.             KeyAuthApp.upgrade(username, key);
  102.             break;
  103.         case 4:
  104.             std::cout << skCrypt("\n Enter license: ");
  105.             std::cin >> key;
  106.             KeyAuthApp.license(key);
  107.             break;
  108.         default:
  109.             std::cout << skCrypt("\n\n Status: Failure: Invalid Selection");
  110.             Sleep(3000);
  111.             exit(1);
  112.         }
  113.  
  114.         if (!KeyAuthApp.data.success)
  115.         {
  116.             std::cout << skCrypt("\n Status: ") << KeyAuthApp.data.message;
  117.             Sleep(1500);
  118.             exit(1);
  119.         }
  120.         if (username.empty() || password.empty())
  121.         {
  122.             WriteToJson("test.json", "license", key, false, "", "");
  123.             std::cout << skCrypt("Successfully Created File For Auto Login");
  124.         }
  125.         else
  126.         {
  127.             WriteToJson("test.json", "username", username, true, "password", password);
  128.             std::cout << skCrypt("Successfully Created File For Auto Login");
  129.         }
  130.  
  131.  
  132.     }
  133.    
  134.     std::cout << skCrypt("\n User data:");
  135.     std::cout << skCrypt("\n Username: ") << KeyAuthApp.data.username;
  136.     std::cout << skCrypt("\n IP address: ") << KeyAuthApp.data.ip;
  137.     std::cout << skCrypt("\n Hardware-Id: ") << KeyAuthApp.data.hwid;
  138.     std::cout << skCrypt("\n Create date: ") << tm_to_readable_time(timet_to_tm(string_to_timet(KeyAuthApp.data.createdate)));
  139.     std::cout << skCrypt("\n Last login: ") << tm_to_readable_time(timet_to_tm(string_to_timet(KeyAuthApp.data.lastlogin)));
  140.     std::cout << skCrypt("\n Subscription(s): ");
  141.  
  142.     for (int i = 0; i < KeyAuthApp.data.subscriptions.size(); i++) {
  143.         auto sub = KeyAuthApp.data.subscriptions.at(i);
  144.         std::cout << skCrypt("\n name: ") << sub.name;
  145.         std::cout << skCrypt(" : expiry: ") << tm_to_readable_time(timet_to_tm(string_to_timet(sub.expiry)));
  146.     }
  147.  
  148.     std::cout << skCrypt("\n\n Closing in five seconds...");
  149.     Sleep(5000);
  150.    
  151.     return 0;
  152. }
  153.  
  154. std::string tm_to_readable_time(tm ctx) {
  155.     char buffer[80];
  156.  
  157.     strftime(buffer, sizeof(buffer), "%a %m/%d/%y %H:%M:%S %Z", &ctx);
  158.  
  159.     return std::string(buffer);
  160. }
  161.  
  162. static std::time_t string_to_timet(std::string timestamp) {
  163.     auto cv = strtol(timestamp.c_str(), NULL, 10); // long
  164.  
  165.     return (time_t)cv;
  166. }
  167.  
  168. static std::tm timet_to_tm(time_t timestamp) {
  169.     std::tm context;
  170.  
  171.     localtime_s(&context, &timestamp);
  172.  
  173.     return context;
  174. }
  175.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement