密码查看器(线程注入)

本文介绍了一种利用远程线程注入技术来获取密码框中隐藏字符的方法。通过DLL实现,结合WinAPI、Hook及Callback机制,详细探讨了如何在不影响程序正常运行的情况下读取密码数据。
摘要由CSDN通过智能技术生成

采用远程线程注入技术,获得一般的密码框*号下的数据

 

 

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);
		
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值