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

📄 mdbpwdgetdlg.cpp

📁 Access数据库密码破解(VC++6.0)
💻 CPP
字号:
// MDBPWDGetDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MDBPWDGet.h"
#include "MDBPWDGetDlg.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()

/////////////////////////////////////////////////////////////////////////////
// CMDBPWDGetDlg dialog

CMDBPWDGetDlg::CMDBPWDGetDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMDBPWDGetDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMDBPWDGetDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
//	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON4);
}

void CMDBPWDGetDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMDBPWDGetDlg)
	DDX_Control(pDX, IDC_STATIC_PROCESSINFO, m_ProcessInfo);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMDBPWDGetDlg, CDialog)
	//{{AFX_MSG_MAP(CMDBPWDGetDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON_INPUTFILE, OnButtonInputFile)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMDBPWDGetDlg message handlers

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

//----------------------------------------------------------------------------------------------
// 这里定义的是13个字节作为Access2000异或的源码。
// Access2000的13个异或字节源码为:
// 0xa1, 0xec, 0x7a, 0x9c, 0xe1, 0x28, 0x34, 0x8a, 0x73, 0x7b, 0xd2, 0xdf, 0x50 ;
// 与之相对应的加密标志是0x13
//
// 也可以用这一组:BE EC 65 9C FE 28 2B 8A 6C 7B CD DF 4F 
// 与这一组相对应的加密标志是0x0c
//----------------------------------------------------------------------------------------------
//const char PassSource2k[13] = { 0xa1, 0xec, 0x7a, 0x9c, 0xe1, 0x28, 0x34, 0x8a, 0x73, 0x7b, 0xd2, 0xdf, 0x50 };
//const char PassSource2k01[16] = { 0xBE, 0xEC, 0x65, 0x9C, 0xFE, 0x28, 0x2B, 0x8A, 
//									0x6C, 0x7B, 0xCD, 0xDF, 0x4F, 0x13, 0xf7, 0xB1};
const char PassSource2k01[16] = { 0xBE, 0xEC, 0x65, 0x9C, 0xFE, 0x28, 0x2B, 0x8A, 0x6C, 0x7B, 0xCD, 0xDF, 0x4F };

//----------------------------------------------------------------------------------------------
// 这里定义的是13个字节作为Access97异或的源码。
// Access97的13个异或字节源码为:
// 0x86, 0xfb, 0xec, 0x37, 0x5d, 0x44, 0x9c, 0xfa, 0xc6, 0x5e, 0x28, 0xe6, 0x13 ;
// 与这一组相对应的加密标志是0x0c
//----------------------------------------------------------------------------------------------
const char PassSource97[13] = { 0x86,0xfb,0xec,0x37,0x5d,0x44,0x9c,0xfa,0xc6,0x5e,0x28,0xe6,0x13 };


void CMDBPWDGetDlg::OnButtonInputFile() 
{
	// TODO: Add your control notification handler code here
	CString szExt = "";
	CString szFilter = "Access 97/2000/2002 DataBase File(*.mdb)|*.mdb||";

	char szBuff[5120] = "";

	DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
	CFileDialog dlg(TRUE, szExt, NULL, dwFlags, szFilter, NULL);
	dlg.m_ofn.nMaxFile = 5120;
	dlg.m_ofn.lpstrFile = szBuff;
	if(dlg.DoModal() == IDCANCEL) 
		return;

	m_ProcessInfo.SetWindowText("正在读取Access数据库文件信息 !!");

	CString& strFN = dlg.GetPathName();
	SetDlgItemText(IDC_EDIT_FILENAME, strFN);

//	bool bSucc = GetMDBPassword(m_strFN);
	bool bSucc = true;
    BYTE PassStrTemp[26], Ver, EncrypFlag, t1;
    CString szMdbPassword, szMdbVersion;
	
	FILE* pFHandle = fopen(strFN, "r");
	if(pFHandle == NULL)
	{
		MessageBox("文件打开错误 !");

		bSucc = false;
	}
	else
	{
		//取得数据库版本
		fseek(pFHandle, 0x14, 0);
		fread(&Ver, 1, 1, pFHandle);

		//取得加密标志
		fseek(pFHandle, 0x62, 0);
		fread(&EncrypFlag, 1, 1, pFHandle);


		//读取加密后的密码到缓冲区
		fseek(pFHandle, 0x42, 0);
		fread(&PassStrTemp, 26, 1, pFHandle);

		fclose(pFHandle);
		
		if(Ver < 0X01)
		{
			szMdbVersion = "Access 97";
			if(int(PassStrTemp[0] ^ PassSource97[0]) == 0)
				szMdbPassword="密码为空!";
			else
			{
				szMdbPassword = "";
				for(int j = 0; j < 13; j++)
				{
					szMdbPassword = szMdbPassword + CString(PassStrTemp[j] ^ PassSource97[j]);
				}
			}
		}
		else
		{
			szMdbVersion = "Access 2000/2002";
			szMdbPassword = "";
			for(int j = 0; j < 13; j++)
			{
				if(j % 2 == 0)
				{
//					t1 = BYTE(0x13 ^ EncrypFlag ^ PassStrTemp[j * 2] ^ (BYTE)PassSource2k[j]);
					t1 = BYTE(0x0C ^ EncrypFlag ^ PassStrTemp[j * 2] ^ (BYTE)PassSource2k01[j]);
				}
				else	//每隔一个字节就与加密标志相异或。这里的加密标志为0x13 或者0x0C。
 				{
				   t1 = BYTE(PassStrTemp[j * 2] ^ (BYTE)PassSource2k01[j]);
				}

				szMdbPassword = szMdbPassword + CString(t1);
			}
		}
		if(szMdbPassword[1] < 0x20 || szMdbPassword[1] > 0x7e)
			szMdbPassword = "密码为空!";
		
//		SetDlgItemText(IDC_EDIT_FILENAME, szFN);
		SetDlgItemText(IDC_EDIT_PASSWORD, szMdbPassword);
		SetDlgItemText(IDC_STATIC_VERSION, szMdbVersion);
	}
	
	if(bSucc)
		m_ProcessInfo.SetWindowText("Access数据库文件解密成功 !!");
	else
		m_ProcessInfo.SetWindowText("Access数据库文件解密失败 !!");
}

⌨️ 快捷键说明

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