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

📄 controldb.cpp

📁 通过穷举法和字典法对远程数据库密码进行破解
💻 CPP
字号:
// ControlDB.cpp : implementation file
//

#include "stdafx.h"
#include "UserKey.h"
#include "ControlDB.h"
#include "ObtainKey.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CControlDB property page

IMPLEMENT_DYNCREATE(CControlDB, CPropertyPage)

CControlDB::CControlDB() : CPropertyPage(CControlDB::IDD)
{
	//{{AFX_DATA_INIT(CControlDB)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CControlDB::~CControlDB()
{
}

void CControlDB::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CControlDB)
	DDX_Control(pDX, IDC_TABLELIST, m_tableList);
	DDX_Control(pDX, IDC_ADODC1, m_ado);
	DDX_Control(pDX, IDC_DATAGRID1, m_dataGrid);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CControlDB, CPropertyPage)
	//{{AFX_MSG_MAP(CControlDB)
	ON_BN_CLICKED(IDC_CONNECTDB, OnConnectdb)
	ON_LBN_SELCHANGE(IDC_TABLELIST, OnSelchangeTablelist)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CControlDB message handlers

void CControlDB::OnConnectdb() 
{
	// TODO: Add your control notification handler code here
	if(CObtainKey::GetPassword() == "")
		AfxMessageBox("请先破解数据库密码,否则对数据库的所有操作都是在本机上进行!");
	else
	{
		CString pwd = CObtainKey::GetPassword();
		CString ipAddr = CObtainKey::GetIPAddress();
		_bstr_t m_strCnt="Driver={SQL Server};server=";
		m_strCnt = m_strCnt + ipAddr;
		m_strCnt = m_strCnt + ";database=Northwind;User ID=sa;";
		m_strCnt = m_strCnt + "password="+pwd;
		CString m_strCTt=_T("SELECT * FROM sysobjects WHERE (xtype = 'u')");
		::CoInitialize(NULL);

		if (!SUCCEEDED(m_pRs.CreateInstance("ADODB.Recordset")))
		{
			AfxMessageBox("Create Instance failed!");
		}
		try
		{
			m_pRs.CreateInstance(__uuidof(Recordset));
	
			m_pRs->Open((LPCTSTR)m_strCTt,(LPCTSTR)m_strCnt,
				adOpenDynamic,adLockOptimistic,adCmdText);
			while (!m_pRs->adoEOF) 
			{
				_variant_t value = m_pRs->GetCollect("name");
				CString valueStr = (LPCTSTR)(_bstr_t)value;
				m_tableList.AddString(valueStr);
				m_pRs->MoveNext();
			}
		}
		catch(_com_error & e)
		{
			//AfxMessageBox(e.Description());
		}
	
		::CoUninitialize();	}

}

void CControlDB::OnSelchangeTablelist() 
{
	// TODO: Add your control notification handler code here
	CString table;
	for(int i=0;i<m_tableList.GetCount();++i)
		if(m_tableList.GetSel(i))
		{
			m_tableList.GetText(i,table);
		}
	CString pwd = CObtainKey::GetPassword();
	CString connectionStr ="Provider=SQLOLEDB.1;Password="+pwd+";Persist Security Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=" + CObtainKey::GetIPAddress();
	CString recordSource = "select * from "+table;
	m_ado.SetConnectionString(connectionStr);
	m_ado.SetRecordSource(recordSource);
	m_ado.Refresh();
	m_dataGrid.SetRefDataSource(m_ado.GetControlUnknown());
}

⌨️ 快捷键说明

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