Skip to content

Commit

Permalink
fix crashes, add disconnect from chat
Browse files Browse the repository at this point in the history
  • Loading branch information
KebsCS committed May 16, 2024
1 parent ee9a65e commit 6d9665e
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 60 deletions.
3 changes: 3 additions & 0 deletions KBotExt/KBotExt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@
<EnableModules>true</EnableModules>
<FloatingPointModel>
</FloatingPointModel>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<FunctionLevelLinking>true</FunctionLevelLinking>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
117 changes: 62 additions & 55 deletions KBotExt/LoginTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Json::CharReader> 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<int>(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<Json::CharReader> 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<int>(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);
Expand Down
12 changes: 7 additions & 5 deletions KBotExt/Misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions KBotExt/MiscTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"({
Expand Down
19 changes: 19 additions & 0 deletions KBotExt/ProfileTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:");
Expand Down
3 changes: 3 additions & 0 deletions KBotExt/SettingsTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6d9665e

Please sign in to comment.