获取ACCESS2000密码 [C#]

Access 的一些早期版本使用异或方法进行简单加密,当忘记密码时可以用同样的办法进行恢复.

以Access2000版本为例,从42H字节开始的后40字节为unicode存储的密码信息,与字节组

0x0b,0x6d ,0xec ,0x37 ,0xd0 ,0xd2 ,0x9c ,0xfa ,0x4b ,0xc8 ,0x28 ,0xe6 ,0x9e ,0x20 ,0x8a ,

0x60 ,0xd9 ,0x02 ,0x7b ,0x36 ,0x78 ,0xe4 ,0xdf ,0xb1 ,0xfa ,0x62 ,0x13 ,0x43 ,0x42 ,0x39 ,

0xb1 ,0x33 ,0xb9 ,0xf7 ,0x79 ,0x5b ,0x1f ,0x23 ,0x7c ,0x2c

异或后即可还原.上述密钥字节组可通过新建ACCESS文件后查看得知.

Access是以轻量化为目的设计的数据库,在重要应用中应该采用更专业的数据库产品,如Microsoft SQL Server.

以下以C#为例,说明获取Access2000密码的方法. 注意:解密结果应用Unicode解码输出,以保证正常显示.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication1
{
 /// <summary>
 /// Form1 的摘要说明。
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
  private System.Windows.Forms.Button button1;
  private System.Windows.Forms.TextBox textBox1;
  private System.Windows.Forms.Button button2;
  private System.Windows.Forms.TextBox textBox2;
  private System.Windows.Forms.OpenFileDialog openFileDialog1;
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;

  public Form1()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows Form Designer generated code
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
   this.button1 = new System.Windows.Forms.Button();
   this.textBox1 = new System.Windows.Forms.TextBox();
   this.button2 = new System.Windows.Forms.Button();
   this.textBox2 = new System.Windows.Forms.TextBox();
   this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
   this.SuspendLayout();
   //
   // button1
   //
   this.button1.Location = new System.Drawing.Point(24, 80);
   this.button1.Name = "button1";
   this.button1.Size = new System.Drawing.Size(232, 88);
   this.button1.TabIndex = 0;
   this.button1.Text = "解";
   this.button1.Click += new System.EventHandler(this.button1_Click);
   //
   // textBox1
   //
   this.textBox1.Location = new System.Drawing.Point(24, 16);
   this.textBox1.Name = "textBox1";
   this.textBox1.ReadOnly = true;
   this.textBox1.Size = new System.Drawing.Size(376, 21);
   this.textBox1.TabIndex = 1;
   this.textBox1.Text = "";
   //
   // button2
   //
   this.button2.Location = new System.Drawing.Point(408, 16);
   this.button2.Name = "button2";
   this.button2.Size = new System.Drawing.Size(88, 24);
   this.button2.TabIndex = 2;
   this.button2.Text = "浏览";
   this.button2.Click += new System.EventHandler(this.button2_Click);
   //
   // textBox2
   //
   this.textBox2.Location = new System.Drawing.Point(24, 48);
   this.textBox2.Name = "textBox2";
   this.textBox2.Size = new System.Drawing.Size(272, 21);
   this.textBox2.TabIndex = 3;
   this.textBox2.Text = "";
   //
   // Form1
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(640, 181);
   this.Controls.AddRange(new System.Windows.Forms.Control[] {
                    this.textBox2,
                    this.button2,
                    this.textBox1,
                    this.button1});
   this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
   this.Name = "Form1";
   this.Text = "解";
   this.ResumeLayout(false);

  }
  #endregion

  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main()
  {
   Application.Run(new Form1());
  }

  private void button2_Click(object sender, System.EventArgs e)
  {
   if(this.openFileDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK)
   {
    this.textBox1.Text=this.openFileDialog1.FileName;
    this.textBox2.Text ="";
   }
  }

  private void button1_Click(object sender, System.EventArgs e)
  {
  
           
   
   try
   {
    this.textBox2.Text =getPassWord2000(this.textBox1.Text);
   }
   catch(System.Exception ee)
   {
    System.Windows.Forms.MessageBox.Show(ee.Message);
   }


  }

  //
  public static string getPassWord2000(string FilePath)
  {
   byte[] key={0x0b,0x6d ,0xec ,0x37 ,0xd0 ,0xd2 ,0x9c ,0xfa ,0x4b ,0xc8 ,0x28 ,0xe6 ,0x9e ,0x20 ,0x8a ,0x60 ,0xd9 ,0x02 ,0x7b ,0x36 ,0x78 ,0xe4 ,0xdf ,0xb1 ,0xfa ,0x62 ,0x13 ,0x43 ,0x42 ,0x39 ,0xb1 ,0x33 ,0xb9 ,0xf7 ,0x79 ,0x5b ,0x1f ,0x23 ,0x7c ,0x2c};

   string result="";
           
   System.Exception ex;
   try
   {
    if(FilePath.Trim()=="")
    {
     ex=new Exception("未选定文件");
    }
    else if(System.IO.File.Exists(FilePath.Trim()))
    {
     ex=new Exception("文件不存在");
    }
   

    System.IO.BinaryReader br=new System.IO.BinaryReader(new System.IO.FileStream(FilePath.Trim(),System.IO.FileMode.Open));
    byte[] db=new byte[40];
    int ix=0;
    while((ix++)<0x42)
    {
     br.ReadByte();
    }
   
    db=br.ReadBytes(40);
     
    br.Close();

   
    for(int i=0;i<40;i++)
    {
    
     byte b=(byte)(db[i]^key[i]);
     db[i]=b;
                   
    }
   
    System.IO.MemoryStream m=new System.IO.MemoryStream(db,0,40,false,true);
   
   

    System.IO.StreamReader s=new System.IO.StreamReader(m,System.Text.Encoding.Unicode);    
           
   

    result =s.ReadToEnd();

   
    s.Close();
    m.Close();

   }
   catch(System.Exception ee)
   {
    throw ee;
   }

   return result;
  }

 }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
首先,你需要在你的Access数据库中创建一个表来存储用户信息,包括用户名和密码。然后,在C#中创建一个Windows窗体应用程序,设计登录界面并添加用户名和密码输入框以及登录按钮。在登录按钮的Click事件处理程序中,你需要通过ADO.NET连接Access数据库并查询用户信息表来验证用户输入的用户名和密码是否正确。如果验证通过,则登录成功,否则登录失败并提示用户。 以下是一个简单的示例代码,仅供参考: ```csharp using System.Data.OleDb; // 连接Access数据库 string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=your_database_path"; private void btnLogin_Click(object sender, EventArgs e) { // 获取用户输入的用户名和密码 string username = txtUsername.Text.Trim(); string password = txtPassword.Text.Trim(); // 构建查询语句 string sql = "SELECT * FROM Users WHERE Username=@Username AND Password=@Password"; using (OleDbConnection connection = new OleDbConnection(connectionString)) { connection.Open(); using (OleDbCommand command = new OleDbCommand(sql, connection)) { command.Parameters.AddWithValue("@Username", username); command.Parameters.AddWithValue("@Password", password); using (OleDbDataReader reader = command.ExecuteReader()) { if (reader.HasRows) { // 登录成功 MessageBox.Show("登录成功!"); } else { // 登录失败 MessageBox.Show("用户名或密码错误!"); } } } } } ``` 请注意,这只是一个简单的示例代码,实际上你还需要进行一些额外的安全性检查和错误处理。另外,建议使用哈希函数等技术来保护用户密码的安全。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值