⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 superpwdspydlg.cpp

📁 利用钩子与API截获方法获取WEB网页及应用程序密码编辑框中的密码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// SuperPwdSpyDlg.cpp : implementation file
//

/************************************
  REVISION LOG ENTRY
  Revision By: Zhang, Zhefu
  Contact: codetiger@hotmail.com
  Revised on 12/7/2002 10:44:33 AM
  Comment: Following Source is Written To Contribute to WWW.CodeGuru.Com
  Also check http://codeguru.earthweb.com/ieprogram/SPwdSpy.html
       for latest patch
 ************************************/

#include "stdafx.h"
#include "SuperPwdSpy.h"
#include "SuperPwdSpyDlg.h"
#include "Toolhelp.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define TOOLTIP_FG_COLOR RGB(255,255,255)
#define TOOLTIP_BK_COLOR RGB(58,110,165)

int CSuperPwdSpyDlg::m_nTransparent[] = { 255, 225, 200,175, 150, 125};
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
#include "HyperLink.h"
class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	CString	m_str;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnTimer(UINT nIDEvent);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	m_str = _T("http://codeguru.earthweb.com/ieprogram/SPwdSpy.html");
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	DDX_Text(pDX, IDC_EDIT, m_str);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSuperPwdSpyDlg dialog

CSuperPwdSpyDlg::CSuperPwdSpyDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSuperPwdSpyDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSuperPwdSpyDlg)
	m_bMore = TRUE;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDI_LOOK_ICON1);//IDR_MAINFRAME);

	m_bCapture = FALSE;
	m_hPrevSpyWnd = NULL; //inside mouse move the previous lighted wnd
	m_hwndSpying = NULL; //double click win tree to locate the win
	m_hTarget = NULL;
	m_msg = RegisterWindowMessage(_T("Something"));
	if(m_msg == 0)
	{
		::PostQuitMessage(0);
	}
	m_bStayOnTop = TRUE;

	VERIFY(m_HollowBrush.CreateStockObject(HOLLOW_BRUSH));
	m_WhiteBrush.CreateSolidBrush(RGB(225,225,225));
}

void CSuperPwdSpyDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSuperPwdSpyDlg)
	DDX_Control(pDX, IDC_COMBO_TRANSPARENT, m_comboTransparent);
	DDX_Control(pDX, IDC_LOOK, m_look);
	DDX_Control(pDX, IDC_EDIT_CTRL_ID, m_editCtrlID);
	DDX_Control(pDX, IDC_EDIT_WNDCLASS, m_editWndClass);
	DDX_Control(pDX, IDC_EDIT_PWD, m_editPwd);
	DDX_Control(pDX, IDC_EDIT_PID, m_editPID);
	DDX_Control(pDX, IDC_EDIT_MOUSEPOS, m_editMousePos);
	DDX_Control(pDX, IDC_EDIT_ISPWD, m_strIsPwd);
	DDX_Control(pDX, IDC_EDIT_HWND, m_editHandle);
	DDX_Control(pDX, IDC_EDIT_EXE_PATH, m_editExePath);
	DDX_Control(pDX, IDC_EDIT_EXE_NAME, m_editExeName);
	DDX_Control(pDX, IDC_EDIT_CAPTION, m_editCaption);
	DDX_Check(pDX, IDC_CHECK_MORE, m_bMore);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSuperPwdSpyDlg, CDialog)
	//{{AFX_MSG_MAP(CSuperPwdSpyDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_MOUSEMOVE()
	ON_WM_COPYDATA()
	ON_WM_ERASEBKGND()
	ON_WM_CTLCOLOR()
	ON_BN_CLICKED(IDC_CHECK_MORE, OnCheckMore)
	ON_CBN_SELCHANGE(IDC_COMBO_TRANSPARENT, OnSelchangeComboTransparent)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSuperPwdSpyDlg message handlers

