mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-02 16:06:35 +00:00
Base for new system
This commit is contained in:
parent
1579c8bc29
commit
f858c462af
@ -2,5 +2,7 @@
|
||||
/// Created by Anonymous275 on 7/18/2020
|
||||
///
|
||||
#pragma once
|
||||
#include <string>
|
||||
int Download(const std::string& URL,const std::string& Path,bool close);
|
||||
std::string PostHTTP(const std::string& IP, const std::string& Fields);
|
||||
std::string HTTP_REQUEST(const std::string& IP,int port);
|
@ -6,7 +6,6 @@
|
||||
void PreGame(int argc, char* argv[],const std::string& GamePath);
|
||||
void InitGame(const std::string& Dir,const std::string&Current);
|
||||
std::string CheckVer(const std::string &path);
|
||||
void SecurityCheck(char* argv[]);
|
||||
void FindDLL(char* args[]);
|
||||
std::string GetGameDir();
|
||||
void LegitimacyCheck();
|
||||
void CheckLocalKey();
|
||||
|
@ -74,7 +74,7 @@ void discordInit(){
|
||||
}else std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
}
|
||||
}
|
||||
void DAS();
|
||||
|
||||
[[noreturn]] void SecurityLoop(){
|
||||
std::string t,t1,t2;
|
||||
while(true){
|
||||
@ -86,7 +86,6 @@ void DAS();
|
||||
}else if(t2 != LocalDec(DiscordInfo->DID) ||
|
||||
t != LocalDec(DiscordInfo->Name) || t1 != LocalDec(DiscordInfo->Tag))DiscordInfo = nullptr;
|
||||
}else if(!t.empty())DiscordInfo->DID.clear();
|
||||
DAS();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +201,6 @@ void NetMain(const std::string& IP, int Port){
|
||||
}
|
||||
void TCPGameServer(const std::string& IP, int Port){
|
||||
GSocket = SetupListener();
|
||||
FindDLL(nullptr);
|
||||
while (!TCPTerminate && GSocket != -1){
|
||||
debug(Sec("MAIN LOOP OF GAME SERVER"));
|
||||
GConnected = false;
|
||||
|
@ -6,8 +6,8 @@
|
||||
#include "Security/Enc.h"
|
||||
#include <curl/curl.h>
|
||||
#include <iostream>
|
||||
#include "Logger.h"
|
||||
#include <mutex>
|
||||
|
||||
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp){
|
||||
((std::string*)userp)->append((char*)contents, size * nmemb);
|
||||
return size * nmemb;
|
||||
@ -88,3 +88,25 @@ int Download(const std::string& URL,const std::string& Path,bool close){
|
||||
std::cout << std::endl;
|
||||
return -1;
|
||||
}
|
||||
std::string PostHTTP(const std::string& IP, const std::string& Fields) {
|
||||
static auto *header = new curl_slist{(char*)"Content-Type: application/json"};
|
||||
CURL* curl;
|
||||
CURLcode res;
|
||||
std::string readBuffer;
|
||||
curl = curl_easy_init();
|
||||
if (curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, IP.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header);
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, Fields.size());
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Fields.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
|
||||
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5);
|
||||
res = curl_easy_perform(curl);
|
||||
curl_easy_cleanup(curl);
|
||||
if (res != CURLE_OK)
|
||||
return "-1";
|
||||
}
|
||||
return readBuffer;
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 7/16/2020
|
||||
///
|
||||
#include "Discord/discord_info.h"
|
||||
#include "Security/Enc.h"
|
||||
#include <windows.h>
|
||||
#include "Startup.h"
|
||||
#include <tlhelp32.h>
|
||||
#include "Logger.h"
|
||||
#include <fstream>
|
||||
#include <Psapi.h>
|
||||
void DAS(){
|
||||
#ifndef DEBUG
|
||||
int i = 0;
|
||||
std::ifstream f(GetEN(), std::ios::binary);
|
||||
f.seekg(0, std::ios_base::end);
|
||||
std::streampos fileSize = f.tellg();
|
||||
if(IsDebuggerPresent() || fileSize > 0x4C4B40){
|
||||
i++;
|
||||
DAboard();
|
||||
}
|
||||
if(i)DAboard();
|
||||
f.close();
|
||||
#endif
|
||||
}
|
||||
DWORD getParentPID(DWORD pid){
|
||||
HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
PROCESSENTRY32 pe = {0};
|
||||
DWORD ppid = 0;
|
||||
pe.dwSize = sizeof(PROCESSENTRY32);
|
||||
if(Process32First(h, &pe)){
|
||||
do{
|
||||
if(pe.th32ProcessID == pid){
|
||||
ppid = pe.th32ParentProcessID;
|
||||
break;
|
||||
}
|
||||
}while(Process32Next(h, &pe));
|
||||
}
|
||||
CloseHandle(h);
|
||||
return ppid;
|
||||
}
|
||||
|
||||
HANDLE getProcess(DWORD pid, LPSTR fname, DWORD sz) {
|
||||
HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
|
||||
if (h) {
|
||||
GetModuleFileNameEx(h, nullptr, fname, sz);
|
||||
return h;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UnderSimulation(char* argv[]){
|
||||
DWORD ppid;
|
||||
std::string Parent(MAX_PATH,0);
|
||||
ppid = getParentPID(GetCurrentProcessId());
|
||||
HANDLE Process = getProcess(ppid, &Parent[0], MAX_PATH);
|
||||
std::string Code = Sec("Code ");
|
||||
if(Process == nullptr){
|
||||
error(Code+std::to_string(2));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
auto P = Parent.find(Sec(".exe"));
|
||||
if(P != std::string::npos)Parent.resize(P + 4);
|
||||
else return;
|
||||
std::string S1 = Sec("\\Windows\\explorer.exe");
|
||||
std::string S2 = Sec("JetBrains\\CLion");
|
||||
std::string S3 = Sec("\\Windows\\System32\\cmd.exe");
|
||||
std::string S4 = Sec("steam.exe");
|
||||
if(Parent == std::string(argv[0]))return;
|
||||
if(Parent.find(S1) == 2)return;
|
||||
if(Parent.find(S2) != std::string::npos)return;
|
||||
if(Parent.find(S3) == 2)return;
|
||||
if(Parent.find(S3) != -1)return;
|
||||
//TerminateProcess(Process, 1);
|
||||
//error(Code + std::to_string(4));
|
||||
//exit(1); //TODO look into that later
|
||||
}
|
||||
void SecurityCheck(char* argv[]){
|
||||
//UnderSimulation(argv);
|
||||
DAS();
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
///
|
||||
/// 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();
|
||||
}
|
||||
}
|
||||
ZeroMemory(szModName,MAX_PATH);
|
||||
}
|
||||
}
|
||||
}
|
||||
CloseHandle(hProcess);
|
||||
}
|
26
src/Security/Login.cpp
Normal file
26
src/Security/Login.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 11/26/2020
|
||||
///
|
||||
|
||||
#include "Curl/http.h"
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
//check file if not present flag for login to the core network
|
||||
//to then get user and pass
|
||||
//if present use to contact the backend to refresh and get a public key for servers
|
||||
//public keys are one time use for a random server
|
||||
|
||||
/// "username":"password"
|
||||
/// "Guest":"Name"
|
||||
/// "pk":"private_key"
|
||||
|
||||
|
||||
///TODO: test with no internet connection
|
||||
void CheckLocalKey(){
|
||||
for(int C = 1; C <= 10; C++) {
|
||||
std::cout << PostHTTP("https://auth.beammp.com/userlogin", R"({"username":"Anonymous275", "password":"SimonAS1482001"})") << std::endl;
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
}
|
||||
system("pause");
|
||||
}
|
@ -181,8 +181,7 @@ void InitLauncher(int argc, char* argv[]) {
|
||||
SetConsoleTitleA((Sec("BeamMP Launcher v") + std::string(GetVer()) + GetPatch()).c_str());
|
||||
InitLog();
|
||||
CheckName(argc, argv);
|
||||
//FindDLL(argv);
|
||||
SecurityCheck(argv);
|
||||
CheckLocalKey(); //will replace DiscordMain
|
||||
Discord_Main();
|
||||
RequestRole();
|
||||
CustomPort(argc, argv);
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
|
||||
[[noreturn]] void aa(){
|
||||
[[noreturn]] void flush(){
|
||||
while(true){
|
||||
std::cout.flush();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
@ -16,8 +16,8 @@
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
#ifdef DEBUG
|
||||
std::thread gb(aa);
|
||||
gb.detach();
|
||||
std::thread th(flush);
|
||||
th.detach();
|
||||
#endif
|
||||
InitLauncher(argc,argv);
|
||||
CheckDir(argc,argv);
|
||||
|
Loading…
x
Reference in New Issue
Block a user