lots of work

This commit is contained in:
Anonymous275
2020-05-26 19:13:02 +03:00
parent 6a3ecfc307
commit 4a3235f445
7 changed files with 32 additions and 28 deletions

View File

@@ -11,7 +11,7 @@
extern int DEFAULT_PORT; extern int DEFAULT_PORT;
std::string HTTP_REQUEST(const std::string&url,int port); std::string HTTP_REQUEST(const std::string&url,int port);
void SyncResources(const std::string& IP, int port); void ProxyThread(const std::string& IP, int port);
void Exit(const std::string& Msg); void Exit(const std::string& Msg);
extern std::string UlStatus; extern std::string UlStatus;
extern std::string MStatus; extern std::string MStatus;
@@ -21,8 +21,8 @@ extern bool TCPTerminate;
extern bool MPDEV; extern bool MPDEV;
void StartSync(const std::string &Data){ void StartSync(const std::string &Data){
//std::thread t1(SyncResources,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(SyncResources,"127.0.0.1",30814); //std::thread t1(ProxyThread,"127.0.0.1",30814);
t1.detach(); t1.detach();
} }

View File

@@ -46,7 +46,7 @@ void ServerSend(const std::string&Data, bool Rel){
if (C == 'O' || C == 'T')Rel = true; if (C == 'O' || C == 'T')Rel = true;
if(Rel){ if(Rel){
if(Data.length() > 1000)TCPSendLarge(Data); if(Data.length() > 1000 || Data.substr(0,2) == "Od")TCPSendLarge(Data);
else TCPSend(Data); else TCPSend(Data);
} }
else UDPSend(Data); else UDPSend(Data);

View File

@@ -59,6 +59,7 @@ void TCPRcv(){
} }
void SyncResources(SOCKET TCPSock);
void TCPClientMain(const std::string& IP,int Port){ void TCPClientMain(const std::string& IP,int Port){
WSADATA wsaData; WSADATA wsaData;
SOCKADDR_IN ServerAddr; SOCKADDR_IN ServerAddr;
@@ -87,6 +88,7 @@ void TCPClientMain(const std::string& IP,int Port){
} }
getsockname(TCPSock, (SOCKADDR *)&ServerAddr, (int *)sizeof(ServerAddr)); getsockname(TCPSock, (SOCKADDR *)&ServerAddr, (int *)sizeof(ServerAddr));
SyncResources(TCPSock);
while(!Terminate){ while(!Terminate){
TCPRcv(); TCPRcv();
} }

View File

@@ -44,9 +44,9 @@ std::string STCPRecv(SOCKET socket){
return std::string(buf); return std::string(buf);
} }
void ProxyThread(const std::string& IP, int port); extern bool Terminate;
void SyncResources(const std::string&IP,int Port){ void SyncResources(SOCKET TCPSock){
if(MPDEV)std::cout << "Called" << std::endl; if(MPDEV)std::cout << "SyncResources Called" << std::endl;
std::string FileList; std::string FileList;
struct stat info{}; struct stat info{};
if(stat( "Resources", &info) != 0){ if(stat( "Resources", &info) != 0){
@@ -156,6 +156,4 @@ void SyncResources(const std::string&IP,int Port){
if(WSACleanup() != 0) if(WSACleanup() != 0)
if(MPDEV)printf("Client: WSACleanup() failed!...\n"); if(MPDEV)printf("Client: WSACleanup() failed!...\n");
*/ */
ProxyThread(IP,Port);
} }

View File

@@ -57,7 +57,7 @@ std::string QueryKey(HKEY hKey,int ID)
hKey, // key handle hKey, // key handle
achClass, // buffer for class name achClass, // buffer for class name
&cchClassName, // size of class string &cchClassName, // size of class string
NULL, // reserved nullptr, // reserved
&cSubKeys, // number of subkeys &cSubKeys, // number of subkeys
&cbMaxSubKey, // longest subkey size &cbMaxSubKey, // longest subkey size
&cchMaxClass, // longest class string &cchMaxClass, // longest class string
@@ -79,9 +79,9 @@ std::string QueryKey(HKEY hKey,int ID)
retCode = RegEnumKeyEx(hKey, i, retCode = RegEnumKeyEx(hKey, i,
achKey, achKey,
&cbName, &cbName,
NULL, nullptr,
NULL, nullptr,
NULL, nullptr,
&ftLastWriteTime); &ftLastWriteTime);
if (retCode == ERROR_SUCCESS) if (retCode == ERROR_SUCCESS)
{ {
@@ -100,22 +100,22 @@ std::string QueryKey(HKEY hKey,int ID)
retCode = RegEnumValue(hKey, i, retCode = RegEnumValue(hKey, i,
achValue, achValue,
&cchValue, &cchValue,
NULL, nullptr,
NULL, nullptr,
NULL, nullptr,
NULL); nullptr);
if (retCode == ERROR_SUCCESS ) if (retCode == ERROR_SUCCESS )
{ {
DWORD lpData = cbMaxValueData; DWORD lpData = cbMaxValueData;
buffer[0] = '\0'; buffer[0] = '\0';
LONG dwRes = RegQueryValueEx(hKey, achValue, 0, NULL, buffer, &lpData); LONG dwRes = RegQueryValueEx(hKey, achValue, nullptr, nullptr, buffer, &lpData);
std::string data = reinterpret_cast<const char *const>(buffer); std::string data = reinterpret_cast<const char *const>(buffer);
std::string key = achValue; std::string key = achValue;
switch (ID){ switch (ID){
case 1: if(data.find(HTA("737465616d")) != std::string::npos)return data; break; case 1: if(key == HTA("537465616d50617468") && data.find(HTA("737465616d")) != std::string::npos)return data;break;
case 2: if(key == HTA("4e616d65") && data == HTA("4265616d4e472e6472697665"))return data; break; case 2: if(key == HTA("4e616d65") && data == HTA("4265616d4e472e6472697665"))return data; break;
case 3: return data.substr(0,data.length()-2); break; case 3: return data.substr(0,data.length()-2);
case 4: if(key == HTA("75736572706174685f6f76657272696465"))return data; case 4: if(key == HTA("75736572706174685f6f76657272696465"))return data;
default: break; default: break;
} }
@@ -149,11 +149,11 @@ void ExitError(){
} }
void Check(){ void Check(){
/*HKEY_CLASSES_ROOT\\beamng\\DefaultIcon /*.HKEY_CURRENT_USER\Software\Valve\Steam
HKEY_USERS\.DEFAULT\Software\Classes\steam\Shell\Open\Command HKEY_CURRENT_USER\\Software\Valve\Steam\Apps\284160
HKEY_CURRENT_USER\\Software\Valve\Steam\Apps\284160*/ HKEY_CLASSES_ROOT\\beamng\\DefaultIcon */
//Sandbox Scramble technique //Sandbox Scramble technique
std::string K1 = HTA("2e44454641554c545c536f6674776172655c436c61737365735c737465616d5c5368656c6c5c4f70656e5c436f6d6d616e64"); std::string K1 = HTA("536f6674776172655c56616c76655c537465616d");
std::string K2 = HTA("536f6674776172655c56616c76655c537465616d5c417070735c323834313630"); std::string K2 = HTA("536f6674776172655c56616c76655c537465616d5c417070735c323834313630");
std::string K3 = HTA("6265616d6e675c44656661756c7449636f6e"); std::string K3 = HTA("6265616d6e675c44656661756c7449636f6e");
std::string MSG1 = HTA("4572726f722120796f7520646f206e6f74206f776e204265616d4e4721"); //Error! you do not own BeamNG! std::string MSG1 = HTA("4572726f722120796f7520646f206e6f74206f776e204265616d4e4721"); //Error! you do not own BeamNG!
@@ -163,12 +163,12 @@ void Check(){
//not used : Warning! you own the game but a cracked game was found on your machine! //not used : Warning! you own the game but a cracked game was found on your machine!
HKEY hKey; HKEY hKey;
LONG dwRegOPenKey = OpenKey(HKEY_USERS, K1.c_str(), &hKey); LONG dwRegOPenKey = OpenKey(HKEY_CURRENT_USER, K1.c_str(), &hKey);
if(dwRegOPenKey == ERROR_SUCCESS) { if(dwRegOPenKey == ERROR_SUCCESS) {
Result = QueryKey(hKey, 1); Result = QueryKey(hKey, 1);
if(Result.empty()){Exit(MSG1 + " Code 1");} if(Result.empty()){Exit(MSG1 + " Code 1");}
SData.push_back(Result); SData.push_back(Result);
Result = Result.substr(1,Result.find_last_of('\\')) + HTA("7573657264617461"); Result += HTA("2f7573657264617461");
struct stat buffer{}; struct stat buffer{};
if(stat (Result.c_str(), &buffer) == 0){ if(stat (Result.c_str(), &buffer) == 0){
auto *F = new std::thread(Find,HTA("3238343136302e6a736f6e"),Result); auto *F = new std::thread(Find,HTA("3238343136302e6a736f6e"),Result);
@@ -198,7 +198,7 @@ void Check(){
} }
SData.push_back(Result); SData.push_back(Result);
TraceBack++; TraceBack++;
} }else{Exit(MSG2+ ". Code : 5");}
//Memory Cleaning //Memory Cleaning
K3.clear(); K3.clear();
//MSG.clear(); //MSG.clear();

View File

@@ -9,12 +9,16 @@ std::string HTTP_REQUEST(const std::string&url,int port);
std::string HTA(const std::string& hex); std::string HTA(const std::string& hex);
void SystemExec(const std::string& cmd); void SystemExec(const std::string& cmd);
void WinExec(const std::string& cmd); void WinExec(const std::string& cmd);
void Exit(const std::string& Msg);
void CheckForUpdates(const std::string& CV){ void CheckForUpdates(const std::string& CV){
system ("cls"); system ("cls");
std::string link = "https://beamng-mp.com/builds/launcher?version=true"; std::string link = "https://beamng-mp.com/builds/launcher?version=true";
std::string HTTP = HTTP_REQUEST(link,443); std::string HTTP = HTTP_REQUEST(link,443);
link = "https://beamng-mp.com/builds/launcher?download=true"; link = "https://beamng-mp.com/builds/launcher?download=true";
if(HTTP.find_first_of("0123456789") == std::string::npos){
Exit("Primary Servers Offline! sorry for the inconvenience!");
}
struct stat buffer{}; struct stat buffer{};
if(stat ("BeamMP-Launcher.back", &buffer) == 0)remove("BeamMP-Launcher.back"); if(stat ("BeamMP-Launcher.back", &buffer) == 0)remove("BeamMP-Launcher.back");
if(HTTP > CV){ if(HTTP > CV){

View File

@@ -87,7 +87,7 @@ 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{};
std::string ver = "1.1", link, Path = CheckDir(argv[0],ver),HTTP_Result; std::string ver = "1.22", link, Path = CheckDir(argv[0],ver),HTTP_Result;
std::thread CFU(CheckForUpdates,ver); std::thread CFU(CheckForUpdates,ver);
CFU.join(); CFU.join();
if(argc > 1){ if(argc > 1){