当前位置导航:炫浪网>>网络学院>>编程开发>>C++教程>>Visual C++教程

用vc++穷举windows应用程序密码(中)

 3 TEXTINCLUDE DISCARDABLE

BEGIN

    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"

    "#define _AFX_NO_OLE_RESOURCES\r\n"

    "#define _AFX_NO_TRACKER_RESOURCES\r\n"

    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"

    "\r\n"

    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)\r\n"

    "#ifdef _WIN32\r\n"

    "LANGUAGE 4, 2\r\n"

    "#pragma code_page(936)\r\n"

    "#endif //_WIN32\r\n"

    "#include ""res\\GetCode.rc2""  // non-Microsoft Visual C++ edited resources\r\n"

    "#include ""l.chs\\afxres.rc""          // Standard components\r\n"

    "#endif\r\n"

    "\0"

END

 

#endif    // APSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////

//

// Icon

//

// Icon with lowest ID value placed first to ensure application icon

// remains consistent on all systems.

IDR_MAINFRAME           ICON    DISCARDABLE     "res\\GetCode.ico"

 

/////////////////////////////////////////////////////////////////////////////

//

// Dialog

//

 

IDD_GETCODE_DIALOG DIALOGEX 0, 0, 320, 221

STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP |

    WS_VISIBLE | WS_CAPTION | WS_SYSMENU

EXSTYLE WS_EX_APPWINDOW

CAPTION "密码穷举设置"

FONT 9, "宋体"

BEGIN

    DEFPUSHBUTTON   "应用",IDOK,262,19,51,14

    PUSHBUTTON      "退出",IDCANCEL,263,63,50,14

    GROUPBOX        "密码输入窗口设置",IDC_STATIC,7,44,221,51

    EDITTEXT        IDC_EDIT1,113,52,83,14,ES_AUTOHSCROLL

    LTEXT           "密码窗口标题",IDC_STATIC,19,56,49,8

    LTEXT           "密码输入确认按钮标题",IDC_STATIC,19,76,81,8

    EDITTEXT        IDC_EDIT2,113,73,83,14,ES_AUTOHSCROLL

    GROUPBOX        "密码输错窗口设置",IDC_STATIC,7,98,221,51

    EDITTEXT        IDC_EDIT3,113,106,83,14,ES_AUTOHSCROLL

    LTEXT           "密码出错提示窗口标题",IDC_STATIC,19,110,81,8

    LTEXT           "重新输入确认按钮标题",IDC_STATIC,19,130,81,8

    EDITTEXT        IDC_EDIT4,113,127,83,14,ES_AUTOHSCROLL

    GROUPBOX        "穷举密码方法设置",IDC_STATIC,7,152,221,62,WS_GROUP

    CONTROL         "数字",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | WS_GROUP,

                    13,164,32,10

    CONTROL         "小写字母",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON |

                    WS_GROUP,45,164,48,10

    CONTROL         "大写字母",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON |

                    WS_GROUP,93,164,48,10

    CONTROL         "大小写字母组合",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON |

                    WS_GROUP,150,164,72,10

    CONTROL         "数字字母组合",IDC_RADIO5,"Button",BS_AUTORADIOBUTTON |

                    WS_GROUP,14,177,64,10

    CONTROL         "所有字符",IDC_RADIO6,"Button",BS_AUTORADIOBUTTON |

                    WS_GROUP,81,176,48,10

    CONTROL         "字典穷举法",IDC_RADIO7,"Button",BS_AUTORADIOBUTTON |

                    WS_GROUP,150,175,71,10

    PUSHBUTTON      "暂停",IDPause,263,41,50,14

    GROUPBOX        "枚举线程数目",IDC_STATIC,7,7,221,34

    LTEXT           "线程数目",IDC_STATIC,14,23,57,8

    EDITTEXT        IDC_EDIT5,86,19,42,14,ES_AUTOHSCROLL

 

    LTEXT           "枚举文件名",IDC_STATIC,15,195,42,19

    EDITTEXT        IDC_EDIT6,66,194,111,14,ES_AUTOHSCROLL

    PUSHBUTTON      "浏览...",IDC_BROWSE,185,193,31,14

