mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-04 00:47:23 +00:00
cleanup
This commit is contained in:
parent
97cc5a3179
commit
a09e5829f3
@ -7,5 +7,6 @@ void PreGame(int argc, char* argv[],const std::string& GamePath);
|
|||||||
void InitGame(const std::string& Dir,const std::string&Current);
|
void InitGame(const std::string& Dir,const std::string&Current);
|
||||||
std::string CheckVer(const std::string &path);
|
std::string CheckVer(const std::string &path);
|
||||||
void SecurityCheck(char* argv[]);
|
void SecurityCheck(char* argv[]);
|
||||||
|
void FindDLL(char* args[]);
|
||||||
std::string GetGameDir();
|
std::string GetGameDir();
|
||||||
void LegitimacyCheck();
|
void LegitimacyCheck();
|
@ -2,6 +2,7 @@
|
|||||||
/// Created by Anonymous275 on 7/20/2020
|
/// Created by Anonymous275 on 7/20/2020
|
||||||
///
|
///
|
||||||
#include "Network/network.h"
|
#include "Network/network.h"
|
||||||
|
#include "Security/Init.h"
|
||||||
#include "Security/Enc.h"
|
#include "Security/Enc.h"
|
||||||
#include "Curl/http.h"
|
#include "Curl/http.h"
|
||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
@ -9,9 +10,9 @@
|
|||||||
#include "Startup.h"
|
#include "Startup.h"
|
||||||
#include "Memory.h"
|
#include "Memory.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
#include <charconv>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <charconv>
|
|
||||||
|
|
||||||
extern int TraceBack;
|
extern int TraceBack;
|
||||||
std::set<std::string>* ConfList = nullptr;
|
std::set<std::string>* ConfList = nullptr;
|
||||||
@ -25,6 +26,7 @@ bool ModLoaded;
|
|||||||
long long ping = -1;
|
long long ping = -1;
|
||||||
|
|
||||||
void StartSync(const std::string &Data){
|
void StartSync(const std::string &Data){
|
||||||
|
FindDLL(nullptr);
|
||||||
std::string IP = GetAddr(Data.substr(1,Data.find(':')-1));
|
std::string IP = GetAddr(Data.substr(1,Data.find(':')-1));
|
||||||
if(IP.find('.') == -1){
|
if(IP.find('.') == -1){
|
||||||
if(IP == "DNS")UlStatus = Sec("UlConnection Failed! (DNS Lookup Failed)");
|
if(IP == "DNS")UlStatus = Sec("UlConnection Failed! (DNS Lookup Failed)");
|
||||||
|
@ -5,18 +5,19 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
#include "Security/Enc.h"
|
||||||
std::string GetAddr(const std::string&IP){
|
std::string GetAddr(const std::string&IP){
|
||||||
if(IP.find_first_not_of("0123456789.") == -1)return IP;
|
if(IP.find_first_not_of("0123456789.") == -1)return IP;
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
hostent *host;
|
hostent *host;
|
||||||
if(WSAStartup(514, &wsaData) != 0){
|
if(WSAStartup(514, &wsaData) != 0){
|
||||||
error("WSA Startup Failed!");
|
error(Sec("WSA Startup Failed!"));
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
host = gethostbyname(IP.c_str());
|
host = gethostbyname(IP.c_str());
|
||||||
if(!host){
|
if(!host){
|
||||||
error("DNS lookup failed! on " + IP);
|
error(Sec("DNS lookup failed! on ") + IP);
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
return "DNS";
|
return "DNS";
|
||||||
}
|
}
|
||||||
|
@ -96,17 +96,17 @@ void NetReset(){
|
|||||||
UlStatus = Sec("Ulstart");
|
UlStatus = Sec("Ulstart");
|
||||||
MStatus = " ";
|
MStatus = " ";
|
||||||
if(UDPSock != (SOCKET)(-1)){
|
if(UDPSock != (SOCKET)(-1)){
|
||||||
debug("Terminating UDP Socket : " + std::to_string(TCPSock));
|
debug(Sec("Terminating UDP Socket : ") + std::to_string(TCPSock));
|
||||||
KillSocket(UDPSock);
|
KillSocket(UDPSock);
|
||||||
}
|
}
|
||||||
UDPSock = -1;
|
UDPSock = -1;
|
||||||
if(TCPSock != (SOCKET)(-1)){
|
if(TCPSock != (SOCKET)(-1)){
|
||||||
debug("Terminating TCP Socket : " + std::to_string(TCPSock));
|
debug(Sec("Terminating TCP Socket : ") + std::to_string(TCPSock));
|
||||||
KillSocket(TCPSock);
|
KillSocket(TCPSock);
|
||||||
}
|
}
|
||||||
TCPSock = -1;
|
TCPSock = -1;
|
||||||
if(GSocket != (SOCKET)(-1)){
|
if(GSocket != (SOCKET)(-1)){
|
||||||
debug("Terminating GTCP Socket : " + std::to_string(GSocket));
|
debug(Sec("Terminating GTCP Socket : ") + std::to_string(GSocket));
|
||||||
KillSocket(GSocket);
|
KillSocket(GSocket);
|
||||||
}
|
}
|
||||||
GSocket = -1;
|
GSocket = -1;
|
||||||
@ -202,7 +202,7 @@ void NetMain(const std::string& IP, int Port){
|
|||||||
void TCPGameServer(const std::string& IP, int Port){
|
void TCPGameServer(const std::string& IP, int Port){
|
||||||
GSocket = SetupListener();
|
GSocket = SetupListener();
|
||||||
while (!TCPTerminate && GSocket != -1){
|
while (!TCPTerminate && GSocket != -1){
|
||||||
debug("MAIN LOOP OF GAME SERVER");
|
debug(Sec("MAIN LOOP OF GAME SERVER"));
|
||||||
GConnected = false;
|
GConnected = false;
|
||||||
if(!CServer){
|
if(!CServer){
|
||||||
warn(Sec("Connection still alive terminating"));
|
warn(Sec("Connection still alive terminating"));
|
||||||
@ -262,5 +262,5 @@ void TCPGameServer(const std::string& IP, int Port){
|
|||||||
GConnected = false;
|
GConnected = false;
|
||||||
Terminate = true;
|
Terminate = true;
|
||||||
if(CSocket != SOCKET_ERROR)KillSocket(CSocket);
|
if(CSocket != SOCKET_ERROR)KillSocket(CSocket);
|
||||||
debug("END OF GAME SERVER");
|
debug(Sec("END OF GAME SERVER"));
|
||||||
}
|
}
|
55
src/Security/DLL.cpp
Normal file
55
src/Security/DLL.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
///
|
||||||
|
/// Created by Anonymous275 on 11/13/2020
|
||||||
|
///
|
||||||
|
#include "Network/network.h"
|
||||||
|
#include "Security/Enc.h"
|
||||||
|
#include <windows.h>
|
||||||
|
#include "Logger.h"
|
||||||
|
#include <psapi.h>
|
||||||
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
|
||||||
|
DWORD getParentPID(DWORD pid);
|
||||||
|
HANDLE getProcess(DWORD pid, LPSTR fname, DWORD sz);
|
||||||
|
|
||||||
|
void Kill(){
|
||||||
|
static bool Run = false;
|
||||||
|
if(!Run)Run = true;
|
||||||
|
else return;
|
||||||
|
while(Run){
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||||
|
NetReset();
|
||||||
|
#ifdef DEBUG
|
||||||
|
debug(Sec("Attention! NetReset Check!"));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FindDLL(char* args[]){
|
||||||
|
static auto argv = args;
|
||||||
|
HANDLE hProcess = GetCurrentProcess();
|
||||||
|
std::string Parent(MAX_PATH,0);
|
||||||
|
DWORD ppid = getParentPID(GetCurrentProcessId());
|
||||||
|
HANDLE Process = getProcess(ppid, &Parent[0], MAX_PATH);
|
||||||
|
if(Process == nullptr){
|
||||||
|
HMODULE hMods[1024];
|
||||||
|
DWORD cbNeeded;
|
||||||
|
unsigned int i;
|
||||||
|
if(K32EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)){
|
||||||
|
for ( i = 1; i < (cbNeeded / sizeof(HMODULE)); i++ ){
|
||||||
|
TCHAR szModName[MAX_PATH];
|
||||||
|
if (K32GetModuleFileNameExA(hProcess, hMods[i], szModName, sizeof(szModName) / sizeof(TCHAR))){
|
||||||
|
std::string Name(szModName),PName(argv[0]);
|
||||||
|
Name = Name.substr(0,Name.rfind(Sec("\\")));
|
||||||
|
PName = PName.substr(0,PName.rfind(Sec("\\")));
|
||||||
|
if(Name == PName){
|
||||||
|
std::thread t1(Kill);
|
||||||
|
t1.detach();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
}
|
@ -16,16 +16,13 @@ extern int TraceBack;
|
|||||||
bool Dev = false;
|
bool Dev = false;
|
||||||
namespace fs = std::experimental::filesystem;
|
namespace fs = std::experimental::filesystem;
|
||||||
std::string GetEN(){
|
std::string GetEN(){
|
||||||
static std::string r = Sec("BeamMP-Launcher.exe");
|
return std::string(Sec("BeamMP-Launcher.exe"));
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
std::string GetVer(){
|
std::string GetVer(){
|
||||||
static std::string r = Sec("1.70");
|
return std::string(Sec("1.70"));
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
std::string GetPatch(){
|
std::string GetPatch(){
|
||||||
static std::string r = Sec("");
|
return std::string(Sec(""));
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
void ReLaunch(int argc,char*args[]){
|
void ReLaunch(int argc,char*args[]){
|
||||||
std::string Arg;
|
std::string Arg;
|
||||||
@ -184,6 +181,7 @@ void InitLauncher(int argc, char* argv[]) {
|
|||||||
SetConsoleTitleA((Sec("BeamMP Launcher v") + std::string(GetVer()) + GetPatch()).c_str());
|
SetConsoleTitleA((Sec("BeamMP Launcher v") + std::string(GetVer()) + GetPatch()).c_str());
|
||||||
InitLog();
|
InitLog();
|
||||||
CheckName(argc, argv);
|
CheckName(argc, argv);
|
||||||
|
FindDLL(argv);
|
||||||
SecurityCheck(argv);
|
SecurityCheck(argv);
|
||||||
Discord_Main();
|
Discord_Main();
|
||||||
RequestRole();
|
RequestRole();
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[noreturn]] void aa(){
|
[[noreturn]] void aa(){
|
||||||
while(true){
|
while(true){
|
||||||
std::cout.flush();
|
std::cout.flush();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user