mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-06 15:56:26 +00:00
Launcher update to 1.63.5
- async tcp buffer - two way encryption on connect - map security fix - DNS Lookup on connect - fixed bug in beamng security
This commit is contained in:
@@ -219,7 +219,7 @@ std::string GetManifest(const std::string& Man){
|
||||
}
|
||||
bool IDCheck(std::string Man, std::string steam){
|
||||
bool a = false,b = true;
|
||||
int pos = int(Man.find(Sec("steamapps")));
|
||||
int pos = int(Man.rfind(Sec("steamapps")));
|
||||
if(pos == -1)Exit(5);
|
||||
Man = Man.substr(0,pos+9) + Sec("/appmanifest_284160.acf");
|
||||
steam += Sec("/config/loginusers.vdf");
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <fstream>
|
||||
#include <Psapi.h>
|
||||
void DAS(){
|
||||
int i = 0;
|
||||
/*int i = 0;
|
||||
std::ifstream f(GetEN(), std::ios::binary);
|
||||
f.seekg(0, std::ios_base::end);
|
||||
std::streampos fileSize = f.tellg();
|
||||
@@ -19,10 +19,10 @@ void DAS(){
|
||||
DAboard();
|
||||
}
|
||||
if(i)DAboard();
|
||||
f.close();
|
||||
f.close();*/
|
||||
}
|
||||
void DASM(){ //A mirror to have 2 independent checks
|
||||
int i = 0;
|
||||
/*int i = 0;
|
||||
std::ifstream f(GetEN(), std::ios::binary);
|
||||
f.seekg(0, std::ios_base::end);
|
||||
std::streampos fileSize = f.tellg();
|
||||
@@ -31,7 +31,7 @@ void DASM(){ //A mirror to have 2 independent checks
|
||||
DAboard();
|
||||
}
|
||||
if(i)DAboard();
|
||||
f.close();
|
||||
f.close();*/
|
||||
}
|
||||
DWORD getParentPID(DWORD pid){
|
||||
HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
@@ -58,6 +58,7 @@ HANDLE getProcess(DWORD pid, LPSTR fname, DWORD sz) {
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UnderSimulation(char* argv[]){
|
||||
DWORD ppid;
|
||||
std::string Parent(MAX_PATH,0);
|
||||
@@ -68,23 +69,22 @@ void UnderSimulation(char* argv[]){
|
||||
error(Code+std::to_string(2));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
auto P = Parent.find(Sec(".exe"));
|
||||
if(P != std::string::npos)Parent.resize(P + 4);
|
||||
else{
|
||||
error(Code+std::to_string(3));
|
||||
exit(1);
|
||||
}
|
||||
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;
|
||||
TerminateProcess(Process, 1);
|
||||
error(Code + std::to_string(4));
|
||||
exit(1);
|
||||
|
||||
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);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "Security/Enc.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <random>
|
||||
|
||||
int LocalKeys[] = {7406809,6967,4810803}; //n e d
|
||||
|
||||
@@ -13,6 +14,64 @@ int log_power(int n,unsigned int p, int mod){
|
||||
return result;
|
||||
}
|
||||
|
||||
int Rand(){
|
||||
std::random_device r;
|
||||
std::default_random_engine e1(r());
|
||||
std::uniform_int_distribution<int> uniform_dist(1, 5000);
|
||||
return uniform_dist(e1);
|
||||
}
|
||||
|
||||
bool rabin_miller(int n){
|
||||
bool ok = true;
|
||||
for (int i = 1; i <= 5 && ok; i++) {
|
||||
int a = Rand() + 1;
|
||||
int result = log_power(a, n - 1, n);
|
||||
ok &= (result == 1);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
int generate_prime(){
|
||||
int generated = Rand();
|
||||
while (!rabin_miller(generated))generated = Rand();
|
||||
return generated;
|
||||
}
|
||||
int gcd(int a, int b){
|
||||
while (b){
|
||||
int r = a % b;
|
||||
a = b;
|
||||
b = r;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
int generate_coprime(int n){
|
||||
int generated = Rand();
|
||||
while (gcd(n, generated) != 1)generated = Rand();
|
||||
return generated;
|
||||
}
|
||||
|
||||
std::pair<int, int> euclid_extended(int a, int b) {
|
||||
if(!b)return {1, 0};
|
||||
auto result = euclid_extended(b, a % b);
|
||||
return {result.second, result.first - (a / b) * result.second};
|
||||
}
|
||||
|
||||
int modular_inverse(int n, int mod){
|
||||
int inverse = euclid_extended(n, mod).first;
|
||||
while(inverse < 0)inverse += mod;
|
||||
return inverse;
|
||||
}
|
||||
|
||||
RSA* GenKey(){
|
||||
int p, q;
|
||||
p = generate_prime();
|
||||
q = generate_prime();
|
||||
int n = p * q;
|
||||
int phi = (p -1) * (q - 1);
|
||||
int e = generate_coprime(phi);
|
||||
int d = modular_inverse(e, phi);
|
||||
return new RSA{n,e,d};
|
||||
}
|
||||
int Enc(int value,int e,int n){
|
||||
return log_power(value, e, n);
|
||||
}
|
||||
@@ -37,35 +96,8 @@ std::string LocalDec(const std::string& Data){
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#include <random>
|
||||
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){
|
||||
if(msg.size() < 2)return "";
|
||||
int R = uint8_t(msg.at(0));
|
||||
if(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;
|
||||
}
|
||||
|
||||
std::string RSA_E(const std::string& Data,int e, int n){
|
||||
if(e < 10 || n < 10)return "";
|
||||
std::stringstream stream;
|
||||
for(const char&c : Data){
|
||||
stream << std::hex << Enc(uint8_t(c),e,n) << "g";
|
||||
|
||||
@@ -58,7 +58,7 @@ void ContinuousCheck(fs::file_time_type last){
|
||||
}
|
||||
}else i = 0;
|
||||
CheckDirs();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(800));
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user