Added Crack Detection

This commit is contained in:
Anonymous275 2020-03-15 20:57:02 +02:00
parent aa875cf8e8
commit 648fadaeec
3 changed files with 71 additions and 28 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/cmake-build-debug/
/cmake-build-release/
/.idea/

View File

@ -5,11 +5,24 @@
#include <windows.h>
#include <iostream>
#include <string>
#include <cstring>
#include <tchar.h>
#define MAX_KEY_LENGTH 255
#define MAX_VALUE_NAME 16383
std::string keyName;
std::string HTA(std::string hex)
{
std::string ascii;
for (size_t i = 0; i < hex.length(); i += 2)
{
std::string part = hex.substr(i, 2);
char ch = stoul(part, nullptr, 16);
ascii += ch;
}
return ascii;
}
std::string QueryKey(HKEY hKey)
{
TCHAR achKey[MAX_KEY_LENGTH]; // buffer for subkey name
@ -65,12 +78,17 @@ std::string QueryKey(HKEY hKey)
if (retCode == ERROR_SUCCESS )
{
DWORD lpData = cbMaxValueData;
buffer[0] = '\0';
LONG dwRes = RegQueryValueEx(hKey, achValue, 0, NULL, buffer, &lpData);
std::string Path = reinterpret_cast<const char *const>(buffer);
return Path.substr(0,Path.length()-2);
std::string data = reinterpret_cast<const char *const>(buffer);
std::string key = achValue;
if(data.find(':') != std::string::npos){
return data.substr(0,data.length()-2);
}
if(key == "Name" && data == "BeamNG.drive"){
return "check";
}
}
}
}else{
@ -81,21 +99,47 @@ std::string QueryKey(HKEY hKey)
}
void Start();
int main()
{
void getPath(){
HKEY hKey;
LONG dwRegOPenKey = RegOpenKeyEx(HKEY_CLASSES_ROOT, "beamng\\DefaultIcon", 0, KEY_READ, &hKey);
if(dwRegOPenKey == ERROR_SUCCESS){
keyName = QueryKey(hKey);
std::cout << keyName << std::endl; //Prints the exe path
LONG dwRegOPenKey = RegOpenKeyEx(HKEY_CLASSES_ROOT, HTA("6265616d6e675c44656661756c7449636f6e").c_str()/*"beamng\\DefaultIcon"*/, 0, KEY_READ, &hKey);
if(dwRegOPenKey != ERROR_SUCCESS){
std::cout << "Error #1\n";
}else{
std::cout << "Error Failed to Find Beamng\n";
keyName = QueryKey(hKey);
std::cout << "full path : " << keyName << std::endl;
}
RegCloseKey(hKey);
}
int main()
{
//Security
HKEY hKey;
LONG dwRegOPenKey = RegOpenKeyEx(HKEY_CURRENT_USER, HTA("536f6674776172655c56616c7665").c_str(), 0, KEY_READ, &hKey);
if(dwRegOPenKey != ERROR_SUCCESS){
std::cout << HTA("4572726f7220506c6561736520436f6e7461637420537570706f7274210a");
exit(-1);
}
dwRegOPenKey = RegOpenKeyEx(HKEY_CURRENT_USER, HTA("536f6674776172655c56616c76655c537465616d5c417070735c323834313630").c_str(), 0, KEY_READ, &hKey);
if(dwRegOPenKey != ERROR_SUCCESS){
std::cout << HTA("796f7520646f206e6f74206f776e207468652067616d65206f6e2074686973206d616368696e65210a");
}else{
keyName = QueryKey(hKey);
if(!keyName.empty()){
std::cout << HTA("796f75206f776e207468652067616d65206f6e2074686973206d616368696e65210a");
getPath();
}else{
std::cout << HTA("796f7520646f206e6f74206f776e207468652067616d65206f6e2074686973206d616368696e65210a");
}
}
//Software\Classes\beamng\DefaultIcon
RegCloseKey(hKey);
/// Update, Mods ect...
Start(); //Proxy main start
//Start(); //Proxy main start
system("pause");
return 0;

View File

@ -5,11 +5,9 @@
#define ENET_IMPLEMENTATION
#include "enet.h"
#include <WinSock2.h>
#include <Windows.h>
#include <WS2tcpip.h>
#include <cstdio>
#include <iostream>
#include <string>
#include <thread>
#define DEFAULT_BUFLEN 64000
#define DEFAULT_PORT "4444"
@ -42,7 +40,7 @@ void TCPServerThread(){
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != 0) {
printf("WSAStartup failed with error: %d\n", iResult);
std::cout <<"WSAStartup failed with error: " << iResult << std::endl;
}
ZeroMemory(&hints, sizeof(hints));
@ -54,14 +52,14 @@ void TCPServerThread(){
// Resolve the server address and port
iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result);
if ( iResult != 0 ) {
printf("getaddrinfo failed with error: %d\n", iResult);
std::cout << "getaddrinfo failed with error: " << iResult << std::endl;
WSACleanup();
}
// Create a socket for connecting to server
ListenSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
if (ListenSocket == INVALID_SOCKET) {
printf("socket failed with error: %d\n", WSAGetLastError());
std::cout << "socket failed with error: " << WSAGetLastError() << std::endl;
freeaddrinfo(result);
WSACleanup();
}
@ -69,7 +67,7 @@ void TCPServerThread(){
// Setup the TCP listening socket
iResult = bind(ListenSocket, result->ai_addr, (int)result->ai_addrlen);
if (iResult == SOCKET_ERROR) {
printf("bind failed with error: %d\n", WSAGetLastError());
std::cout << "bind failed with error: " << WSAGetLastError() << std::endl;
freeaddrinfo(result);
closesocket(ListenSocket);
WSACleanup();
@ -79,13 +77,13 @@ void TCPServerThread(){
iResult = listen(ListenSocket, SOMAXCONN);
if (iResult == SOCKET_ERROR) {
printf("listen failed with error: %d\n", WSAGetLastError());
std::cout << "listen failed with error: " << WSAGetLastError() << std::endl;
closesocket(ListenSocket);
WSACleanup();
}
ClientSocket = accept(ListenSocket, NULL, NULL);
if (ClientSocket == INVALID_SOCKET) {
printf("accept failed with error: %d\n", WSAGetLastError());
std::cout << "accept failed with error: " << WSAGetLastError() << std::endl;
closesocket(ListenSocket);
WSACleanup();
}
@ -95,12 +93,12 @@ void TCPServerThread(){
if(!RUDPData.empty()){
iSendResult = send( ClientSocket, RUDPData.c_str(), int(RUDPData.length())+1, 0);
if (iSendResult == SOCKET_ERROR) {
printf("send failed with error: %d\n", WSAGetLastError());
std::cout << "send failed with error: " << WSAGetLastError() << std::endl;
closesocket(ClientSocket);
WSACleanup();
}else{
RUDPData.clear();
printf("Bytes sent: %d\n", iSendResult);
std::cout << "Bytes sent: " << iSendResult << std::endl;
}
}
@ -113,9 +111,9 @@ void TCPServerThread(){
}
else if (iResult == 0)
printf("Connection closing...\n");
std::cout << "Connection closing...\n";
else {
printf("recv failed with error: %d\n", WSAGetLastError());
std::cout << "recv failed with error: " << WSAGetLastError() << std::endl;
closesocket(ClientSocket);
WSACleanup();
}
@ -124,7 +122,7 @@ void TCPServerThread(){
iResult = shutdown(ClientSocket, SD_SEND);
if (iResult == SOCKET_ERROR) {
printf("shutdown failed with error: %d\n", WSAGetLastError());
std::cout << "shutdown failed with error: " << WSAGetLastError() << std::endl;
closesocket(ClientSocket);
WSACleanup();
}
@ -163,7 +161,7 @@ void HandleEvent(ENetEvent event,Client client){
}
void RUDPClientThread(){
if (enet_initialize() != 0) {
printf("An error occurred while initializing ENet.\n");
std::cout << "An error occurred while initializing ENet.\n";
}
@ -174,13 +172,13 @@ void RUDPClientThread(){
address.port = 30814;
printf("starting client...\n");
std::cout << "starting client...\n";
enet_address_set_host(&address, "localhost");
client.host = enet_host_create(NULL, 1, 2, 0, 0);
client.peer = enet_host_connect(client.host, &address, 2, 0);
if (client.peer == NULL) {
printf("could not connect\n");
std::cout << "could not connect\n";
}
do {