Helló, az volna felétek a kérdésem, hogy ilyen: https://metin2dev.org/board/index.php?/topic/2906-simple-anti-cheat-with-python/
vagy ehez hasonló védelmet tudtok küldeni ami forrásban írodik?
Tehát leginkább erre a részre volna szügségem:
Idézdef ProcCheck():
whitelist = ["putty.exe","filezilla.exe"]
hack = []
result = []
Persze mindezt forrásban...Pl: kliens futási idő alatt egy beállított alkalmazást bezárjon!
Inkább fogalmazd meg, hogy mit szeretnél, mert senki se akar abban bogarászni (vagy nem ért feltétlen az ember pythonhoz).
De ha jól értelmezem, tessék itt van vmi ilyesmi.
based on (https://stackoverflow.com/questions/3477097/get-full-running-process-list-visual-c)
#include <Windows.h>
#include <string>
#include <TlHelp32.h>
#include <vector>
bool FindRunningProcess(std::wstring process)
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcessSnap == INVALID_HANDLE_VALUE)
{
return false;
}
else
{
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hProcessSnap, &pe32))
{
if (pe32.szExeFile == process)
return true;
else
{
while (Process32Next(hProcessSnap, &pe32))
if (pe32.szExeFile == process)
return true;
}
CloseHandle(hProcessSnap);
}
}
return false;
}
és akkor utána
std::wstring blocked[] = {L"valami.exe",L"valami2.exe",L"valami3.exe",L"valami4.exe"};
for (int i = 0; i < sizeof(blocked) / sizeof(blocked[0]); ++i)
if (FindRunningProcess(blocked[i]))
exit(0);
Esetleg
HANDLE hProteksön = NULL;
void Proteksön()
{
P:
std::wstring blocked[] = {L"valami.exe",L"valami2.exe",L"valami3.exe",L"valami4.exe"};
for (int i = 0; i < sizeof(blocked) / sizeof(blocked[0]); ++i)
if (FindRunningProcess(blocked[i]))
exit(0);
Sleep(1000);
goto P;
}
és ezt beszúrni ahol el akarod indítani a védelmet:
hProteksön = CreateThread(NULL, NULL, LPTHREAD_START_ROUTINE(Proteksön), NULL, NULL, NULL);
Mindketten jól értelmeztétek, bocsi a meg fogalmazásért, erre gondoltam igen :D Viszont azt nem tudom, pontosan melyik fájlba és azon belül hol kezdjek el "szúrkálni" :)
nézd meg, hogy melyik függvény az entry point, azt hiszem a WinMain az UserInterface.cpp-ben
Csak én nem látom értelmét ennek a védelemnek? ???
Nóp, való igaz h ekze alaplyán gyökérség védeni, de mi csak átkonvertáltuk neki cépépére.
Valahogy így? Esetleg ha nem jó vetne rá valaki egy pillantást?
fv-t a fv-be? :o ???
magát a FindRunningProcess függvényt a WinMain elé tedd és a második [ code ]-ben lévőt tedd bele a WinMainbe
DE, ha azt akarod, hogy folyamatosan fusson, akkor egy új threadben indítsd el és detach-eld
Így valahogy? (csatolva)
Erre panaszkodik:
Error 13 error C2679: binary '==' : no operator found which takes a right-hand operand of type 'std::wstring' (or there is no acceptable conversion)
Error 14 error C2679: binary '==' : no operator found which takes a right-hand operand of type 'std::wstring' (or there is no acceptable conversion)
15 IntelliSense: no operator "==" matches these operands
operand types are: CHAR [260] == std::wstring
16 IntelliSense: no operator "==" matches these operands
operand types are: CHAR [260] == std::wstring
Hozzáírtam a folyamatos ellenőrzést amúgy most.
Szóval a WinMain függvény elé ezt így egy ez egyben tedd be:
#include <Windows.h>
#include <string>
#include <TlHelp32.h>
#include <vector>
#include <thread>
bool FindRunningProcess(std::wstring process)
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcessSnap == INVALID_HANDLE_VALUE)
{
return false;
}
else
{
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hProcessSnap, &pe32))
{
if (pe32.szExeFile == process)
return true;
else
{
while (Process32Next(hProcessSnap, &pe32))
if (pe32.szExeFile == process)
return true;
}
CloseHandle(hProcessSnap);
}
}
return false;
}
void Protection()
{
while (true)
{
std::wstring blocked[] = { L"valami1.exe", L"valami2.exe", L"valami3.exe", L"valami4.exe" };
for (int i = 0; i < sizeof(blocked) / sizeof(blocked[0]); ++i)
if (FindRunningProcess(blocked[i]))
exit(0);
Sleep(1000);
}
}
Ezt a 2 sort pedig a WinMain függvényedbe tedd bele:
std::thread prot(Protection);
prot.detach();
Ahogy látom, lehet felül vannak írva nálad ezek a függvények (?) és wcharok helyett sima charokat használ. Akkor írd át a wstring-eket stringre és szedd ki az L betűket a tömb elemei elől.
Esetleg ha működik, és lejebb veszem az ellenörzési időt, pl: 1000 ről 5-re akkor nem lesz az, hogy minden ellenőrzésnél, egy atom nagy lagg? :D Sajnos tapasztaltam már ilyet azért kérdezem.
Üzenet összefésülés: 2018-08-06, 18:28:16
Error 13 error C2679: binary '==' : no operator found which takes a right-hand operand of type 'std::wstring' (or there is no acceptable conversion)
Error 14 error C2679: binary '==' : no operator found which takes a right-hand operand of type 'std::wstring' (or there is no acceptable conversion)
Ezt az üzenetet kapom.
Eh idézetre akartam nyomni, nem thank youra.
Már leírtam az előbb, hogy mit írj akkor át, de látom nem megy, tessék:
#include <Windows.h>
#include <string>
#include <TlHelp32.h>
#include <vector>
#include <thread>
bool FindRunningProcess(std::string process)
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcessSnap == INVALID_HANDLE_VALUE)
{
return false;
}
else
{
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hProcessSnap, &pe32))
{
if (pe32.szExeFile == process)
return true;
else
{
while (Process32Next(hProcessSnap, &pe32))
if (pe32.szExeFile == process)
return true;
}
CloseHandle(hProcessSnap);
}
}
return false;
}
void Protection()
{
while (true)
{
std::string blocked[] = { "valami1.exe", "valami2.exe", "valami3.exe", "valami4.exe" };
for (int i = 0; i < sizeof(blocked) / sizeof(blocked[0]); ++i)
if (FindRunningProcess(blocked[i]))
exit(0);
Sleep(1000);
}
}
Köszi szépen, és a türelmed is :D Sikerült :) Ment a +
Esetleg ugyan ez a funkció megoldható, hogy ne a klienst zárja be, hanem magát a tiltó listán lévő elemeket? :)
Írd felül a Protection és a FindRunningProcess függvényt:
DWORD FindRunningProcess(std::string process)
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcessSnap == INVALID_HANDLE_VALUE)
{
return false;
}
else
{
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hProcessSnap, &pe32))
{
if (pe32.szExeFile == process)
return pe32.th32ProcessID;
else
{
while (Process32Next(hProcessSnap, &pe32))
if (pe32.szExeFile == process)
return pe32.th32ProcessID;
}
CloseHandle(hProcessSnap);
}
}
return 0;
}
void Protection()
{
while (true)
{
std::string blocked[] = { "valami1.exe", "valami2.exe", "valami3.exe", "valami4.exe" };
for (int i = 0; i < sizeof(blocked) / sizeof(blocked[0]); ++i)
{
DWORD curr_id = FindRunningProcess(blocked[i]);
if (curr_id)
TerminateProcess(OpenProcess(SYNCHRONIZE | PROCESS_TERMINATE, TRUE, curr_id), 0);
}
Sleep(1000);
}
}
Köszönöm szépen, működik :D