C#Access database tool and password cracking modification
- 1. Trouble encountered by mdb files
-
- Easy to develop, hard to read data
- 2. Benchmark Microsoft Access functions
-
- 2.1 Addition, deletion, modification and query of Access database files
- 2.2 The interface is easy to operate, just like adding, deleting, modifying and checking in Excell
- 2.3 A single exe tool, no installation or environment required
- 2.4 Crack the password and change the password
- 2.5 Can this still be benchmarked against SQL Server
- 3. Detailed design
-
- 3.1 Main program code
- 3.2 Password Operation
- 4. How familiar do you see
- 5. Download evaluation
- 6. Single-line contact information
A program without data is a program without a soul, and a program without a database may be very NB. The types of databases have been answered during the interview. The larger ones need an environment, and the smaller ones are not easy to debug. Whoever uses them will know. As the native database of Windows, the components are integrated into the system, and the tools are integrated into Office. The core is in the file with the suffix “mdb”. Table data computer thinking,
1. Trouble encountered in mdb file
Easy to develop, but difficult to read data
If Access in the Microsoft family bucket is not installed on the running computer, the data in the mdb file cannot be seen and cannot be edited. Since it is from Microsoft, it should be possible to develop a simple access database tool to realize simple addition, deletion, modification and query, as well as password cracking
2. Benchmark Microsoft Access features
2.1 Addition, deletion, modification and query of Access database files
Connection string, select, delete, insert, update
2.2 The interface is easy to operate, just like adding, deleting, modifying and checking in Excel
DataGridView is king. Double-click to select table, can generate connection string, various sorting, copy column fields, custom filter conditions, batch update table, display the row and column index of the operation, right-click to set which columns to display, like Sql server Editing the first two hundred lines is the same as editing and adding
2.3 A single exe tool, no installation or environment required
Focus, the environment here is the framework environment, with the lowest 2.0, xp can also be used
2.4 Crack the password, change the password
it’s actually really easy
2.5 Can this be used against SQL Server
The function is exactly the same, but the string connection is different, please leave a message if you are interested
3. Detailed design
3.1 Main program code
using System; using System.Data; using System.Data.OleDb; using System.Data.SqlClient; using System. Drawing; using System.IO; using System. Reflection; using System. Windows. Forms; using RegisterSpace; namespace tempJH0116 {<!-- --> public partial class Form1 : Form {<!-- --> string strDBConn = ""; OleDbDataAdapter DBAdapter; OleDbConnection OleConn; DataTable tbDBSource = new DataTable(); BindingSource bs = new BindingSource();//data source Label labelX; public Form1() {<!-- --> InitializeComponent(); InitX(); OpenControlDoubleBuffered(dataGridView1); OpenControlDoubleBuffered(splitter1); if (Program. strDropFilePath != null) {<!-- --> txtFilePath.Text = Program.strDropFilePath; } } private void Form1_FormClosing(object sender, FormClosingEventArgs e) {<!-- --> if (MessageBox.Show("Exit the database editor, are you sure?", "Prompt", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) {<!-- --> } else {<!-- --> e. Cancel = true; } } private void btnLink_Click(object sender, EventArgs e) {<!-- --> string filePath = txtFilePath. Text; string password = txtPwd. Text; try {<!-- --> strDBConn = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={<!-- -->filePath};Persist Security Info=False;Jet OLEDB:Database Password={<!-- -->password }"; OleConn = new OleDbConnection(strDBConn); OleConn. Open(); } catch (Exception) {<!-- --> MessageBox.Show("File configuration error!"); return; } txtLinkStr.Text = strDBConn; DataTable tbDB = OleConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] {<!-- --> null, null, null, "TABLE" }); tbDB.DefaultView.Sort = "TABLE_NAME ASC"; tbDB = tbDB. DefaultView. ToTable(); dataGridView1.DataSource = tbDB; treeList. Nodes. Clear(); for (int i = 0; i < tbDB. Rows. Count; i ++ ) {<!-- --> treeList.Nodes.Add(tbDB.Rows[i][2].ToString()); } txtPwd. ReadOnly = true; btnLink. Enabled = false; btnGetPwd. Enabled = false; txtFilePath. AllowDrop = false; string name = txtFilePath.Text.Substring(txtFilePath.Text.LastIndexOf('\') + 1); txtDBName.Text = name; } private void treeList_DoubleClick(object sender, EventArgs e) {<!-- --> txtFilter.Text = ""; TreeNode selectTable = treeList. SelectedNode; //if (selectTable.Level != 1) return; txtTableName.Text = selectTable.Text; txtShow.Text = "【" + selectTable.Text + "】"; string strAllTable = $"Select * From [{<!-- -->txtTableName.Text}]"; DBAdapter = new OleDbDataAdapter(strAllTable, OleConn);//【】No database name is required txtStrExec.Text = strAllTable; //txtLinkStr.Text = strDBConn; tbDBSource = new DataTable(); DBAdapter. Fill(tbDBSource); bs.DataSource = tbDBSource; man.BindingSource = bs; dataGridView1.DataSource = bs; txtInfo.Text = $"A total of {<!-- -->tbDBSource.Rows.Count} rows/a total of {<!-- -->tbDBSource.Columns.Count} columns"; cbAllowEdit. Checked = false; cbAllowEdit_CheckedChanged(null, null); cbAllowSort. Checked = false; cbAllowSort_CheckedChanged(null, null); } private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) {<!-- --> if (dataGridView1. CurrentCell == null) return; dataGridView1. BeginEdit(true); DataGridViewCell d = dataGridView1. CurrentCell; string col = d.OwningColumn.HeaderText; txtFilter.Text = col + "='" + d.Value.ToString() + "'"; txtStatusNow.Text = $"Current cell index ({<!-- -->d.RowIndex}, {<!-- -->d.ColumnIndex})"; } private void cbAllowEdit_CheckedChanged(object sender, EventArgs e) {<!-- --> dataGridView1.ReadOnly = !cbAllowEdit.Checked; btnSave.Enabled = cbAllowEdit.Checked; if (cbAllowEdit. Checked) cbAllowEdit.ForeColor = Color.Red; else cbAllowEdit. ForeColor = DefaultForeColor; } private void cbAllowSort_CheckedChanged(object sender, EventArgs e) {<!-- --> if (cbAllowSort. Checked) {<!-- --> for (int i = 0; i < dataGridView1. Columns. Count; i ++ ) {<!-- --> dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic; } } else {<!-- --> for (int i = 0; i < dataGridView1. Columns. Count; i ++ ) {<!-- --> dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.Programmatic; } tbDBSource = tbDBSource. Copy(); bs.DataSource = tbDBSource; dataGridView1.DataSource = bs;//Cancel sorting effect } } private void btnFilter_Click(object sender, EventArgs e) {<!-- --> //tbDBSource.DefaultView.RowFilter = txtFilter.Text; bs.Filter = txtFilter.Text; } private void splitter1_Click(object sender, EventArgs e) {<!-- --> groupBox2.Visible = !groupBox2.Visible; if (!groupBox2.Visible) {<!-- --> splitter1.Cursor = Cursors.PanEast; this.toolTip1.SetToolTip(this.splitter1, "Click to display Object Explorer"); } else {<!-- --> splitter1.Cursor = Cursors.VSplit; this.toolTip1.SetToolTip(this.splitter1, "Click to hide the object explorer"); } } private void btnSave_Click(object sender, EventArgs e) {<!-- --> tbDBSource = (DataTable)bs.DataSource; if (tbDBSource. GetChanges() == null) return; OleDbCommandBuilder sqlCommandBuilder = new OleDbCommandBuilder(DBAdapter); int nowCount = 0; try {<!-- --> nowCount = DBAdapter. Update(tbDBSource); } catch (Exception ee) {<!-- --> MessageBox. Show(ee. Message); } MessageBox.Show("updated" + nowCount.ToString() + "line data!"); //tbDBSource.AcceptChanges(); dataGridView1. Refresh(); } private void set column ToolStripMenuItem_Click(object sender, EventArgs e) {<!-- --> FormColumnFilter formColumnFilter = new FormColumnFilter(); formColumnFilter.InitUI(dataGridView1); formColumnFilter. ShowDialog(); } public void OpenControlDoubleBuffered(Control ctr) {<!-- --> Type type = ctr. GetType(); PropertyInfo pi = type. GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic); pi. SetValue(ctr, true, null); } public void InitX() {<!-- --> labelX = new Label(); labelX.Text = "×"; toolTip1.SetToolTip(labelX, "Cancel filter conditions"); labelX. AutoSize = true; labelX.ForeColor = Color.Red; labelX.Dock = DockStyle.Right; labelX.Cursor = Cursors.Hand; labelX.Click += ClearText; txtFilter.Controls.Add(labelX); txtFilter_TextChanged(null, null); //textBox1_TextChanged(null, null); } public void ClearText(object sender, EventArgs e) {<!-- --> txtFilter.Text = ""; btnFilter_Click(null, null); } private void txtFilter_TextChanged(object sender, EventArgs e) {<!-- --> if (txtFilter. TextLength > 0) labelX.Visible = true; else labelX.Visible = false; } private void dataGridView1_SelectionChanged(object sender, EventArgs e) {<!-- --> dataGridView1_CellClick(null, null); } private void txtFilePath_DragDrop(object sender, DragEventArgs e) {<!-- --> txtFilePath.Text = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString(); } private void txtFilePath_DragEnter(object sender, DragEventArgs e) {<!-- --> if (e.Data.GetDataPresent(DataFormats.FileDrop)) {<!-- --> //If the dragged in is a file type if (e.Data.GetDataPresent(DataFormats.FileDrop)) {<!-- --> string[] paths = e.Data.GetData(DataFormats.FileDrop) as string[]; // get the dragged path string path = paths[0]; //Path string length is not empty if (path. Length > 1) {<!-- --> // Determine if it is a folder FileInfo fil = new FileInfo(path); if (fil.Attributes == FileAttributes.Directory)//folder {<!-- --> //mouse icon link e.Effect = DragDropEffects.None; } else//file {<!-- --> //mouse icon disabled e. Effect = DragDropEffects. Link; } } } else {<!-- --> e.Effect = DragDropEffects.None; } } } private void btnGetPwd_Click(object sender, EventArgs e) {<!-- --> FormPwd f = new FormPwd(); f.Tag = txtFilePath.Text; f.ShowDialog(); } } }
3.2 Password operation
private static string GetPassword(string file) {<!-- --> // Unencrypted file 0x42 to 0x61 before the value of each interval byte byte[] baseByte = {<!-- --> 0xbe, 0xec, 0x65, 0x9c, 0xfe, 0x28, 0x2b, 0x8a, 0x6c, 0x7b, 0xcd, 0xdf, 0x4f, 0x13, 0xf7, 0xb1, }; byte flagByte = 0x0c; // value at flag 0x62 string password = ""; try {<!-- --> FileStream fs = File. OpenRead(file); fs.Seek(0x14, SeekOrigin.Begin); byte ver = (byte)fs.ReadByte(); // Get version, 1 is Access2000, 0 is Access97 fs.Seek(0x42, SeekOrigin.Begin); byte[] bs = new byte[33]; if (fs. Read(bs, 0, 33) != 33) return ""; byte flag = (byte)(bs[32] ^ flagByte); for (int i = 0; i < 16; i ++ ) {<!-- --> byte b = (byte)(baseByte[i] ^ bs[i * 2]); if (i % 2 == 0 & amp; & amp; ver == 1) b ^= flag; //Access 2000 if (b > 0) password + = (char)b; } fs. Dispose(); } catch {<!-- --> } return password; } private void UpdatePwd() {<!-- --> string filePath = Tag. ToString(); string strDBConn = $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={<!-- -->filePath};Persist Security Info=False;Mode=12;Jet OLEDB:Database Password={<!- - -->txtOld.Text}"; OleDbConnection OleConn = new OleDbConnection(strDBConn); OleConn. Open(); string newPwd = txtNew. Text; string oldPwd = txtOld. Text; string strExe = $"ALTER DATABASE PASSWORD " + newPwd + " " + oldPwd; OleDbCommand cmd = new OleDbCommand(strExe, OleConn); int count = cmd.ExecuteNonQuery();//password is text type OleConn.Close(); }
4. How familiar are you?
5. Download reviews
to be reviewed
6. Single-line contact
[email protected], this mailbox only accepts and does not reply, and the code master uses other mailboxes for reply letters, only sending but not receiving. –Anti-investigation Lianxuan