From 6d9665edce95eb99b188ebfa705f2e650c103c55 Mon Sep 17 00:00:00 2001 From: KebsCS Date: Thu, 16 May 2024 15:12:40 +0200 Subject: [PATCH] fix crashes, add disconnect from chat --- KBotExt/KBotExt.vcxproj | 3 ++ KBotExt/LoginTab.h | 117 +++++++++++++++++++++------------------- KBotExt/Misc.h | 12 +++-- KBotExt/MiscTab.h | 8 +++ KBotExt/ProfileTab.h | 19 +++++++ KBotExt/SettingsTab.h | 3 ++ README.md | 4 ++ 7 files changed, 106 insertions(+), 60 deletions(-) diff --git a/KBotExt/KBotExt.vcxproj b/KBotExt/KBotExt.vcxproj index 47ba0ff..4b1af9e 100644 --- a/KBotExt/KBotExt.vcxproj +++ b/KBotExt/KBotExt.vcxproj @@ -145,6 +145,9 @@ true + MultiThreadedDebug + EnableFastChecks + true Windows diff --git a/KBotExt/LoginTab.h b/KBotExt/LoginTab.h index a46b429..4fd307b 100644 --- a/KBotExt/LoginTab.h +++ b/KBotExt/LoginTab.h @@ -302,61 +302,68 @@ class LoginTab if (ImGui::Button("Get email")) { - cpr::Session session; - cpr::Header authHeader = { - {"Content-Type", "application/json"}, - {"Accept-Encoding", "deflate"}, - {"Upgrade-Insecure-Requests", "1"}, - {"sec-ch-ua", R"("Not/A)Brand";v="99", "Google Chrome";v="115", "Chromium";v="115")"}, - {"sec-ch-ua-platform", "\"Windows\""}, - {"sec-ch-ua-mobile", "?0"}, - {"User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"}, - {"Sec-Fetch-Site", "cross-site"}, - {"Sec-Fetch-Mode", "navigate"}, - {"Sec-Fetch-Dest", "document"}, - {"Accept-Language", "en-US,en;q=0.9"}, - { - "Accept", - "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" - }, - {"Referer", "https://riotgames.zendesk.com/"}, - }; - session.SetHeader(authHeader); - - session.SetUrl( - "https://auth.riotgames.com/authorize?redirect_uri=https://login.playersupport.riotgames.com/login_callback&client_id=player-support-zendesk&ui_locales=en-us%20en-us&response_type=code&scope=openid%20email"); - session.Get(); - - Json::Value authData2; - authData2["language"] = "en_GB"; - authData2["password"] = password; - authData2["region"] = Json::nullValue; - authData2["remember"] = false; - authData2["type"] = "auth"; - authData2["username"] = username; - - session.SetBody(authData2.toStyledString()); - session.SetUrl("https://auth.riotgames.com/api/v1/authorization"); - std::string r = session.Put().text; - - Json::CharReaderBuilder builder; - const std::unique_ptr reader(builder.newCharReader()); - JSONCPP_STRING err; - Json::Value rootAuth; - banCheck = r; - if (r.find("\"error\"") == std::string::npos && reader->parse(r.c_str(), r.c_str() + static_cast(r.length()), &rootAuth, &err)) - { - session.SetUrl(rootAuth["response"]["parameters"]["uri"].asString()); - session.Get().text; // UnusedValue - - session.SetUrl("https://support-leagueoflegends.riotgames.com/hc/en-us/requests"); - std::string support = session.Get().text; - std::regex regexStr("\"email\":(.*?),"); - if (std::smatch m; std::regex_search(support, m, regexStr)) - { - banCheck = m.str(); - } - } + MessageBoxA(nullptr, "Login\nClick on 'My Tickets'\nCtrl+Shift+I\nCtrl+F and search for \"email\"", "Info", MB_OK | MB_SETFOREGROUND); + + Utils::OpenUrl(L"https://auth.riotgames.com/authorize?redirect_uri=https://login.playersupport.riotgames.com/login_callback&client_id=player-support-zendesk&ui_locales=en-us%20en-us&response_type=code&scope=openid%20email" + , nullptr, SW_SHOW); + + // Outdated, new login endpoints require captcha + // + //cpr::Session session; + //cpr::Header authHeader = { + // {"Content-Type", "application/json"}, + // {"Accept-Encoding", "deflate"}, + // {"Upgrade-Insecure-Requests", "1"}, + // {"sec-ch-ua", R"("Not/A)Brand";v="99", "Google Chrome";v="115", "Chromium";v="115")"}, + // {"sec-ch-ua-platform", "\"Windows\""}, + // {"sec-ch-ua-mobile", "?0"}, + // {"User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"}, + // {"Sec-Fetch-Site", "cross-site"}, + // {"Sec-Fetch-Mode", "navigate"}, + // {"Sec-Fetch-Dest", "document"}, + // {"Accept-Language", "en-US,en;q=0.9"}, + // { + // "Accept", + // "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" + // }, + // {"Referer", "https://riotgames.zendesk.com/"}, + //}; + //session.SetHeader(authHeader); + + //session.SetUrl( + // "https://auth.riotgames.com/authorize?redirect_uri=https://login.playersupport.riotgames.com/login_callback&client_id=player-support-zendesk&ui_locales=en-us%20en-us&response_type=code&scope=openid%20email"); + //session.Get(); + + //Json::Value authData2; + //authData2["language"] = "en_GB"; + //authData2["password"] = password; + //authData2["region"] = Json::nullValue; + //authData2["remember"] = false; + //authData2["type"] = "auth"; + //authData2["username"] = username; + + //session.SetBody(authData2.toStyledString()); + //session.SetUrl("https://auth.riotgames.com/api/v1/authorization"); + //std::string r = session.Put().text; + + //Json::CharReaderBuilder builder; + //const std::unique_ptr reader(builder.newCharReader()); + //JSONCPP_STRING err; + //Json::Value rootAuth; + //banCheck = r; + //if (r.find("\"error\"") == std::string::npos && reader->parse(r.c_str(), r.c_str() + static_cast(r.length()), &rootAuth, &err)) + //{ + // session.SetUrl(rootAuth["response"]["parameters"]["uri"].asString()); + // session.Get().text; // UnusedValue + + // session.SetUrl("https://support-leagueoflegends.riotgames.com/hc/en-us/requests"); + // std::string support = session.Get().text; + // std::regex regexStr("\"email\":(.*?),"); + // if (std::smatch m; std::regex_search(support, m, regexStr)) + // { + // banCheck = m.str(); + // } + //} } ImGui::Columns(1); diff --git a/KBotExt/Misc.h b/KBotExt/Misc.h index a52610a..2d27167 100644 --- a/KBotExt/Misc.h +++ b/KBotExt/Misc.h @@ -20,7 +20,7 @@ class Misc { public: - static inline std::string programVersion = "1.5.5"; + static inline std::string programVersion = "1.5.6"; static inline std::string latestVersion; static bool LaunchClient(const std::string& args) @@ -201,10 +201,10 @@ class Misc if (currentSkin["isBase"].asBool() == true) { champs[champName].name = champName; - - std::string splashPath = currentSkin["splashPath"].asString(); - size_t keyStart = splashPath.find("champion-splashes/") + strlen("champion-splashes/"); - std::string champKey = splashPath.substr(keyStart, splashPath.find("/", keyStart) - keyStart); + std::string champKey = id; + if (champKey.size() >= 3 && champKey.substr(champKey.size() - 3) == "000") { + champKey.erase(champKey.size() - 3); + } champs[champName].key = std::stoi(champKey); skin.first = id; @@ -246,8 +246,10 @@ class Misc L"RiotClientServices.exe", L"RiotClientUx.exe", L"RiotClientUxRender.exe", + L"Riot Client.exe", L"LeagueCrashHandler.exe", + L"LeagueCrashHandler64.exe", L"LeagueClient.exe", L"LeagueClientUx.exe", L"LeagueClientUxRender.exe" diff --git a/KBotExt/MiscTab.h b/KBotExt/MiscTab.h index cd66483..92807b6 100644 --- a/KBotExt/MiscTab.h +++ b/KBotExt/MiscTab.h @@ -504,6 +504,14 @@ class MiscTab } } + if (ImGui::Button("Get email")) + { + MessageBoxA(nullptr, "Login\nClick on 'My Tickets'\nCtrl+Shift+I\nCtrl+F and search for \"email\"", "Info", MB_OK | MB_SETFOREGROUND); + + Utils::OpenUrl(L"https://auth.riotgames.com/authorize?redirect_uri=https://login.playersupport.riotgames.com/login_callback&client_id=player-support-zendesk&ui_locales=en-us%20en-us&response_type=code&scope=openid%20email" + , nullptr, SW_SHOW); + } + // if (ImGui::Button("Tournament of Souls - unlock all")) // { // LCU::Request("POST", "/lol-marketing-preferences/v1/partition/sfm2023", R"({ diff --git a/KBotExt/ProfileTab.h b/KBotExt/ProfileTab.h index 46e4541..5d38856 100644 --- a/KBotExt/ProfileTab.h +++ b/KBotExt/ProfileTab.h @@ -71,6 +71,25 @@ class ProfileTab LCU::Request("PUT", "https://127.0.0.1/lol-chat/v1/me", body); } + ImGui::SameLine(); + ImGui::Text("\t "); + ImGui::SameLine(); + if (ImGui::Button("Disconnect from chat")) + { + LCU::SetCurrentClientRiotInfo(); + cpr::Post(cpr::Url{ std::format("https://127.0.0.1:{}/chat/v1/suspend", LCU::riot.port) }, + cpr::Body{ "{\"config\":\"disable\"}" }, + cpr::Header{ Utils::StringToHeader(LCU::riot.header) }, cpr::VerifySsl{ false }); + } + + ImGui::SameLine(); + if (ImGui::Button("Reconnect to chat")) + { + LCU::SetCurrentClientRiotInfo(); + cpr::Post(cpr::Url{ std::format("https://127.0.0.1:{}/chat/v1/resume", LCU::riot.port) }, + cpr::Header{ Utils::StringToHeader(LCU::riot.header) }, cpr::VerifySsl{ false }); + } + ImGui::Separator(); ImGui::Text("Rank:"); diff --git a/KBotExt/SettingsTab.h b/KBotExt/SettingsTab.h index e8e0e32..6028572 100644 --- a/KBotExt/SettingsTab.h +++ b/KBotExt/SettingsTab.h @@ -235,6 +235,9 @@ class SettingsTab Misc::programVersion.c_str(), Misc::latestVersion.c_str()); ImGui::Text("GitHub repository:"); ImGui::TextURL("Click me!", "https://github.com/KebsCS/KBotExt", 1, 0); + ImGui::SameLine(); + ImGui::Text("| Discord server:"); + ImGui::TextURL("Click me!", "https://discord.gg/qMmPBFpj2n", 1, 0); if (!result.empty()) ImGui::Separator(); diff --git a/README.md b/README.md index 9d44324..603be82 100644 --- a/README.md +++ b/README.md @@ -65,3 +65,7 @@ 3. Set the solution platform to x64 Release 4. Build the project 5. Feel free to make a pull request with your changes :-) + + +## Discord +Feel free to ask any questions regarding this project, or league client on my [discord server](https://discord.gg/qMmPBFpj2n), although I won't be teaching you how to code there if you're a complete beginner \ No newline at end of file