-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
74 lines (57 loc) · 2.23 KB
/
main.cpp
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
#include <4dm.h>
#include <openssl/evp.h>
using namespace fdm;
void updateGame( StateMultiplayer* mp, std::string uuidstr, std::string uuidlbl, std::string uuid_hidden ) {
mp->uuidInput.text = uuidstr; // apply uuid to game logic
mp->uuidLabel.text = uuidlbl;
mp->uuidInput.passwordVisualText = uuid_hidden;
}
void updateUUID() {
StateMultiplayer* mp = StateMultiplayer::instanceObj;
static std::string trueUUID = mp->uuidInput.text;
static std::string oldAddress = "ä";
static std::string uuidstr = "";
static std::string uuidlbl = "";
static std::string uuid_hidden = "";
if (oldAddress == mp->serverAddressInput.text)
return updateGame(mp,uuidstr,uuidlbl,uuid_hidden);
oldAddress = mp->serverAddressInput.text;
unsigned char hashBytes[EVP_MAX_MD_SIZE];
EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
EVP_DigestInit(mdctx, EVP_sha256()); // set hashing function to sha256
EVP_DigestUpdate(mdctx, trueUUID.c_str(), trueUUID.length()); // add uuid to hash
EVP_DigestUpdate(mdctx, mp->serverAddressInput.text.c_str(), mp->serverAddressInput.text.length()); // add server address to hash
EVP_DigestFinal(mdctx, hashBytes, NULL);
EVP_MD_CTX_free(mdctx);
std::stringstream rawuuid;
for (int i = 0; i < 0x10; i++)
rawuuid << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(hashBytes[i]);
uuid uuid = uuid(rawuuid.str());
uuidstr = uuid.to_string(uuid); // add in dashes
uuidlbl = "Obfuscated UUID:";
int teaseLength = 8;
if (mp->serverAddressInput.text == "") {
uuidstr = trueUUID;
uuidlbl = "!!! UNobfuscated UUID: !!!";
teaseLength = 4;
}
uuid_hidden = uuidstr;
std::replace_if(uuid_hidden.begin() + teaseLength, uuid_hidden.end(), [](char c) {return c != '-';}, '*');
return updateGame(mp,uuidstr,uuidlbl,uuid_hidden);
}
$hook(void, StateMultiplayer, joinButtonCallback) {
original(self);
updateUUID();
}
$hook(void, StateMultiplayer, keyInput, StateManager& s, int key, int scancode, int action, int mods ) {
original(self,s,key,scancode,action,mods);
updateUUID();
}
$hook(void, StateMultiplayer, init, StateManager& s, uint32_t codepoint) {
original(self,s,codepoint);
updateUUID();
}
$hook(void, StateMultiplayer, update, StateManager& s, double dt) {
original(self,s,dt);
updateUUID();
}