Knight online için yapmış olduğum bir programdı. KnightOnline.exe çalışmaya başladıktan sonra ilk açılan 2 thread güvenlik ile alakalı bir takım illegal aktiviteleri arıyordu. Onları otomatik bulup sonlandırmaları için yapmıştım.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
#include "stdafx.h" #include <stdio.h> #include <windows.h> #include <tlhelp32.h> #include <shlwapi.h> #include <conio.h> #include <iostream> #include <fstream> #include <string> #include <WinSock.h> using namespace std; bool threadClose=false; HANDLE CurrentThread; int ThCount=1; HANDLE ThreadListA[10]; HANDLE Ko_Handle=0; void ThreadList(int processId){ HANDLE snapHandle = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); if (snapHandle != INVALID_HANDLE_VALUE) { THREADENTRY32 te; PROCESSENTRY32 pe; te.dwSize = sizeof(te); if (Thread32First(snapHandle, &te)) { do { if (te.dwSize >= FIELD_OFFSET(THREADENTRY32, th32OwnerProcessID) + sizeof(te.th32OwnerProcessID)) { if(te.th32OwnerProcessID == processId) { ThCount++; ThreadListA[ThCount] = (HANDLE)te.th32ThreadID; printf("ExeName :%d ProcessID: %d ThreadID %d\n",pe.szExeFile,te.th32OwnerProcessID, te.th32ThreadID); } } te.dwSize = sizeof(te); } while (Thread32Next(snapHandle, &te)); } CloseHandle(snapHandle); } } void KillThreads(HANDLE Th){ TerminateThread(Th,0); } DWORD GetTargetThreadIDFromProcName(const char * ProcName) { PROCESSENTRY32 pe; HANDLE thSnapShot; BOOL retval, ProcFound = false; thSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if(thSnapShot == INVALID_HANDLE_VALUE) { printf("Error: Unable to create toolhelp snapshot!"); return false; } pe.dwSize = sizeof(PROCESSENTRY32); retval = Process32First(thSnapShot, &pe); while(retval) { } return 0; } void SoacsTh(){ char* app = "KnightOnline.exe"; while(1) { if(GetTargetThreadIDFromProcName(app)){ ThreadList(GetTargetThreadIDFromProcName(app)); KillThreads(ThreadListA[0]); KillThreads(ThreadListA[2]); for(int i=0; i<5; i++) { cout << "Thread " << ThreadListA[i]<<endl; } printf("Die from thread... Closing\n"); cout << "Kapatilan Thread :" <<endl<<"\t2->"<<ThreadListA[0]<<endl<<"\t3->"<<ThreadListA[2]<<endl; printf("Good bye..\n"); } Sleep(1); } return SoacsTh(); } int main(int argc, char* argv[]) { ThreadList(GetTargetThreadIDFromProcName("KnightOnline.exe")); /* SoacsTh(); CreateThread(0,0,(LPTHREAD_START_ROUTINE)SoacsTh,0,0,0); */ /// getch(); EXIT_SUCCESS; } |