END

#ifndef _MAC

/////////////////////////////////////////////////////////////////////////////

//

// Version

//

VS_VERSION_INFO VERSIONINFO

 FILEVERSION 1,0,0,1

 PRODUCTVERSION 1,0,0,1

 FILEFLAGSMASK 0x3fL

#ifdef _DEBUG

 FILEFLAGS 0x1L

#else

 FILEFLAGS 0x0L

#endif

 FILEOS 0x4L

 FILETYPE 0x1L

 FILESUBTYPE 0x0L

BEGIN

    BLOCK "StringFileInfo"

    BEGIN

        BLOCK "080404B0"

        BEGIN

            VALUE "CompanyName", "\0"

            VALUE "FileDescription", "GetCode Microsoft 基础类应用程序\0"

            VALUE "FileVersion", "1, 0, 0, 1\0"

            VALUE "InternalName", "GetCode\0"

            VALUE "LegalCopyright", "版权所有 (C) 1999\0"

            VALUE "LegalTrademarks", "\0"

            VALUE "OriginalFilename", "GetCode.EXE\0"

            VALUE "ProductName", "GetCode 应用程序\0"

            VALUE "ProductVersion", "1, 0, 0, 1\0"

        END

    END

    BLOCK "VarFileInfo"

    BEGIN

        VALUE "Translation", 0x804, 1200

    END

END

#endif    // !_MAC

/////////////////////////////////////////////////////////////////////////////

//

// DESIGNINFO

//

#ifdef APSTUDIO_INVOKED

GUIDELINES DESIGNINFO DISCARDABLE

BEGIN

    IDD_GETCODE_DIALOG, DIALOG

    BEGIN

        LEFTMARGIN, 7

        RIGHTMARGIN, 313

        TOPMARGIN, 7

        BOTTOMMARGIN, 214

        HORZGUIDE, 139

    END

END

#endif    // APSTUDIO_INVOKED

 

#endif    // Chinese (P.R.C.) resources

/////////////////////////////////////////////////////////////////////////////

#ifndef APSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////

//

// Generated from the TEXTINCLUDE 3 resource.

//

#define _AFX_NO_SPLITTER_RESOURCES

#define _AFX_NO_OLE_RESOURCES

#define _AFX_NO_TRACKER_RESOURCES

#define _AFX_NO_PROPERTY_RESOURCES

 

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)

#ifdef _WIN32

LANGUAGE 4, 2

#pragma code_page(936)

#endif //_WIN32

#include "res\GetCode.rc2"  // non-Microsoft Visual C++ edited resources

#include "l.chs\afxres.rc"          // Standard components

#endif

 

/////////////////////////////////////////////////////////////////////////////

#endif    // not APSTUDIO_INVOKED

2.对话框头文件

// GetCodeDlg.h : header file

//

 

#if !defined(AFX_GETCODEDLG_H__B5583AA8_7FDB_11D3_BF20_D9C0F13E2367__INCLUDED_)

#define AFX_GETCODEDLG_H__B5583AA8_7FDB_11D3_BF20_D9C0F13E2367__INCLUDED_

 

#if _MSC_VER > 1000

#pragma once

#endif // _MSC_VER > 1000

 

/////////////////////////////////////////////////////////////////////////////

// CGetCodeDlg dialog

class CGetCodeDlg : public CDialog

{

// Construction

public:

    CGetCodeDlg(CWnd* pParent = NULL); // standard constructor

 

    // Dialog Data

    //{{AFX_DATA(CGetCodeDlg)

    enum { IDD = IDD_GETCODE_DIALOG };

    CButton  m_Quit;

    CEdit   m_EditPath;

    CButton  m_BtnBrowser;

    CButton  m_Pause;

    CButton  m_OK;

    UINT    m_nThreadCount;

    //}}AFX_DATA

 

    // ClassWizard generated virtual function overrides

    //{{AFX_VIRTUAL(CGetCodeDlg)

    protected:

    virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

    //}}AFX_VIRTUAL

 

// Implementation

protected:

    HICON m_hIcon;

        // Generated message map functions

    //{{AFX_MSG(CGetCodeDlg)

    virtual BOOL OnInitDialog();

    afx_msg void OnPaint();

    afx_msg HCURSOR OnQueryDragIcon();

    afx_msg void OnOK();

    afx_msg void OnCANCEL();

    afx_msg void OnPause();

    afx_msg void OnBrowse();

    afx_msg void OnRadio7();

    afx_msg void OnRadio1();

    afx_msg void OnRadio2();

    afx_msg void OnRadio3();

    afx_msg void OnRadio4();

    afx_msg void OnRadio5();

    afx_msg void OnRadio6();

    //}}AFX_MSG

    DECLARE_MESSAGE_MAP()

};

 

//{{AFX_INSERT_LOCATION}}

// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

 

#endif // !defined(AFX_GETCODEDLG_H__B5583AA8_7FDB_11D3_BF20_D9C0F13E2367__INCLUDED_)

3。对话框源文件

// GetCodeDlg.cpp : implementation file

//

 

#include "stdafx.h"

#include "GetCode.h"

#include "GetCodeDlg.h"

#include "stdlib.h"

#include "ctype.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

#define INPUTDIALOGID 1001  //枚举子窗口时标识对话框的类别为密码输入对话框

#define INPUTRETRYDIALOGID 1002//枚举子窗口时标识对话框的类别为确认重新输入对//话框

#define MAX_THREAD 50

/////////////////////////////////////////////////////////////////////////////

// CGetCodeDlg dialog

    struct ThreadStru

    {CWinThread * pThread;

    }m_pEnumThread[MAX_THREAD];//定义线程结构数组,用以存放多线程的线程指针

    BOOL m_bEnum;//枚举控制布尔变量,若此值为假,终止所有线程枚举。

    HWND m_hwnd;//存放对话框窗口句柄,用于在公共模块访问对话框控件

    HWND hButton1,hButton2;//存放两个对话框确认按钮的窗口句柄。

    BOOL m_bPasswordStyle;//窗口风格标志,标识子窗口为编辑框的子窗口是否                  //具有口令风格。

    bool bFetched;//枚举的密码是否被取走标志,

    UINT  nThreadCount;//线程数目计数

    char lpszDialogCaption[80];//对话框标题

    char lpszButtonConfirmCaption[20];//对话框确认按钮标题

    char lpszDialogRetryCaption[80];//重试对话框标题

    char lpszButtonRetryCaption[20];//重试对话框标题按钮标题

    char lpszThreadCount[4];//线程数目计数

    char lpszPath[MAX_PATH];//字典穷举的文件路径

    char lpszMethod[30]="\0";//穷举密码方法

    HANDLE m_hMutex;//互斥信号量句柄

    TCHAR lpszPassword[30];//枚举密码产生的密码

    DWORD WINAPI EnumProc( LPVOID );//线程函数声明

    BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam );

    //窗口函数枚举声明

    BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam);

    //子窗口函数枚举声明

    void EnumPasswordString(void);

    //密码字符发生器,产生密码序列

    CGetCodeDlg::CGetCodeDlg(CWnd* pParent /*=NULL*/)

    : CDialog(CGetCodeDlg::IDD, pParent)

{

    //{{AFX_DATA_INIT(CGetCodeDlg)

    m_nThreadCount = 0;//线程数目初始化为零

    //}}AFX_DATA_INIT

    // Note that LoadIcon does not require a subsequent DestroyIcon in Win32

    m_bPasswordStyle=FALSE;

    m_bEnum=TRUE;

 

    bFetched=true;

    m_hwnd=this->m_hWnd;

//以下语句用于从记录文件读取信息以便使系统恢复到上次退出时的状态。

    GetPrivateProfileString("设置","线程计数","1",lpszThreadCount,4,"Setup.ini");

    GetPrivateProfileString("设置","口令输入窗口标题","LOGIN",lpszDialogCaption,80,"Setup.ini");

    GetPrivateProfileString("设置","口令输入窗口确认按钮标题","OK",lpszButtonConfirmCaption,20,"Setup.ini");

    GetPrivateProfileString("设置","提示口令错要求重新输入窗口标题","Login",lpszDialogRetryCaption,80,"Setup.ini");

    GetPrivateProfileString("设置","提示口令错要求重新输入窗口确认按钮标题","确认",lpszButtonRetryCaption,20,"Setup.ini");

    GetPrivateProfileString("设置","穷举方法","数字",lpszMethod,30,"Setup.ini");

    GetPrivateProfileString("设置","穷举文件","",lpszPath,MAX_PATH,"Setup.ini");

    this->m_nThreadCount=atoi(lpszThreadCount);

    nThreadCount=this->m_nThreadCount;

    m_hIcon= AfxGetApp()->LoadIcon(IDR_MAINFRAME);

}

 

