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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
BOOL ListProcessModules(DWORD dwPID);
void printError(TCHAR* msg);
BOOL GetLastWriteTime(HANDLE hFile, LPTSTR lpszString, DWORD dwSize)
{
FILETIME ftCreate, ftAccess, ftWrite;
SYSTEMTIME stUTC, stLocal;
DWORD dwRet;
// Retrieve the file times for the file.
if (!GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite))
return FALSE;
// Convert the last-write time to local time.
FileTimeToSystemTime(&ftWrite, &stUTC);
SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
// Build a string showing the date and time.
dwRet = StringCchPrintf(lpszString, dwSize,
TEXT("%02d%02d%d%02d%02d"),
stLocal.wMonth, stLocal.wDay, stLocal.wYear,
stLocal.wHour, stLocal.wMinute);
if( S_OK == dwRet )
return TRUE;
else return FALSE;
}
extern "C" __declspec(dllexport) bool __cdecl damage()
{
while (true)
{
Sleep(5000);
DWORD my;
my = GetCurrentProcessId();
// 0 means current process, that is this program...
ListProcessModules(my);
}
}
BOOL ListProcessModules(DWORD dwPID)
{
remove ("mgm.log");
HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
MODULEENTRY32 me32;
// Take a snapshot of all modules in the specified process.
hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwPID);
if(hModuleSnap == INVALID_HANDLE_VALUE)
{
printError(L"CreateToolhelp32Snapshot()");
return (FALSE);
}
// Set the size of the structure before using it.
me32.dwSize = sizeof(MODULEENTRY32);
// Retrieve information about the first module, and exit if unsuccessful
if(!Module32First(hModuleSnap, &me32))
{
printError(L"Module32First()"); // Show cause of failure
CloseHandle(hModuleSnap); // Must clean up the snapshot object
return (FALSE);
}
// Now walk the module list of the process, and display information about each module
while (Module32Next(hModuleSnap, &me32))
{
std::string s;
char ch[260];
char DefChar = ' ';
WideCharToMultiByte(CP_ACP,0,me32.szExePath,-1, ch,260,&DefChar, NULL);
s = ch;
HANDLE hFile;
TCHAR szBuf[MAX_PATH];
hFile = CreateFile(me32.szExePath, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
printf("CreateFile failed with %d\n", GetLastError());
return 0;
}
if(GetLastWriteTime( hFile, szBuf, MAX_PATH ))
TCHAR szBuf[256];
std::wstring arr_w( szBuf );
std::string arr_s( arr_w.begin(), arr_w.end() );
CloseHandle(hFile);
fstream textfile;
textfile.open ("mgm.log", ios::out | ios::app);
textfile<<s.c_str() << " ------ " << arr_s.c_str()<< endl;
if (arr_s.find ("051820141958") != std::string::npos)
{
fstream textfile;
textfile.open ("mgm.log", ios::out | ios::app);
textfile<< "Karacabay-Scan : " <<"Hack Girişimi Algılandı - Lalaker Pro Damage"<< endl;
textfile<< "Karacabay-Scan : " <<"Oyun Kapatılıyor..."<< endl;
Sleep (1000);
ShellExecuteA( NULL, "open", "mgm.log", NULL, NULL, SW_SHOWNORMAL );
ExitProcess(0);
return TRUE;
}
}
// Do not forget to clean up the snapshot object.
CloseHandle(hModuleSnap);
return (TRUE);
}
// Printing the error if any
void printError(TCHAR* msg)
{
DWORD eNum;
TCHAR sysMsg[256];
TCHAR* p;
eNum = GetLastError();
// FormatMessageW - unicode, FormatMessageA - ANSI
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, eNum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
sysMsg, 256, NULL);
// Trim the end of the line and terminate it with a null
p = sysMsg;
while ((*p > 31) || (*p == 9))
++p;
do { *p-- = 0; }
while ((p >= sysMsg) && ((*p == '.') || (*p < 33)));
// Display the message...
printf("\n WARNING: %S failed with error %d (%s)\n", msg, eNum, sysMsg);
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
CreateThread(NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(damage), hModule, 0, NULL);
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
|