Пользователь
-
Автор темы
- #1
Валв взломан
Нашёл в пизде интернета
Нашёл в пизде интернета
C++:
#include <windows.h>
#include <vector>
#include <TlHelp32.h>
#include <stdio.h>
std::uint8_t* PatternScan(void* module, const char* signature)
{
static auto pattern_to_byte = [](const char* pattern) {
auto bytes = std::vector<int>{};
auto start = const_cast<char*>(pattern);
auto end = const_cast<char*>(pattern) + strlen(pattern);
for (auto current = start; current < end; ++current) {
if (*current == '?') {
++current;
if (*current == '?')
++current;
bytes.push_back(-1);
}
else {
bytes.push_back(strtoul(current, ¤t, 16));
}
}
return bytes;
};
auto dosHeader = (PIMAGE_DOS_HEADER)module;
auto ntHeaders = (PIMAGE_NT_HEADERS)((std::uint8_t*)module + dosHeader->e_lfanew);
auto sizeOfImage = ntHeaders->OptionalHeader.SizeOfImage;
auto patternBytes = pattern_to_byte(signature);
auto scanBytes = reinterpret_cast<std::uint8_t*>(module);
auto s = patternBytes.size();
auto d = patternBytes.data();
for (auto i = 0ul; i < sizeOfImage - s; ++i) {
bool found = true;
for (auto j = 0ul; j < s; ++j) {
if (scanBytes[i + j] != d[j] && d[j] != -1) {
found = false;
break;
}
}
if (found) {
return &scanBytes[i];
}
}
return nullptr;
}
int Main() {
HWND CounterStrike = FindWindow(0, "Counter-Strike: Global Offensive");
DWORD dwPID;
GetWindowThreadProcessId(CounterStrike, &dwPID);
uint8_t* prime = PatternScan(GetModuleHandleA("client.dll"), "8B 0D ? ? ? ? 85 C9 75 04 33 C0 EB 1E");
DWORD OldProtect;
VirtualProtect(prime, 5, PAGE_EXECUTE_READWRITE, &OldProtect);
char patch[] = { 0x31,0xC0,0x40,0xC3 };
memcpy(prime, patch, 5);
VirtualProtect(prime, 5, OldProtect, nullptr);
return 0;
}
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDll,_In_ DWORD fdwReason,_In_opt_ LPVOID lpvReserved){
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Main, 0, 0, 0);
default:
return TRUE;
}
}