Skip to content

Update lib at request of Networking #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 70 additions & 8 deletions x64/auth.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <Windows.h>
#include <iostream>
#include <vector>
#include <fstream>
#include <includes.hpp>
#include <xorstr.hpp>
#include <random>

#define CURL_STATICLIB

struct channel_struct
{
Expand All @@ -14,15 +15,15 @@ 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) {}

void ban(std::string reason = "");
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);
Expand All @@ -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<unsigned char> download(std::string fileid);
void regstr(std::string username, std::string password, std::string key, std::string email = "");
void chatget(std::string channel);
Expand All @@ -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:
Expand Down Expand Up @@ -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;

};
}
Binary file modified x64/library_x64.lib
Binary file not shown.
88 changes: 86 additions & 2 deletions x86/lib/auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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 +
Expand Down Expand Up @@ -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 +
Expand Down Expand Up @@ -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<int> 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<int> 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<int> 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<int> 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();

Expand Down
6 changes: 4 additions & 2 deletions x86/lib/auth.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<unsigned char> download(std::string fileid);
void regstr(std::string username, std::string password, std::string key, std::string email = "");
void chatget(std::string channel);
Expand All @@ -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:
Expand Down
Loading