diff --git a/x64/auth.hpp b/x64/auth.hpp index 3d493b9..89e1fd0 100644 --- a/x64/auth.hpp +++ b/x64/auth.hpp @@ -1,7 +1,8 @@ -#include -#include -#include -#include +#include +#include +#include + +#define CURL_STATICLIB struct channel_struct { @@ -14,7 +15,7 @@ namespace KeyAuth { class api { public: - std::string name, ownerid, version, url, path; + std::string name, ownerid, version, url, path; api(std::string name, std::string ownerid, std::string version, std::string url, std::string path) : name(name), ownerid(ownerid), version(version), url(url), path(path) {} @@ -22,7 +23,7 @@ namespace KeyAuth { void init(); void check(bool check_paid = false); void log(std::string msg); - void license(std::string key); + void license(std::string key, std::string code = ""); std::string var(std::string varid); std::string webhook(std::string id, std::string params, std::string body = "", std::string contenttype = ""); void setvar(std::string var, std::string vardata); @@ -31,7 +32,7 @@ namespace KeyAuth { void web_login(); void button(std::string value); void upgrade(std::string username, std::string key); - void login(std::string username, std::string password); + void login(std::string username, std::string password, std::string code = ""); std::vector download(std::string fileid); void regstr(std::string username, std::string password, std::string key, std::string email = ""); void chatget(std::string channel); @@ -41,6 +42,8 @@ namespace KeyAuth { void fetchstats(); void forgot(std::string username, std::string email); void logout(); + void enable2fa(std::string code = ""); + void disable2fa(std::string code); class subscriptions_class { public: @@ -83,8 +86,67 @@ namespace KeyAuth { userdata user_data; appdata app_data; responsedata response; - private: std::string sessionid, enckey; + + static std::string req(std::string data, std::string url); + + + void load_user_data(nlohmann::json data) { + api::user_data.username = data[XorStr("username")]; + api::user_data.ip = data[XorStr("ip")]; + if (data[XorStr("hwid")].is_null()) { + api::user_data.hwid = XorStr("none"); + } + else { + api::user_data.hwid = data[XorStr("hwid")]; + } + api::user_data.createdate = data[XorStr("createdate")]; + api::user_data.lastlogin = data[XorStr("lastlogin")]; + + for (int i = 0; i < data[XorStr("subscriptions")].size(); i++) { // Prompto#7895 & stars#2297 was here + subscriptions_class subscriptions; + subscriptions.name = data[XorStr("subscriptions")][i][XorStr("subscription")]; + subscriptions.expiry = data[XorStr("subscriptions")][i][XorStr("expiry")]; + api::user_data.subscriptions.emplace_back(subscriptions); + } + } + + void load_app_data(nlohmann::json data) { + api::app_data.numUsers = data[XorStr("numUsers")]; + api::app_data.numOnlineUsers = data[XorStr("numOnlineUsers")]; + api::app_data.numKeys = data[XorStr("numKeys")]; + api::app_data.version = data[XorStr("version")]; + api::app_data.customerPanelLink = data[XorStr("customerPanelLink")]; + } + + void load_response_data(nlohmann::json data) { + api::response.success = data[XorStr("success")]; + api::response.message = data["message"]; + + if (data.contains(XorStr("role").c_str()) && data[XorStr("role")] != XorStr("tester").c_str() && data[XorStr("role")] != XorStr("not_checked").c_str()) { + api::response.isPaid = true; + } + } + + void load_channel_data(nlohmann::json data) { + api::response.success = data["success"]; // intentional. Possibly trick a reverse engineer into thinking this string is for login function + api::response.message = data["message"]; + api::response.channeldata.clear(); //If you do not delete the data before pushing it, the data will be repeated. github.com/TTakaTit + for (const auto sub : data["messages"]) { + + std::string authoroutput = sub[XorStr("author")]; + std::string messageoutput = sub["message"]; + int timestamp = sub[XorStr("timestamp")]; std::string timestampoutput = std::to_string(timestamp); + authoroutput.erase(remove(authoroutput.begin(), authoroutput.end(), '"'), authoroutput.end()); + messageoutput.erase(remove(messageoutput.begin(), messageoutput.end(), '"'), messageoutput.end()); + timestampoutput.erase(remove(timestampoutput.begin(), timestampoutput.end(), '"'), timestampoutput.end()); + channel_struct output = { authoroutput , messageoutput, timestampoutput }; + api::response.channeldata.push_back(output); + } + } + + nlohmann::json response_decoder; + }; } diff --git a/x64/library_x64.lib b/x64/library_x64.lib index a525028..9d72067 100644 Binary files a/x64/library_x64.lib and b/x64/library_x64.lib differ diff --git a/x86/lib/auth.cpp b/x86/lib/auth.cpp index 95aa775..a827a03 100644 --- a/x86/lib/auth.cpp +++ b/x86/lib/auth.cpp @@ -210,7 +210,7 @@ static size_t header_callback(char* buffer, size_t size, size_t nitems, void* us return nitems * size; } -void KeyAuth::api::login(std::string username, std::string password) +void KeyAuth::api::login(std::string username, std::string password, std::string code) { checkInit(); @@ -219,6 +219,7 @@ void KeyAuth::api::login(std::string username, std::string password) XorStr("type=login") + XorStr("&username=") + username + XorStr("&pass=") + password + + XorStr("&code=") + code + XorStr("&hwid=") + hwid + XorStr("&sessionid=") + sessionid + XorStr("&name=") + name + @@ -826,13 +827,14 @@ void KeyAuth::api::upgrade(std::string username, std::string key) { load_response_data(json); } -void KeyAuth::api::license(std::string key) { +void KeyAuth::api::license(std::string key, std::string code) { checkInit(); std::string hwid = utils::get_hwid(); auto data = XorStr("type=license") + XorStr("&key=") + key + + XorStr("&code=") + code + XorStr("&hwid=") + hwid + XorStr("&sessionid=") + sessionid + XorStr("&name=") + name + @@ -865,6 +867,88 @@ void KeyAuth::api::license(std::string key) { load_user_data(json[(XorStr("info"))]); } +void KeyAuth::api::enable2fa(std::string code) +{ + checkInit(); + + auto data = + XorStr("type=enable2fa") + + XorStr("&code=") + code + + XorStr("&sessionid=") + sessionid + + XorStr("&name=") + name + + XorStr("&ownerid=") + ownerid; + + auto response = req(data, url); + std::hash hasher; + int expectedHash = hasher(42); + int result = VerifyPayload(signature, signatureTimestamp, response.data()); + if ((hasher(result ^ 0xA5A5) & 0xFFFF) == (expectedHash & 0xFFFF)) + { + + auto json = response_decoder.parse(response); + if (json[(XorStr("ownerid"))] != ownerid) { + LI_FN(exit)(8); + } + + std::string message = json[(XorStr("message"))]; + + std::hash hasher; + size_t expectedHash = hasher(68); + size_t resultCode = hasher(json[(XorStr("code"))]); + + if (!json[(XorStr("success"))] || (json[(XorStr("success"))] && (resultCode == expectedHash))) { + load_response_data(json); + } + else { + LI_FN(exit)(9); + } + } + else { + LI_FN(exit)(7); + } +} + +void KeyAuth::api::disable2fa(std::string code) +{ + checkInit(); + + auto data = + XorStr("type=disable2fa") + + XorStr("&code=") + code + + XorStr("&sessionid=") + sessionid + + XorStr("&name=") + name + + XorStr("&ownerid=") + ownerid; + + auto response = req(data, url); + std::hash hasher; + int expectedHash = hasher(42); + int result = VerifyPayload(signature, signatureTimestamp, response.data()); + if ((hasher(result ^ 0xA5A5) & 0xFFFF) == (expectedHash & 0xFFFF)) + { + + auto json = response_decoder.parse(response); + if (json[(XorStr("ownerid"))] != ownerid) { + LI_FN(exit)(8); + } + + std::string message = json[(XorStr("message"))]; + + std::hash hasher; + size_t expectedHash = hasher(68); + size_t resultCode = hasher(json[(XorStr("code"))]); + + if (!json[(XorStr("success"))] || (json[(XorStr("success"))] && (resultCode == expectedHash))) { + load_response_data(json); + } + else { + LI_FN(exit)(9); + } + } + else { + LI_FN(exit)(7); + } +} + void KeyAuth::api::setvar(std::string var, std::string vardata) { checkInit(); diff --git a/x86/lib/auth.hpp b/x86/lib/auth.hpp index 556c16a..253e1d5 100644 --- a/x86/lib/auth.hpp +++ b/x86/lib/auth.hpp @@ -29,7 +29,7 @@ namespace KeyAuth { void init(); void check(); void log(std::string msg); - void license(std::string key); + void license(std::string key, std::string code = ""); std::string var(std::string varid); std::string webhook(std::string id, std::string params, std::string body = "", std::string contenttype = ""); void setvar(std::string var, std::string vardata); @@ -38,7 +38,7 @@ namespace KeyAuth { void web_login(); void button(std::string value); void upgrade(std::string username, std::string key); - void login(std::string username, std::string password); + void login(std::string username, std::string password, std::string code = ""); std::vector download(std::string fileid); void regstr(std::string username, std::string password, std::string key, std::string email = ""); void chatget(std::string channel); @@ -48,6 +48,8 @@ namespace KeyAuth { void fetchstats(); void forgot(std::string username, std::string email); void logout(); + void enable2fa(std::string code = ""); + void disable2fa(std::string code); class subscriptions_class { public: