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

📄 getcodedlg.cpp

📁 穷举型密码破译器。可以自定义词典
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// 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
}

// 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 CGetCodeDlg::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 CGetCodeDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}





void CGetCodeDlg::OnOK() 
{
	GetDlgItemText(IDC_EDIT1,lpszDialogCaption,80);
	GetDlgItemText(IDC_EDIT2,lpszButtonConfirmCaption,20);
	GetDlgItemText(IDC_EDIT3,lpszDialogRetryCaption,80);
	GetDlgItemText(IDC_EDIT4,lpszButtonRetryCaption,20);	
	GetDlgItemText(IDC_EDIT5,lpszThreadCount,20);
	GetDlgItemText(IDC_EDIT6,lpszPath,MAX_PATH);
	nThreadCount=(int)GetDlgItemInt(IDC_EDIT5,NULL,true);
	if ((nThreadCount<1)||(nThreadCount>50))
	{SetDlgItemText(IDC_EDIT5,"5");
	GetDlgItem(IDC_EDIT5)->SetFocus();
	return ;
	}
	WritePrivateProfileString("设置","线程计数",lpszThreadCount,"Setup.ini");
	WritePrivateProfileString("设置","口令输入窗口标题",lpszDialogCaption,"Setup.ini");
	WritePrivateProfileString("设置","口令输入窗口确认按钮标题",lpszButtonConfirmCaption,"Setup.ini");
	WritePrivateProfileString("设置","提示口令错要求重新输入窗口标题",lpszDialogRetryCaption,"Setup.ini");
	WritePrivateProfileString("设置","提示口令错要求重新输入窗口确认按钮标题",lpszButtonRetryCaption,"Setup.ini");
	WritePrivateProfileString("设置","穷举文件",lpszPath,"Setup.ini");
	LPTSTR lpszTemp;
	if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO1)lpszTemp="数字";
	if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO2)lpszTemp="小写字母";
	if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO3)lpszTemp="大写字母";
	if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO4)lpszTemp="大小写字母组合";
	if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO5)lpszTemp="数字字母组合";
	if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO6)lpszTemp="所有字符";
	if(this->GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO7)==IDC_RADIO7)lpszTemp="数据字典";
	WritePrivateProfileString("设置","穷举方法",lpszTemp,"Setup.ini");
	m_OK.EnableWindow(FALSE);
	m_Quit.EnableWindow(FALSE);
	m_Pause.EnableWindow(TRUE);
	m_Pause.SetFocus();
	this->PostMessage(WM_SYSCOMMAND,SC_MINIMIZE,0);
	if (m_pEnumThread[0].pThread ==NULL)
	{	UINT i;
	
	for(i=1;i<=this->m_nThreadCount ;i++)
		{
		m_pEnumThread[i].pThread=AfxBeginThread((AFX_THREADPROC)EnumProc,(LPVOID)0,THREAD_PRIORITY_LOWEST,0,0,NULL);
		m_pEnumThread[i].pThread->m_bAutoDelete =true;
		}
	}
	else 
		{	UINT i;
		for(i=1;i<=this->m_nThreadCount;i++)
		m_pEnumThread[i].pThread->ResumeThread();
		}
		
	

}
DWORD WINAPI EnumProc( LPVOID )
{while (m_bEnum)
{
	::EnumWindows((WNDENUMPROC)EnumWindowsProc,NULL);	
}
return true;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam )
{	
	if (!IsWindowVisible(hwnd)) return true;
	char lpString[128]="\0";
	::GetWindowText(hwnd,(LPSTR)lpString,sizeof(lpString));
	if(strstr(lpString,(const char *)lpszDialogCaption)!=NULL)
	{::WaitForSingleObject(m_hMutex,INFINITE);
	::EnumChildWindows(hwnd,(WNDENUMPROC) EnumChildProc,INPUTDIALOGID);
	::ReleaseMutex(m_hMutex);
	return false;
	}
	if(strstr(lpString,(const char *)lpszDialogRetryCaption)!=NULL)
	{::WaitForSingleObject(m_hMutex,INFINITE);
	::EnumChildWindows(hwnd,(WNDENUMPROC) EnumChildProc,INPUTRETRYDIALOGID);
	::ReleaseMutex(m_hMutex);
	return false;
	}

⌨️ 快捷键说明

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