From 99633ae05786818957ecce04cba84905f9560abb Mon Sep 17 00:00:00 2001 From: Shxde <112267394+Shxde1@users.noreply.github.com> Date: Fri, 22 Mar 2024 17:44:05 -0400 Subject: [PATCH 1/3] Update auth.cpp --- auth.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/auth.cpp b/auth.cpp index e97d4ce..6116797 100644 --- a/auth.cpp +++ b/auth.cpp @@ -1261,6 +1261,26 @@ std::string KeyAuth::api::req(std::string data, std::string url) { debugInfo(data, url, to_return); + struct curl_certinfo* ci; + code = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci); + + if (!code) { + bool issuer_found = false; + + for (int i = 0; i < ci->num_of_certs; i++) { + struct curl_slist* slist; + + for (slist = ci->certinfo[i]; slist; slist = slist->next) { + if (std::strstr(slist->data, XorStr("Google Trust Services").c_str()) != NULL || std::strstr(slist->data, XorStr("Let's Encrypt").c_str()) != NULL) { + issuer_found = true; + } + } + } + + if (!issuer_found) + error(XorStr("SSL certificate couldn't be verified")); + } + return to_return; } void error(std::string message) { From b40e3ee3ee4dbe0b594926e566d8b63a64601f84 Mon Sep 17 00:00:00 2001 From: Shxde <112267394+Shxde1@users.noreply.github.com> Date: Sat, 23 Mar 2024 14:24:52 -0400 Subject: [PATCH 2/3] Update auth.cpp --- auth.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auth.cpp b/auth.cpp index 6116797..50972b1 100644 --- a/auth.cpp +++ b/auth.cpp @@ -250,7 +250,7 @@ bool KeyAuth::api::chatsend(std::string message, std::string channel) return json[("success")]; } -void KeyAuth::api::changeusername(std::string newusername) +void KeyAuth::api::changeUsername(std::string newusername) { checkInit(); @@ -1143,7 +1143,7 @@ std::string KeyAuth::api::fetchonline() std::string onlineusers; - int y = atoi(api::data.numOnlineUsers.c_str()); + int y = atoi(api::app_data.numOnlineUsers.c_str()); for (int i = 0; i < y; i++) { onlineusers.append(json[XorStr("users")][i][XorStr("credential")]); onlineusers.append(XorStr("\n")); From 1f5464be9bf2835d45df4c168009c66940fb08f3 Mon Sep 17 00:00:00 2001 From: Shxde <112267394+Shxde1@users.noreply.github.com> Date: Sat, 23 Mar 2024 14:25:05 -0400 Subject: [PATCH 3/3] Update auth.hpp --- auth.hpp | 64 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/auth.hpp b/auth.hpp index 0d99edb..85a9bf4 100644 --- a/auth.hpp +++ b/auth.hpp @@ -37,7 +37,7 @@ namespace KeyAuth { void regstr(std::string username, std::string password, std::string key, std::string email = ""); void chatget(std::string channel); bool chatsend(std::string message, std::string channel); - void changeusername(std::string newusername); + void changeUsername(std::string newusername); std::string fetchonline(); void fetchstats(); void forgot(std::string username, std::string email); @@ -48,14 +48,9 @@ namespace KeyAuth { std::string expiry; }; - class data_class { + class userdata { public: - // app data - std::string numUsers; - std::string numOnlineUsers; - std::string numKeys; - std::string version; - std::string customerPanelLink; + // user data std::string username; std::string ip; @@ -64,54 +59,71 @@ namespace KeyAuth { std::string lastlogin; std::vector subscriptions; + }; + class appdata { + public: + // app data + std::string numUsers; + std::string numOnlineUsers; + std::string numKeys; + std::string version; + std::string customerPanelLink; + }; + + class responsedata { + public: // response data std::vector channeldata; bool success{}; std::string message; }; - data_class data; + + 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::data.username = data["username"]; - api::data.ip = data["ip"]; + api::user_data.username = data["username"]; + api::user_data.ip = data["ip"]; if (data["hwid"].is_null()) { - api::data.hwid = "none"; + api::user_data.hwid = "none"; } else { - api::data.hwid = data["hwid"]; + api::user_data.hwid = data["hwid"]; } - api::data.createdate = data["createdate"]; - api::data.lastlogin = data["lastlogin"]; + api::user_data.createdate = data["createdate"]; + api::user_data.lastlogin = data["lastlogin"]; for (int i = 0; i < data["subscriptions"].size(); i++) { // Prompto#7895 & stars#2297 was here subscriptions_class subscriptions; subscriptions.name = data["subscriptions"][i]["subscription"]; subscriptions.expiry = data["subscriptions"][i]["expiry"]; - api::data.subscriptions.emplace_back(subscriptions); + api::user_data.subscriptions.emplace_back(subscriptions); } } void load_app_data(nlohmann::json data) { - api::data.numUsers = data["numUsers"]; - api::data.numOnlineUsers = data["numOnlineUsers"]; - api::data.numKeys = data["numKeys"]; - api::data.version = data["version"]; - api::data.customerPanelLink = data["customerPanelLink"]; + api::app_data.numUsers = data["numUsers"]; + api::app_data.numOnlineUsers = data["numOnlineUsers"]; + api::app_data.numKeys = data["numKeys"]; + api::app_data.version = data["version"]; + api::app_data.customerPanelLink = data["customerPanelLink"]; } void load_response_data(nlohmann::json data) { - api::data.success = data["success"]; - api::data.message = data["message"]; + api::response.success = data["success"]; + api::response.message = data["message"]; } void load_channel_data(nlohmann::json data) { - api::data.success = data["success"]; - api::data.message = data["message"]; + api::response.success = data["success"]; + api::response.message = data["message"]; for (const auto sub : data["messages"]) { std::string authoroutput = sub["author"]; @@ -121,7 +133,7 @@ namespace KeyAuth { 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::data.channeldata.push_back(output); + api::response.channeldata.push_back(output); } }