BOOL CSuperPwdSpyDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	this->SetWindowText(_T("SuperPasswordSpy++"));
	ShowMoreInfo(m_bMore);
	for(int i = 0; i < sizeof(this->m_nTransparent)/sizeof(this->m_nTransparent[0]); i++)
	{
		CString str;
		str.Format(_T("%d"), this->m_nTransparent[i]);
		m_comboTransparent.InsertString(-1, str);
	}
	m_comboTransparent.SetCurSel(0);


	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	m_tt.Create(this);
	m_tt.SetTipBkColor(TOOLTIP_BK_COLOR);
	m_tt.SetTipTextColor(TOOLTIP_FG_COLOR);
	m_tt.SetMaxTipWidth(400);
	m_tt.SetDelayTime(500, 20000);

	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_PWD),
		_T("See Password Here.\nIf Target IE Page Contains Multiple Password Field, They are Listed by Tab Order on that Homepage"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_WNDCLASS),
		_T("Tracking Window Class Name(Length Must Be Shorter Than MAX_PATH (256))"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_PID),
		_T("Tracking Window's Process ID(in Decimal Value)"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_MOUSEPOS),
		_T("Tracking Mouse Position(in Screen Coordinate)"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_ISPWD),
		_T("Does Target Window Contain Password Field?"));

	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_HWND),
		_T("Tracking Window's Handle(in Hex Value)"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_EXE_PATH),
		_T("Execute File's Full Directory of Tracking Window's Process"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_EXE_NAME),
		_T("Execute File Name of Tracking Window's Process \n(Note: Tracking Window May Resides inside A DLL other than This Execute File!)"));
	m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_CAPTION),
		_T("Tracking Window's Caption(Length Must Be Shorter Than MAX_PATH (256))"));
    m_tt.AddWindowTool (GetDlgItem (IDC_COMBO_TRANSPARENT),
		_T("Make This Window Transparent"));
	m_tt.AddWindowTool (GetDlgItem (IDC_CHECK_MORE),
		_T("Show/Hide More Information"));
    m_tt.AddWindowTool (GetDlgItem (IDC_EDIT_CTRL_ID),
		_T("Tracking Window's Control ID"));

	CStatic* pLook = (CStatic*)GetDlgItem(IDC_LOOK);
	CRect rectLook;
	pLook->GetWindowRect(&rectLook);
	this->ScreenToClient(&rectLook);
	m_tt.AddTool(this, (LPCTSTR)_T("Drag This Magnifying Glass Over Any Password Area"), &rectLook, IDC_LOOK);


	CStatic* pStay = (CStatic*)GetDlgItem(IDC_STAY);
	CRect rectStay;
	pStay->GetWindowRect(&rectStay);
	this->ScreenToClient(&rectStay);
	m_tt.AddTool(this, (LPCTSTR)_T("StayOnTop Switch"), &rectStay, IDC_STAY);

	if(m_bStayOnTop)
		this->SetWindowPos(&wndTopMost, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CSuperPwdSpyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CSuperPwdSpyDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CSuperPwdSpyDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CSuperPwdSpyDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
	RelayEvent(WM_LBUTTONDOWN, (WPARAM)nFlags,
					MAKELPARAM(LOWORD(point.x), LOWORD(point.y)));

	CStatic* pLook = (CStatic*)GetDlgItem(IDC_LOOK);
	CRect rectLook;
	pLook->GetWindowRect(&rectLook);

	CStatic* pStay = (CStatic*)GetDlgItem(IDC_STAY);
	CRect rectStay;
	pStay->GetWindowRect(&rectStay);

    this->ClientToScreen(&point);
	if(rectLook.PtInRect(point)) 
	{
		this->GetWindowRect(&m_rect);
		
		HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(), 
			MAKEINTRESOURCE(IDI_BLANK_ICON));
		pLook->SetIcon(hIcon);
		HCURSOR hCursor = ::LoadCursor(AfxGetInstanceHandle(),
			MAKEINTRESOURCE(IDC_LOOK_CUR));
		SetCursor(hCursor); 
		m_bCapture = TRUE;
		SetCapture();
	}
	else if(rectStay.PtInRect(point)) 
	{
		if(m_bStayOnTop)
		{
			this->SetWindowPos(&wndBottom, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
		    this->SetWindowPos(&wndTop , 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
		}
	    else
		{
			this->SetWindowPos(&wndTopMost, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
		}
		m_bStayOnTop = !m_bStayOnTop;

		if(m_bStayOnTop)
		{
			HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(), 
			   MAKEINTRESOURCE(IDI_STAYTOP));
		    pStay->SetIcon(hIcon);
		}
		else
		{
			HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(), 
			   MAKEINTRESOURCE(IDI_NOT_STAYTOP));
		    pStay->SetIcon(hIcon);
		}

	}
	else
	CDialog::OnLButtonDown(nFlags, point);
}

void CSuperPwdSpyDlg::OnLButtonUp(UINT nFlags, CPoint point) 
{
	RelayEvent(WM_LBUTTONUP, (WPARAM)nFlags,
					MAKELPARAM(LOWORD(point.x), LOWORD(point.y)));

	CStatic* pLook = (CStatic*)GetDlgItem(IDC_LOOK);
	if(m_bCapture)
	{
		ReleaseCapture(); 
        
        HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(), 
			MAKEINTRESOURCE(IDI_LOOK_ICON));
		pLook->SetIcon(hIcon);

		SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
		if(m_hPrevSpyWnd) 
		{
			HighlightWindow(m_hPrevSpyWnd,FALSE);			
		}
		m_hPrevSpyWnd = NULL;
		
		m_bCapture = FALSE;
	}
	else 
	CDialog::OnLButtonUp(nFlags, point);
}

void CSuperPwdSpyDlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	RelayEvent(WM_MOUSEMOVE, (WPARAM)nFlags,
					MAKELPARAM(LOWORD(point.x), LOWORD(point.y)));

	if(m_bCapture)
	{
		this->ClientToScreen(&point);
		if(m_rect.PtInRect(point)) return;
		HWND hWnd = XYZWindowFromPoint(NULL, point);
		
		CString strMousePos;
	    strMousePos.Format(_T("X = %d, Y = %d"), point.x, point.y);
        m_editMousePos.SetWindowText(strMousePos);

		if(hWnd != m_hPrevSpyWnd)
		{
			HCURSOR hCursor = ::LoadCursor(AfxGetInstanceHandle(),
		         	MAKEINTRESOURCE(IDC_LOOK_CUR));
		    SetCursor(hCursor); 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -