-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
auth.hpp
150 lines (126 loc) · 4.78 KB
/
auth.hpp
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
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include <includes.hpp>
#include <xorstr.hpp>
#include <random>
#define CURL_STATICLIB
struct channel_struct
{
std::string author;
std::string message;
std::string timestamp;
};
namespace KeyAuth {
class api {
public:
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);
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);
std::string getvar(std::string var);
bool checkblack();
void web_login();
void button(std::string value);
void upgrade(std::string username, std::string key);
void login(std::string username, std::string password);
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);
bool chatsend(std::string message, std::string channel);
void changeUsername(std::string newusername);
std::string fetchonline();
void fetchstats();
void forgot(std::string username, std::string email);
void logout();
class subscriptions_class {
public:
std::string name;
std::string expiry;
};
class userdata {
public:
// user data
std::string username;
std::string ip;
std::string hwid;
std::string createdate;
std::string lastlogin;
std::vector<subscriptions_class> 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<channel_struct> channeldata;
bool success{};
std::string message;
bool isPaid{};
};
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;
};
}