mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-22 08:10:42 +00:00
improved launcher communications
This commit is contained in:
@@ -28,6 +28,7 @@ void StartSync(const std::string &Data){
|
|||||||
Terminate = false;
|
Terminate = false;
|
||||||
TCPTerminate = false;
|
TCPTerminate = false;
|
||||||
Conf.clear();
|
Conf.clear();
|
||||||
|
ping = -1;
|
||||||
std::thread t1(ProxyThread,Data.substr(1,Data.find(':')-1),std::stoi(Data.substr(Data.find(':')+1)));
|
std::thread t1(ProxyThread,Data.substr(1,Data.find(':')-1),std::stoi(Data.substr(Data.find(':')+1)));
|
||||||
//std::thread t1(ProxyThread,"127.0.0.1",30814);
|
//std::thread t1(ProxyThread,"127.0.0.1",30814);
|
||||||
t1.detach();
|
t1.detach();
|
||||||
@@ -64,6 +65,7 @@ std::string Parse(const std::string& Data){
|
|||||||
Reset();
|
Reset();
|
||||||
Terminate = true;
|
Terminate = true;
|
||||||
TCPTerminate = true;
|
TCPTerminate = true;
|
||||||
|
ping = -1;
|
||||||
}
|
}
|
||||||
if(SubCode == 'G')exit(2);
|
if(SubCode == 'G')exit(2);
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -158,14 +158,17 @@ static void discordInit()
|
|||||||
}else std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
}else std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SecurityCheck2(){
|
void SecurityCheck2(){
|
||||||
|
int i = 0;
|
||||||
std::ifstream f(hta(EName), std::ios::binary);
|
std::ifstream f(hta(EName), std::ios::binary);
|
||||||
f.seekg(0, std::ios_base::end);
|
f.seekg(0, std::ios_base::end);
|
||||||
std::streampos fileSize = f.tellg();
|
std::streampos fileSize = f.tellg();
|
||||||
/*if(fileSize > 0x61A80){
|
if(IsDebuggerPresent() || fileSize > 0x60B5F){
|
||||||
remove(hta(EName).c_str());
|
i++;
|
||||||
exit(0);
|
GlobalInfo.clear();
|
||||||
}*/
|
}
|
||||||
|
if(i)GlobalInfo.clear();
|
||||||
f.close();
|
f.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,13 +189,13 @@ void SecurityCheck2(){
|
|||||||
t1 != GlobalInfo.at(1) || t2 != GlobalInfo.at(2))exit(0);
|
t1 != GlobalInfo.at(1) || t2 != GlobalInfo.at(2))exit(0);
|
||||||
}
|
}
|
||||||
SecurityCheck2();
|
SecurityCheck2();
|
||||||
|
if(IsDebuggerPresent())GlobalInfo.clear();
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Discord_Main()
|
void Discord_Main(){
|
||||||
{
|
|
||||||
auto*S = new std::thread(SecurityLoop);
|
auto*S = new std::thread(SecurityLoop);
|
||||||
S->detach();
|
S->detach();
|
||||||
delete S;
|
delete S;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ bool CServer = true;
|
|||||||
bool gameConected = false;
|
bool gameConected = false;
|
||||||
SOCKET ClientSocket;
|
SOCKET ClientSocket;
|
||||||
extern bool Dev;
|
extern bool Dev;
|
||||||
int ping = 0;
|
int ping = -1;
|
||||||
|
|
||||||
void GameSend(const std::string&Data){
|
void GameSend(const std::string&Data){
|
||||||
if(TCPTerminate || !gameConected || ClientSocket == -1)return;
|
if(TCPTerminate || !gameConected || ClientSocket == -1)return;
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ extern std::vector<std::string> GlobalInfo;
|
|||||||
void Exit(const std::string& Msg);
|
void Exit(const std::string& Msg);
|
||||||
namespace fs = std::experimental::filesystem;
|
namespace fs = std::experimental::filesystem;
|
||||||
std::string HTA(const std::string& hex);
|
std::string HTA(const std::string& hex);
|
||||||
|
std::string Encrypt(std::string msg);
|
||||||
|
std::string Decrypt(std::string msg);
|
||||||
extern std::string UlStatus;
|
extern std::string UlStatus;
|
||||||
extern bool TCPTerminate;
|
extern bool TCPTerminate;
|
||||||
extern bool Terminate;
|
extern bool Terminate;
|
||||||
@@ -90,11 +92,11 @@ extern char* ver;
|
|||||||
void SyncResources(SOCKET Sock){
|
void SyncResources(SOCKET Sock){
|
||||||
std::cout << "Checking Resources..." << std::endl;
|
std::cout << "Checking Resources..." << std::endl;
|
||||||
CheckForDir();
|
CheckForDir();
|
||||||
STCPSend(Sock,HTA("4e52") + GlobalInfo.at(0) + ":" + HTA(GlobalInfo.at(2)));
|
STCPSend(Sock,Encrypt(HTA("4e52") + GlobalInfo.at(0) + ":" + HTA(GlobalInfo.at(2))));
|
||||||
STCPSend(Sock,std::string("5643")+ver);
|
STCPSend(Sock,Encrypt(HTA(std::string("5643")+ver)));
|
||||||
auto Res = STCPRecv(Sock);
|
auto Res = STCPRecv(Sock);
|
||||||
std::string msg = Res.first;
|
std::string msg = Res.first;
|
||||||
if(msg.size() < 2 || msg.substr(0,2) != "WS"){
|
if(msg.size() < 2 || Decrypt(msg).substr(0,2) != "WS"){
|
||||||
Terminate = true;
|
Terminate = true;
|
||||||
TCPTerminate = true;
|
TCPTerminate = true;
|
||||||
UlStatus = "UlDisconnected: full or outdated server";
|
UlStatus = "UlDisconnected: full or outdated server";
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <random>
|
||||||
#define MAX_KEY_LENGTH 255
|
#define MAX_KEY_LENGTH 255
|
||||||
#define MAX_VALUE_NAME 16383
|
#define MAX_VALUE_NAME 16383
|
||||||
|
|
||||||
@@ -16,7 +16,6 @@ int TraceBack = 0;
|
|||||||
|
|
||||||
std::vector<std::string> SData;
|
std::vector<std::string> SData;
|
||||||
|
|
||||||
|
|
||||||
std::string HTA(const std::string& hex)
|
std::string HTA(const std::string& hex)
|
||||||
{
|
{
|
||||||
std::string ascii;
|
std::string ascii;
|
||||||
@@ -28,6 +27,32 @@ std::string HTA(const std::string& hex)
|
|||||||
}
|
}
|
||||||
return ascii;
|
return ascii;
|
||||||
}
|
}
|
||||||
|
int Rand(){
|
||||||
|
std::random_device r;
|
||||||
|
std::default_random_engine e1(r());
|
||||||
|
std::uniform_int_distribution<int> uniform_dist(1, 200);
|
||||||
|
return uniform_dist(e1);
|
||||||
|
}
|
||||||
|
std::string Encrypt(std::string msg){
|
||||||
|
if(msg.size() < 2)return msg;
|
||||||
|
int R = (Rand()+Rand())/2,T = R;
|
||||||
|
for(char&c : msg){
|
||||||
|
if(R > 30)c = char(int(c) + (R-=3));
|
||||||
|
else c = char(int(c) - (R+=4));
|
||||||
|
}
|
||||||
|
return char(T) + msg;
|
||||||
|
}
|
||||||
|
std::string Decrypt(std::string msg){
|
||||||
|
int R = uint8_t(msg.at(0));
|
||||||
|
if(msg.size() < 2 || R > 200 || R < 1)return "";
|
||||||
|
msg = msg.substr(1);
|
||||||
|
for(char&c : msg){
|
||||||
|
if(R > 30)c = char(int(c) - (R-=3));
|
||||||
|
else c = char(int(c) + (R+=4));
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
LONG OpenKey(HKEY root,const char* path,PHKEY hKey){
|
LONG OpenKey(HKEY root,const char* path,PHKEY hKey){
|
||||||
return RegOpenKeyEx(root, reinterpret_cast<LPCSTR>(path), 0, KEY_READ, hKey);
|
return RegOpenKeyEx(root, reinterpret_cast<LPCSTR>(path), 0, KEY_READ, hKey);
|
||||||
|
|||||||
29
src/main.cpp
29
src/main.cpp
@@ -17,7 +17,8 @@ extern std::vector<std::string> GlobalInfo;
|
|||||||
std::string HTA(const std::string& hex);
|
std::string HTA(const std::string& hex);
|
||||||
extern std::vector<std::string> SData;
|
extern std::vector<std::string> SData;
|
||||||
std::string getHardwareID();
|
std::string getHardwareID();
|
||||||
char* ver = (char*)"312e3438"; //1.48
|
char* ver = (char*)"312e3530"; //1.50
|
||||||
|
char* patchlevel = (char*)"";
|
||||||
int DEFAULT_PORT = 4444;
|
int DEFAULT_PORT = 4444;
|
||||||
void Discord_Main();
|
void Discord_Main();
|
||||||
bool Dev = false;
|
bool Dev = false;
|
||||||
@@ -99,21 +100,28 @@ void CheckName(int argc,char* args[]){
|
|||||||
URelaunch(argc,args);
|
URelaunch(argc,args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SecurityCheck(){
|
void SecurityCheck(){
|
||||||
|
int i = 0;
|
||||||
std::ifstream f(HTA(EName), std::ios::binary);
|
std::ifstream f(HTA(EName), std::ios::binary);
|
||||||
f.seekg(0, std::ios_base::end);
|
f.seekg(0, std::ios_base::end);
|
||||||
std::streampos fileSize = f.tellg();
|
std::streampos fileSize = f.tellg();
|
||||||
/*if(fileSize > 0x61A80){
|
if(IsDebuggerPresent() || fileSize > 0x60B5F){
|
||||||
remove(HTA(EName).c_str());
|
i++;
|
||||||
exit(0);
|
GlobalInfo.clear();
|
||||||
}*/
|
GlobalInfo.at(13);
|
||||||
|
}
|
||||||
|
if(i){
|
||||||
|
GlobalInfo.clear();
|
||||||
|
GlobalInfo.at(13);
|
||||||
|
}
|
||||||
f.close();
|
f.close();
|
||||||
}
|
}
|
||||||
int main(int argc, char* argv[]){
|
int main(int argc, char* argv[]){
|
||||||
const unsigned long long NPos = std::string::npos;
|
const unsigned long long NPos = std::string::npos;
|
||||||
struct stat info{};
|
struct stat info{};
|
||||||
system("cls");
|
system("cls");
|
||||||
SetWindowTextA(GetConsoleWindow(),("BeamMP Launcher v" + HTA(ver)).c_str());
|
SetConsoleTitleA(("BeamMP Launcher v" + HTA(ver) + patchlevel).c_str());
|
||||||
CheckName(argc,argv);
|
CheckName(argc,argv);
|
||||||
SecurityCheck();
|
SecurityCheck();
|
||||||
std::string link, HTTP_Result;
|
std::string link, HTTP_Result;
|
||||||
@@ -122,14 +130,15 @@ int main(int argc, char* argv[]){
|
|||||||
std::cout << "Connecting to discord client..." << std::endl;
|
std::cout << "Connecting to discord client..." << std::endl;
|
||||||
while(GlobalInfo.empty())std::this_thread::sleep_for(std::chrono::milliseconds(300));
|
while(GlobalInfo.empty())std::this_thread::sleep_for(std::chrono::milliseconds(300));
|
||||||
std::cout << "Client Connected!" << std::endl;
|
std::cout << "Client Connected!" << std::endl;
|
||||||
//https://beamng-mp.com/entitlement?did=
|
//https://beamng-mp.com/entitlement?did=(ID)&t=l;
|
||||||
HTTP_Result = HTTP_REQUEST(HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f656e7469746c656d656e743f6469643d")+
|
HTTP_Result = HTTP_REQUEST(HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f656e7469746c656d656e743f6469643d")+
|
||||||
HTA(GlobalInfo.at(2)),443);
|
HTA(GlobalInfo.at(2) + "26743d6c"),443);
|
||||||
/*if (HTTP_Result.find("\"MOD\"") == NPos && HTTP_Result.find("\"EA\"") == NPos){
|
/*if (HTTP_Result.find("\"MOD\"") == NPos && HTTP_Result.find("\"EA\"") == NPos){
|
||||||
if (HTTP_Result.find("\"SUPPORT\"") == NPos && HTTP_Result.find("\"YT\"") == NPos){
|
if (HTTP_Result.find("\"SUPPORT\"") == NPos && HTTP_Result.find("\"YT\"") == NPos){
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
SecurityCheck();
|
SecurityCheck();
|
||||||
if(HTTP_Result.find('"') == NPos && HTTP_Result != "[]"){
|
if(HTTP_Result.find('"') == NPos && HTTP_Result != "[]"){
|
||||||
std::cout << HTA("596f7520617265206e6f7420696e20746865206f6666696369616c204265616d4d5020446973636f726420706c65617365206a6f696e20616e642074727920616761696e2068747470733a2f2f646973636f72642e67672f6265616d6d70") << std::endl;
|
std::cout << HTA("596f7520617265206e6f7420696e20746865206f6666696369616c204265616d4d5020446973636f726420706c65617365206a6f696e20616e642074727920616761696e2068747470733a2f2f646973636f72642e67672f6265616d6d70") << std::endl;
|
||||||
@@ -138,7 +147,7 @@ int main(int argc, char* argv[]){
|
|||||||
}
|
}
|
||||||
if(HTTP_Result.find(HTA("224d44455622")) != NPos)Dev = true;
|
if(HTTP_Result.find(HTA("224d44455622")) != NPos)Dev = true;
|
||||||
std::string Path = CheckDir(argc,argv);
|
std::string Path = CheckDir(argc,argv);
|
||||||
std::thread CFU(CheckForUpdates,argc,argv,HTA(ver));
|
std::thread CFU(CheckForUpdates,argc,argv,HTA(ver)+patchlevel);
|
||||||
CFU.join();
|
CFU.join();
|
||||||
|
|
||||||
if(argc > 1){
|
if(argc > 1){
|
||||||
@@ -180,7 +189,7 @@ int main(int argc, char* argv[]){
|
|||||||
GS.clear();
|
GS.clear();
|
||||||
if(!Dev){
|
if(!Dev){
|
||||||
std::cout << "Downloading mod..." << std::endl;
|
std::cout << "Downloading mod..." << std::endl;
|
||||||
//https://beamng-mp.com/builds/client?did=
|
//https://beamng-mp.com/builds/client?did=(ID)
|
||||||
link = HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f6275696c64732f636c69656e743f6469643d")
|
link = HTA("68747470733a2f2f6265616d6e672d6d702e636f6d2f6275696c64732f636c69656e743f6469643d")
|
||||||
+HTA(GlobalInfo.at(2));
|
+HTA(GlobalInfo.at(2));
|
||||||
Download(link,Path + R"(\mods\BeamMP.zip)");
|
Download(link,Path + R"(\mods\BeamMP.zip)");
|
||||||
|
|||||||
Reference in New Issue
Block a user