-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
289 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <algorithm> | ||
#include <thread> | ||
#include <cstddef> | ||
#include <fstream> | ||
#include <curl/curl.h> | ||
#include <sstream> | ||
#include <vector> | ||
#include <chrono> | ||
#include <sqlite3.h> | ||
|
||
#include "base64.cpp" | ||
#include "leaguefiles.cpp" | ||
#include "curling.cpp" | ||
|
||
int main() { | ||
system("pkexec sh -c 'sysctl -w abi.vsyscall32=0' > /dev/null"); | ||
std::cout << "STARTED LEAGUEAUTOACCEPT" << std::endl; | ||
// std::cout << std::unitbuf; | ||
while (true) { | ||
std::ifstream lockfile = getfile(); | ||
std::vector<std::string> data(getdata(lockfile)); | ||
std::cout << "Port number: " << data[0] << '\n' << "Auth: " << Base64::Encode(data[1]) << std::endl; | ||
curlstuff(data[0], Base64::Encode(data[1])); //data[0]=portnum,data[1]=password | ||
std::this_thread::sleep_for(std::chrono::seconds(2)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
//Taken from https://gist.github.com/tomykaira/f0fd86b6c73063283afe550bc5d77594 | ||
#ifndef _MACARON_BASE64_H_ | ||
#define _MACARON_BASE64_H_ | ||
|
||
/** | ||
* The MIT License (MIT) | ||
* Copyright (c) 2016 tomykaira | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#include <string> | ||
|
||
class Base64 { | ||
public: | ||
|
||
static std::string Encode(const std::string data) { | ||
static constexpr char sEncodingTable[] = { | ||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', | ||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', | ||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', | ||
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', | ||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', | ||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', | ||
'w', 'x', 'y', 'z', '0', '1', '2', '3', | ||
'4', '5', '6', '7', '8', '9', '+', '/' | ||
}; | ||
|
||
size_t in_len = data.size(); | ||
size_t out_len = 4 * ((in_len + 2) / 3); | ||
std::string ret(out_len, '\0'); | ||
size_t i; | ||
char *p = const_cast<char*>(ret.c_str()); | ||
|
||
for (i = 0; i < in_len - 2; i += 3) { | ||
*p++ = sEncodingTable[(data[i] >> 2) & 0x3F]; | ||
*p++ = sEncodingTable[((data[i] & 0x3) << 4) | ((int) (data[i + 1] & 0xF0) >> 4)]; | ||
*p++ = sEncodingTable[((data[i + 1] & 0xF) << 2) | ((int) (data[i + 2] & 0xC0) >> 6)]; | ||
*p++ = sEncodingTable[data[i + 2] & 0x3F]; | ||
} | ||
if (i < in_len) { | ||
*p++ = sEncodingTable[(data[i] >> 2) & 0x3F]; | ||
if (i == (in_len - 1)) { | ||
*p++ = sEncodingTable[((data[i] & 0x3) << 4)]; | ||
*p++ = '='; | ||
} | ||
else { | ||
*p++ = sEncodingTable[((data[i] & 0x3) << 4) | ((int) (data[i + 1] & 0xF0) >> 4)]; | ||
*p++ = sEncodingTable[((data[i + 1] & 0xF) << 2)]; | ||
} | ||
*p++ = '='; | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
static std::string Decode(const std::string& input, std::string& out) { | ||
static constexpr unsigned char kDecodingTable[] = { | ||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | ||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | ||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, | ||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, | ||
64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, | ||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, | ||
64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, | ||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, | ||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | ||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | ||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | ||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | ||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | ||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | ||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | ||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 | ||
}; | ||
|
||
size_t in_len = input.size(); | ||
if (in_len % 4 != 0) return "Input data size is not a multiple of 4"; | ||
|
||
size_t out_len = in_len / 4 * 3; | ||
if (input[in_len - 1] == '=') out_len--; | ||
if (input[in_len - 2] == '=') out_len--; | ||
|
||
out.resize(out_len); | ||
|
||
for (size_t i = 0, j = 0; i < in_len;) { | ||
uint32_t a = input[i] == '=' ? 0 & i++ : kDecodingTable[static_cast<int>(input[i++])]; | ||
uint32_t b = input[i] == '=' ? 0 & i++ : kDecodingTable[static_cast<int>(input[i++])]; | ||
uint32_t c = input[i] == '=' ? 0 & i++ : kDecodingTable[static_cast<int>(input[i++])]; | ||
uint32_t d = input[i] == '=' ? 0 & i++ : kDecodingTable[static_cast<int>(input[i++])]; | ||
|
||
uint32_t triple = (a << 3 * 6) + (b << 2 * 6) + (c << 1 * 6) + (d << 0 * 6); | ||
|
||
if (j < out_len) out[j++] = (triple >> 2 * 8) & 0xFF; | ||
if (j < out_len) out[j++] = (triple >> 1 * 8) & 0xFF; | ||
if (j < out_len) out[j++] = (triple >> 0 * 8) & 0xFF; | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
}; | ||
|
||
|
||
#endif /* _MACARON_BASE64_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef curling | ||
#define curling | ||
|
||
#include <curl/curl.h> | ||
#include <iostream> | ||
#include <sstream> | ||
|
||
size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata) { | ||
for (int i(0); i != nmemb; ++i) { | ||
std::cout << ptr[i]; | ||
} | ||
return 0; | ||
} | ||
void curlstuff(const std::string& port, const std::string& pass) { | ||
CURLcode ret; | ||
CURL* curl; | ||
struct curl_slist *slist1; | ||
slist1 = NULL; | ||
slist1 = curl_slist_append(slist1, (static_cast<std::string>("Authorization: Basic ") + pass).c_str()); | ||
curl = curl_easy_init(); | ||
std::stringstream urlstring; | ||
urlstring << "https://127.0.0.1:" << port << "/lol-matchmaking/v1/ready-check/accept"; | ||
// std::cout << urlstring.str() << std::endl; | ||
curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 102400L); | ||
// curl_easy_setopt(curl, CURLOPT_URL, "https://127.0.0.1:39961/lol-matchmaking/v1/ready-check/accept"); | ||
curl_easy_setopt(curl, CURLOPT_URL, urlstring.str().c_str()); | ||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L); | ||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1); | ||
curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl/7.83.1"); | ||
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L); | ||
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_2TLS); | ||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); | ||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); | ||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); | ||
curl_easy_setopt(curl, CURLOPT_FTP_SKIP_PASV_IP, 1L); | ||
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); | ||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); | ||
ret = curl_easy_perform(curl); | ||
curl_easy_cleanup(curl); | ||
curl=NULL; | ||
curl_slist_free_all(slist1); | ||
slist1=NULL; | ||
std::cout << '\n' << std::endl; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#ifndef leaguefiles | ||
#define leaguefiles | ||
#include <sqlite3.h> | ||
#include <iostream> | ||
#include <fstream> | ||
#include <vector> | ||
|
||
struct leagueDBfind { | ||
std::string installlocation, XDG_DATA_HOME, databaselocation, lockfile="0"; | ||
sqlite3 *database; | ||
|
||
leagueDBfind() { // constructor tries to find the location of the lutris database with the XDG_DATA_HOME environmental variable. If it doesn't, it gets set to ~/.local/share/lutris/pga.db | ||
XDG_DATA_HOME = std::getenv("XDG_DATA_HOME"); | ||
databaselocation = XDG_DATA_HOME.empty() ? "" : XDG_DATA_HOME+"/lutris/pga.db"; | ||
if (XDG_DATA_HOME.empty()) { | ||
std::cout << "Environmental var: XDG_DATA_HOME doesn't exist. defaulting to ~/.local/share\n"; | ||
XDG_DATA_HOME=static_cast<std::string>(std::getenv("HOME"))+"/.local/share"; | ||
databaselocation = XDG_DATA_HOME + "/lutris/pga.db"; | ||
} | ||
//std::cout << "Using databaselocation: " << databaselocation << std::endl;; | ||
} | ||
int open() { //give sqlite3 object the location of the lutris database | ||
return sqlite3_open(databaselocation.c_str(), &database); | ||
} | ||
static int callback(void *currentDB, int a, char **res, char **azColName) { //gets called by getinstalllocation. | ||
//std::cout << *res << std::endl; | ||
static_cast<leagueDBfind *>(currentDB)->installlocation = *res; | ||
static_cast<leagueDBfind *>(currentDB)->lockfile = static_cast<leagueDBfind *>(currentDB)->installlocation+"/drive_c/Riot Games/League of Legends/lockfile"; | ||
return 0; | ||
} | ||
int getinstalllocation() { // run sql command to find the location league of legends lockfile | ||
return sqlite3_exec(database, "SELECT \"directory\" FROM \"main\".\"games\" WHERE \"slug\" LIKE 'league-of-legends'", callback, this, NULL); | ||
} | ||
|
||
}; | ||
|
||
std::ifstream getfile() { //Get credentials from lockfile | ||
#ifdef _WIN32 // i haven't tried this program with windows at all. I wanted to but I don't know how to cross compile for windows | ||
std::ifstream lockfile("C:\\Riot Games\\League of Legends\\lockfile"); | ||
#else | ||
static leagueDBfind database; | ||
if (database.lockfile != "0") { //if the lockfile is already set to something, then it doesn't need to be found again not sure what's a better way of doing this | ||
// std::cout << database.lockfile << '\n'; | ||
return std::ifstream(database.lockfile); | ||
} | ||
int code = database.open(); | ||
if (code) { //if the database wasn't opened properly | ||
std::cerr << "couldn't open database to find league of legends install location"; | ||
} | ||
code = database.getinstalllocation(); | ||
std::ifstream lockfile(database.lockfile); | ||
std::cout << "lockfile location: " << database.lockfile << std::endl; | ||
#endif | ||
if (!lockfile.is_open()) { // if it didn't get anything, something went wrong | ||
std::cout << "League isn't open yet or something else went wrong" << std::endl; | ||
// MessageBox(NULL,"League isn't open yet?", "Error!", MB_OK); winblows? | ||
exit(1); | ||
} | ||
return lockfile; | ||
} | ||
|
||
|
||
std::vector<std::string> getdata(std::ifstream &lockfile) { | ||
std::vector<std::string> svec; | ||
std::string portnum(""); | ||
std::string pass("riot:"); | ||
char ch; | ||
for (int coloncount = 0; !lockfile.eof();) { | ||
if (lockfile >> ch && ch == ':') { | ||
++coloncount; | ||
} else switch (coloncount) { | ||
case 2: | ||
portnum += ch; | ||
break; | ||
case 3: | ||
pass += ch; | ||
break; | ||
} | ||
} | ||
svec.push_back(std::string(portnum)); | ||
svec.push_back(std::string(pass)); | ||
return svec; | ||
} | ||
|
||
/*int main() { | ||
leagueDBfind database; | ||
int code = database.open(); | ||
if (code) { | ||
std::cerr << "couldn't open database to find league of legends install location"; | ||
return 1; | ||
} | ||
code = database.getinstalllocation(); | ||
}*/ | ||
#endif |