Hello, today I am sharing a code I used for client protection. I no longer need it because I now use much more advanced tools and no longer rely on it. The code scans all possible names from an array, and if it detects a specific phrase, it completely shuts down the game, saves a protection log in a .txt file, and informs the player about the shutdown. The code detects open names in folders, browsers, Discord, Notepad, or any other application. As soon as any phrase from the array appears, the client is automatically closed, and the user is notified about the detection of suspicious activity.
C
- Userinterface.cpp
- #include <fstream>
- #include <string>
- #include <shellapi.h>
- #include <regex>
- #include <thread>
- #include <chrono>
- #include <windows.h>
- std::vector<std::string> windowBlackList = {
- "inject",
- "lalaker",
- "hlbot",
- "eterwizard",
- "etermgr",
- "m2bob",
- "netlimiter",
- "metin2mod",
- "wireshark",
- "unpack",
- "clicker",
- "debugger",
- "Wiersz polecenia",
- "ymir work",
- "stmod",
- "hlb0t",
- "metin2 bot",
- "m24pro"
- };
- static BOOL CALLBACK FindBlacklistWindow(HWND hWnd, LPARAM lparam)
- {
- int length = GetWindowTextLength(hWnd);
- char* buffer = new char[length + 1];
- GetWindowTextA(hWnd, buffer, length + 1);
- std::string windowTitle(buffer);
- if (IsWindowVisible(hWnd) && length != 0)
- {
- for (const auto& blacklisted : windowBlackList)
- {
- if (std::regex_search(windowTitle, std::regex(blacklisted, std::regex_constants::icase)))
- {
- std::ofstream textfile("protection.txt", std::ios::out | std::ios::app);
- textfile << "Protection Alert: Suspicious activity detected. Client terminated." << std::endl;
- ShellExecuteA(NULL, "open", "protection.txt", NULL, NULL, SW_SHOWNORMAL);
- TerminateProcess(GetCurrentProcess(), 0);
- exit(0);
- }
- }
- }
- delete[] buffer;
- return TRUE;
- }
- void ScanForBlockedWindows()
- {
- while(true)
- {
- EnumWindows(FindBlacklistWindow, NULL);
- std::this_thread::sleep_for(std::chrono::milliseconds(200));
- }
- }
- void Protection()
- {
- CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(ScanForBlockedWindows), NULL, NULL, 0);
- }
- ////////////////////////
- Find:
- int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- Add after:
- Protection();