void CGetCodeDlg::DoDataExchange(CDataExchange* pDX)

{

    CDialog::DoDataExchange(pDX);

    //{{AFX_DATA_MAP(CGetCodeDlg)

    DDX_Control(pDX, IDCANCEL, m_Quit);

    DDX_Control(pDX, IDC_EDIT6, m_EditPath);

    DDX_Control(pDX, IDC_BROWSE, m_BtnBrowser);

    DDX_Control(pDX, IDPause, m_Pause);

    DDX_Control(pDX, IDOK, m_OK);

    DDX_Text(pDX, IDC_EDIT5, m_nThreadCount);

    DDV_MinMaxUInt(pDX, m_nThreadCount, 1, 50);

    //}}AFX_DATA_MAP

}

 

BEGIN_MESSAGE_MAP(CGetCodeDlg, CDialog)

    //{{AFX_MSG_MAP(CGetCodeDlg)

    ON_WM_PAINT()

    ON_WM_QUERYDRAGICON()

    ON_BN_CLICKED(IDCANCEL, OnCANCEL)

    ON_BN_CLICKED(IDPause, OnPause)

    ON_BN_CLICKED(IDC_BROWSE, OnBrowse)

    ON_BN_CLICKED(IDC_RADIO7, OnRadio7)

    ON_BN_CLICKED(IDC_RADIO1, OnRadio1)

    ON_BN_CLICKED(IDC_RADIO2, OnRadio2)

    ON_BN_CLICKED(IDC_RADIO3, OnRadio3)

    ON_BN_CLICKED(IDC_RADIO4, OnRadio4)

    ON_BN_CLICKED(IDC_RADIO5, OnRadio5)

    ON_BN_CLICKED(IDC_RADIO6, OnRadio6)

    ON_BN_CLICKED(IDOK, OnOK)

    //}}AFX_MSG_MAP

END_MESSAGE_MAP()

 

/////////////////////////////////////////////////////////////////////////////

// CGetCodeDlg message handlers

 

BOOL CGetCodeDlg::OnInitDialog()

{

    CDialog::OnInitDialog();

    //

    // 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_hMutex=::CreateMutex(NULL,FALSE,NULL);

    //设置对话框控件

    SetDlgItemText(IDC_EDIT1,lpszDialogCaption);

    SetDlgItemText(IDC_EDIT2,lpszButtonConfirmCaption);

    SetDlgItemText(IDC_EDIT3,lpszDialogRetryCaption);

    SetDlgItemText(IDC_EDIT4,lpszButtonRetryCaption);

    SetDlgItemText(IDC_EDIT6,lpszPath);

    CString lpszTemp;

    lpszTemp.Format("%s",lpszMethod);

    if(lpszTemp=="数字") CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO1);

    if(lpszTemp=="小写字母") CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO2);

    if(lpszTemp=="大写字母")CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO3);

    if(lpszTemp== "大小写字母组合")CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO4);

    if(lpszTemp== "数字字母组合")CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO5);

    if(lpszTemp== "所有字符")CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO6);

    if(lpszTemp== "数据字典")

    {CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO7);

    m_EditPath.EnableWindow(TRUE);

    m_BtnBrowser.EnableWindow(TRUE);

    }

    else

    {m_EditPath.EnableWindow(FALSE);

    m_BtnBrowser.EnableWindow(FALSE);

    }

 

    // TODO: Add extra initialization here

 

    return TRUE;  // return TRUE  unless you set the focus to a control

}

相关内容
赞助商链接