Ethereal/dll/HEH/dllmain.cpp

75 lines
2.4 KiB
C++
Raw Normal View History

2022-09-09 21:20:46 +02:00
#define _CRT_SECURE_NO_WARNINGS
#include <thread>
#include <filesystem>
#include <fstream>
#include <string>
2022-09-12 17:19:29 +02:00
#include <windows.h>
2022-09-09 21:20:46 +02:00
#include <sstream>
HANDLE p;
void patch(PVOID address, int opCode, int bytes) {
DWORD protectbak, dumbshit;
VirtualProtectEx(p, address, bytes, PAGE_EXECUTE_READWRITE, &protectbak);
memset(address, opCode, bytes);
VirtualProtectEx(p, address, bytes, protectbak, &dumbshit);
}
void patchm(PVOID address, std::vector<char> bytes, int size) {
DWORD protectbak, dumbshit;
VirtualProtect(address, size, PAGE_EXECUTE_READWRITE, &protectbak);
memcpy(address, bytes.data(), size);
VirtualProtect(address, size, protectbak, &dumbshit);
}
void log(const char* msg) {
2022-09-09 21:52:56 +02:00
time_t currentTime;
struct tm* localTime;
time(&currentTime);
localTime = localtime(&currentTime);
printf("[%02d:%02d:%02d] %s\n", localTime->tm_hour, localTime->tm_min, localTime->tm_sec, msg);
2022-09-09 21:20:46 +02:00
}
__declspec(dllexport) void lessgo(HMODULE hmod) {
AllocConsole();
p = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
freopen("CONOUT$", "w", stdout);
2022-09-09 21:52:56 +02:00
DWORD64 mod = (DWORD64)LoadLibraryA(std::string("C:\\Ethereal\\Ethereal.dll").c_str());
2022-09-09 21:20:46 +02:00
std::stringstream ss;
ss << std::hex << mod;
2022-09-12 17:19:29 +02:00
patch((void*)(mod + 0x4A9E0), 0xB8, 1);
2022-09-09 21:52:56 +02:00
log("Applied patch 1/10");
2022-09-12 17:19:29 +02:00
patch((void*)(mod + 0x4A9E1), 0x01, 1);
2022-09-09 21:52:56 +02:00
log("Applied patch 2/10");
2022-09-12 17:19:29 +02:00
patch((void*)(mod + 0x4A9E2), 0x00, 1);
2022-09-09 21:52:56 +02:00
log("Applied patch 3/10");
2022-09-12 17:19:29 +02:00
patch((void*)(mod + 0x4A9E3), 0x00, 1);
2022-09-09 21:52:56 +02:00
log("Applied patch 4/10");
2022-09-12 17:19:29 +02:00
patch((void*)(mod + 0x4A9E4), 0x00, 1);
2022-09-09 21:52:56 +02:00
log("Applied patch 5/10");
2022-09-12 17:19:29 +02:00
patch((void*)(mod + 0x4A9E5), 0xC3, 1);
2022-09-09 21:52:56 +02:00
log("Applied patch 6/10");
2022-09-12 17:19:29 +02:00
patch((void*)(mod + 0x4A9E6), 0x90, 1);
2022-09-09 21:52:56 +02:00
log("Applied patch 7/10");
2022-09-12 17:19:29 +02:00
patch((void*)(mod + 0x4A9E7), 0x90, 1);
2022-09-09 21:52:56 +02:00
log("Applied patch 8/10");
2022-09-12 17:19:29 +02:00
patch((void*)(mod + 0x4A9E8), 0x90, 1);
2022-09-09 21:52:56 +02:00
log("Applied patch 9/10");
2022-09-12 17:19:29 +02:00
patch((void*)(mod + 0x4A9E9), 0x90, 1);
2022-09-09 21:52:56 +02:00
log("Applied patch 10/10");
2022-09-09 21:20:46 +02:00
while (FindWindowA(0, "Ethereal") == NULL) Sleep(100);
HWND w = FindWindowA(0, "Ethereal");
SetWindowTextA(w, "Ethereal | cracked by EinTim#0777");
}
BOOL APIENTRY DllMain(HMODULE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
{
if(ul_reason_for_call == 1){
CreateThread(nullptr, NULL, [](LPVOID hmod) -> DWORD {
lessgo((HMODULE)hmod);
return 0;
}, NULL, NULL, NULL);
return TRUE;
}
return FALSE;
}