您好,欢迎访问一九零五行业门户网

账号密码管理系统Access版本

哈哈,花了我整整五天时间, 账号 密码 管理 系统 软件终于成功编写完成了。由于我的各大论坛的 账号 密码 特别多,记性又不好。所以一直以来都想要这么一个软件的,但是以前学习的都是面向过程的编程语言,一直无法实现这个想法。这个暑假为了做一个程序项
哈哈,花了我整整五天时间,账号密码管理系统软件终于成功编写完成了。由于我的各大论坛的账号密码特别多,记性又不好。所以一直以来都想要这么一个软件的,但是以前学习的都是面向过程的编程语言,一直无法实现这个想法。这个暑假为了做一个程序项目,对记事本实现图形用户界面增删改查操作,所以开始学习c#编程。在花了整整二十天学习winform编程和研究文件读写流(大多数时间在学习文件读写流上,winform编程也就学会了几个常用的控件,文件读写流这个边读边写刚开始不会,特别蛋疼),好在经过一番努力学习后终于实现了。在完成这个后,突然想起一直以来想要的这个软件,于是开始动手编写,在快开学的这五天内,简单匆忙简单学习了下winform数据库编程(账号密码想法是放在数据库里比较好)。编写这个软件刚开始使用的sql server数据库,但是当我花了三天左右完成时,才发现竟然蛋疼的无法脱机使用。查了资料后知道了用access数据库可以实现脱机使用。而且之前用过的御剑、啊d、明小子之类渗透软件也大都是用的access数据库,可移植性很好。因此只好开始又想法将sql server更换成access数据库。不停地在百度上转啊转,搞了半天才知道更换也很简单,只要将连接数据库语句更换下,再把sql换成oledb即可。更换期间也出了很多未知的蛋疼的问题,编译器查不出来哪里的问题,代码页看出出来哪里不对。搞了半天才知道原来数据库名称和字段名称不小心和access数据库中关键词冲突了。不过不管怎么说,终于搞定了。但是完成后安全性还是个问题,那么多账号密码明文存放access数据库,那也太不安全了。因此又开始给程序增加加密算法。菜鸟学艺不精,而且时间有限,只好直接引用现成的加密算法了,程序界面登陆不需要查看账号密码,因此最后考虑后采用了单向加密的md5 32位加密算法加密,而数据库内存储的账号密码信息信息还需要显示出来,而md5虽然安全但是不可逆,只能加密对比后台登陆使用,因此最终采用了des加密算法和md5混合加密的方法,当然加密算法是我copy的,我是菜鸟还没那个本事自己编写。
     嘿嘿。废话说了一大堆,现在开始言归正传。
  由于在下 的各种论坛账号密码特别多,记性又不好,为了方便账号密码的管理而编写的这个小软件。
使用说明:
1. 本程序由本人星云用winform编程+access数据库编写;(程序运行需安装有.net2.0环境和access软件)
2.登陆界面有四次登陆机会,连续四次登陆四次错误,程序将会锁定禁止使用,防止密码被暴力破解。
3.解锁方法:
用户名+秘钥:用户提供修改后的用户名配合本人在程序中设置的一个秘钥才可以解锁。(缺一不可。)
4.登陆界面账号密码初始密码都为:root,采用不可逆的单向加密md5加密算法进行加密.
5.为了账号安全,请登陆后后立即点击系统维护按钮,进入登陆密码修改界面。
6.为了防止直接打开access数据库文件,对此打开进行了数据库密码设置,密码采用不可逆的md5加密。
7.关于软件是否开源问题,考虑后觉得“交流即分享,分享才能进步“,因此最终决定开源,况且这也没什么技术含量。
8.源码公开后软件账号密码安全性问题,在下决定在源码中对程序中涉及到的关键敏感密码处加以更改。
程序截图:
查询方式有两种,下拉菜单查询以及搜索查询。
基本功能添加修改删除
系统维护界面:
软件下载地址:http://pan.baidu.com/s/1i3uuckh 密码:7u2y
文章中的公开项目源码下载:http://pan.baidu.com/s/1qwns3bu 密码:s05u
程序源码:
form窗体1如下:
using system;using system.windows.forms;using system.data.oledb;using system.security.cryptography;using system.text;namespace 账号密码管理系统1._0{ public partial class form1 : form { public form1() { initializecomponent(); } //登陆错误时调用此函数:错误次数加一 private void incerrortimes() { //与数据库建立连接 string connectionstring = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改。; { using (oledbconnection conn = new oledbconnection(connectionstring)) { conn.open();//打开连接 //创建数据库命令语句,更新错误次数加一 using (oledbcommand updatecmd = conn.createcommand()) { updatecmd.commandtext = update t_system set errortimes=errortimes+1 where sys_username=@name; updatecmd.parameters.add(new oledbparameter(name, textbox1.text)); updatecmd.executenonquery(); } } } } //登陆成功时调用此函数:重置错误次数 private void reseterrotimes() { //与数据库建立连接 string connectionstring = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改。; { using (oledbconnection conn = new oledbconnection(connectionstring)) { conn.open();//打开连接 //创建数据库命令语句 using (oledbcommand updatecmd = conn.createcommand()) { updatecmd.commandtext = update t_system set errortimes=0 where sys_username=@name; updatecmd.parameters.add(new oledbparameter(name, textbox1.text)); updatecmd.executenonquery(); } } } } //秘钥清除使用 private void recovererrotimes() { //与数据库建立连接 string connectionstring = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改。; { using (oledbconnection conn = new oledbconnection(connectionstring)) { conn.open();//打开连接 //创建sql命令语句,重置错误次数为0 using (oledbcommand updatecmd = conn.createcommand()) { updatecmd.commandtext = update t_system set errortimes=0 where sys_username=@name; updatecmd.parameters.add(new oledbparameter(name, textbox1.text)); updatecmd.executenonquery(); } //创建sql命令语句,恢复默认密码为root using (oledbcommand updatecmd = conn.createcommand()) { updatecmd.commandtext = update t_system set sys_password='63a9f0ea7bb98050796b649e85481845' where sys_username=@name; updatecmd.parameters.add(new oledbparameter(name, textbox1.text)); updatecmd.executenonquery(); } } } } //当单击登陆按钮时执行以下事件处理程序 private void button1_click(object sender, eventargs e) { //与数据库建立连接 string connectionstring = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改。; { using (oledbconnection conn = new oledbconnection(connectionstring)) { conn.open();//打开连接 //创建sql命令语句 using (oledbcommand cmd = conn.createcommand()) { cmd.commandtext = select * from t_system where sys_username=@name; cmd.parameters.add(new oledbparameter(name, getmd5(textbox1.text))); //读取数据库查询结果进行用户名和密码判断 using (oledbdatareader reader = cmd.executereader()) { if (reader.read())//用户名输入正确 { int errortimes = reader.getint32(reader.getordinal(errortimes)); if (errortimes > 3) { if (textbox2.text == 解锁 秘钥字符串,此处已经修改) { recovererrotimes(); messagebox.show(程序解锁成功,程序即将重新启动!); application.exit(); return; } else { messagebox.show(密码错误次数太多,程序已经被锁定禁用!); application.exit(); return; } } string dbpassword = reader.getstring(reader.getordinal(sys_password)); if (dbpassword == getmd5(textbox2.text))//登陆成功! { reseterrotimes();//登陆成功,错误次数清零 form2 fm2 = new form2(); this.hide(); fm2.show(); } else { messagebox.show(登陆失败!); incerrortimes(); } } else //用户输入错误 { messagebox.show(用户名不存在!); } } } } } } //md5加密算法 public static string getmd5(string str) { md5 md5 = md5.create(); byte[] buffer = encoding.default.getbytes(str); byte[] md5buffer = md5.computehash(buffer); string strnew = ; for (int i = 0; i ) { strnew += md5buffer[i].tostring(x2); } return strnew; } // private void label4_click(object sender, eventargs e) { string information = \t欢迎使用账号密码管理系统\n\n1.初始账号:root 密码: root \n\n2.登陆后请立即修改登陆账号和密码\n\n3.账号和密码打死也不能忘记和告诉其他人\n\n4.连续登陆错误次数多于4次,此程序将会被锁定禁用\n\n5.解锁需要用户和作者合作才能解锁成功!\n\n6.用户需提供用户名,作者提供清除错误次数秘钥,\n\n还原默认密码合作才能完成\n\n6.为了防止密码暴力破解以及系统锁定后无法使用,\n\n作者掌握清除错误次数和还原系统默认密码秘钥,但无法修改登陆账号\n\n因此如果登陆账号也忘记,作者也回天无力。\n\n7.联系作者:xingyun2684@gmail.com; messagebox.show(null, information, 使用说明:); } //当单击重置按钮时执行以下事件处理程序 private void button2_click(object sender, eventargs e) { textbox1.text = ; textbox2.text = ; } }}
form2窗体源码:
using system;using system.windows.forms;using system.data.sqlclient;using system.data.oledb;using system.security.cryptography;using system.text;using system.io;namespace 账号密码管理系统1._0{ public partial class form2 : form { public form2() { initializecomponent(); //combox1 下拉条内容初始化 /**********************************************************/ //与数据库建立连接 string connectionstring = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改。; { using (oledbconnection conn = new oledbconnection(connectionstring)) { conn.open();//打开连接 //创建sql命令语句 using (oledbcommand cmd = conn.createcommand()) { //sql查询语句 cmd.commandtext = select account_type from t_users; //读取查询结果内容 using (oledbdatareader reader = cmd.executereader()) { while (reader.read()) { combobox1.items.add((reader.getstring(reader.getordinal(account_type)))); } } } } } /*********************************************************/ } /************************************************************************* * * 算法加密模块 * * 登陆账号密码采用md5加密算法进行加密。 * * 信息内容采用 des加密算法+md5混合加密算法 * * 所有账号信息将调用此函数进行数据加密 * * 调用方法:encryptdes(string 明文字符串, string 秘钥字符串); * * decryptdes(string 密文字符串, string 秘钥字符串); * * *********************************************************************/ //des普通加密解密算法 // des加密字符串 private static byte[] keys = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef }; /************************************************************************ * * 解密函数:decryptdes(string 密文字符串, string 秘钥字符串); * * encryptstring 待加密的字符串 * * encryptkey 加密密钥,要求为8位 * * 加密返回值 加密后的字符串,失败返回源串 * * ***************************************************************************/ public static string encryptdes(string encryptstring, string encryptkey) { try { byte[] rgbkey = encoding.utf8.getbytes(encryptkey.substring(0, 8)); byte[] rgbiv = keys; byte[] inputbytearray = encoding.utf8.getbytes(encryptstring); descryptoserviceprovider dcsp = new descryptoserviceprovider(); memorystream mstream = new memorystream(); cryptostream cstream = new cryptostream(mstream, dcsp.createencryptor(rgbkey, rgbiv), cryptostreammode.write); cstream.write(inputbytearray, 0, inputbytearray.length); cstream.flushfinalblock(); return convert.tobase64string(mstream.toarray()); } catch { return encryptstring; } } /* *********************************************************************************/ /* des解密函数 decryptdes(string 密文字符串, string 秘钥字符串); * * decryptstring : 待解密的字符串 * * decryptkey : 解密密钥,要求为8位,和加密密钥相同 * * 返回值: 解密成功返回解密后的字符串,失败返源串 * ************************************************************************************/ public static string decryptdes(string decryptstring, string decryptkey) { try { byte[] rgbkey = encoding.utf8.getbytes(decryptkey); byte[] rgbiv = keys; byte[] inputbytearray = convert.frombase64string(decryptstring); descryptoserviceprovider dcsp = new descryptoserviceprovider(); memorystream mstream = new memorystream(); cryptostream cstream = new cryptostream(mstream, dcsp.createdecryptor(rgbkey, rgbiv), cryptostreammode.write); cstream.write(inputbytearray, 0, inputbytearray.length); cstream.flushfinalblock(); return encoding.utf8.getstring(mstream.toarray()); } catch { return decryptstring; } } //添加数据/**************************************************************************/ private void button1_click(object sender, eventargs e) { // 1. 判断是否数据库内已经有该条记录 /*****************************************************************/ //与数据库建立连接 string connectionstring = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改。; { using (oledbconnection conn2 = new oledbconnection(connectionstring)) { conn2.open();//打开连接 //创建sql命令语句 using (oledbcommand cmd = conn2.createcommand()) { //sql查询语句加密后查询 cmd.commandtext = select account_type from t_users where account_type=' + textbox1.text + '; //读取查询结果内容 using (oledbdatareader reader = cmd.executereader()) { if (reader.read())//如果存在 { messagebox.show(对不起,同一类型的账号只能添加一次!, 添加失败提示); //清空内容 textbox1.text = ; textbox2.text = ; textbox3.text = ; textbox4.text = ; textbox5.text = ; return; } else //数据库中不存在此类型账号则将其添加 { // 更新combox 下拉选项 combobox1.items.add(textbox1.text); //添加信息插入到数据库内 /***********************************************************************/ //与数据库建立连接 string connectionstring2 = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改; { using (oledbconnection conn = new oledbconnection(connectionstring2)) { conn.open();//打开连接 //创建sql命令语句,添加内容都将会调用md5算法进行加密,然后保存到数据库内。 using (oledbcommand insert_cmd = conn.createcommand()) { //sql查询语句 insert_cmd.commandtext = insert into t_users (account_type,account_website,account_username,account_password)values(' + textbox1.text + ',' + encryptdes(textbox2.text, 信息md5加密字符串) + ',' + encryptdes(textbox3.text, 信息md5加密字符串) + ',' + encryptdes(textbox4.text, 信息md5加密字符串) + ');; insert_cmd.executenonquery(); } } /**************************************************/ textbox1.text = ; textbox2.text = ; textbox3.text = ; textbox4.text = ; textbox5.text = ; messagebox.show(插入成功!, 插入提示); } } } } } } } /************************************************************************/ //修改更新数据实现/***********************************************************/ private void button2_click(object sender, eventargs e) { //判断是否库中是否有此记录,有才可以修改。 /************************************************************/ //与数据库建立连接 string connectionstring = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改; { using (oledbconnection conn = new oledbconnection(connectionstring)) { conn.open();//打开连接 //创建sql命令语句 using (oledbcommand cmd = conn.createcommand()) { //sql查询语句 cmd.commandtext = select account_type from t_users where account_type=' + textbox1.text + ';; //读取查询结果内容 using (oledbdatareader reader = cmd.executereader()) { if (reader.read()) { //与数据库建立连接 string connectionstring2 = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改; { using (oledbconnection conn2 = new oledbconnection(connectionstring2)) { conn2.open();//打开连接 //创建sql命令语句 using (oledbcommand modify_cmd = conn2.createcommand()) { //sql查询语句 modify_cmd.commandtext = update t_users set account_website=' + encryptdes(textbox2.text, 信息md5加密字符串) + ',account_username=' + encryptdes(textbox3.text, 信息md5加密字符串) + ',account_password=' + encryptdes(textbox4.text, 信息md5加密字符串) + ' where account_type=' + textbox1.text + ';; modify_cmd.executenonquery(); //修改成功清空内容 textbox1.text = ; textbox2.text = ; textbox3.text = ; textbox4.text = ; textbox5.text = ; messagebox.show(修改成功!, 修改提示); } } } } else { messagebox.show(数据库内没有该账号类型,无法修改!, 修改失败提示); return; } } } } } } /*********************************************************/ /***********************************************************/ //删除数据实现/********************************************************/ private void button3_click(object sender, eventargs e) { /**********************************************************/ //与数据库建立连接 string connectionstring = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改; { using (oledbconnection conn = new oledbconnection(connectionstring)) { conn.open();//打开连接 //创建sql命令语句 using (oledbcommand cmd = conn.createcommand()) { //sql查询语句 cmd.commandtext = select account_type from t_users where account_type=' + textbox1.text + ';; //读取查询结果内容 using (oledbdatareader reader = cmd.executereader()) { if (reader.read())//存在该条记录 { //执行删除操作 /*********************************************************/ //与数据库建立连接 string connectionstring2 = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改; { using (oledbconnection conn2 = new oledbconnection(connectionstring2)) { conn2.open();//打开连接 //创建sql命令语句 using (oledbcommand delete_cmd = conn2.createcommand()) { //sql查询语句 delete_cmd.commandtext = delete from t_users where account_type=' + textbox1.text+ ';; delete_cmd.executenonquery(); } } } //删除此combox选项 if (combobox1.text == textbox1.text) { combobox1.items.remove(combobox1.text); } //删除成功清空内容 textbox1.text = ; textbox2.text = ; textbox3.text = ; textbox4.text = ; textbox5.text = ; messagebox.show(删除成功!, 删除成功提示); } else { messagebox.show(删除失败!, 删除失败提示); return; } } } } } }/**************************************************************/ //清空/*************************************************************************/ private void button6_click(object sender, eventargs e) { textbox1.text = ; textbox2.text = ; textbox3.text = ; textbox4.text = ; textbox5.text = ; }/*************************************************************************/ //关键词搜索 private void button4_click(object sender, eventargs e) { //与数据库建立连接 string connectionstring = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改; { using (oledbconnection conn = new oledbconnection(connectionstring)) { conn.open();//打开连接 //创建sql命令语句 using (oledbcommand cmd = conn.createcommand()) { //sql查询语句 cmd.commandtext = select * from t_users where account_type=' + textbox5.text + ';; //读取查询结果内容 using (oledbdatareader reader = cmd.executereader()) { if (reader.read())//账号类型存在存在 { string db_type = reader.getstring(reader.getordinal(account_type)); string db_website = reader.getstring(reader.getordinal(account_website)); string db_username = reader.getstring(reader.getordinal(account_username)); string db_password = reader.getstring(reader.getordinal(account_password)); textbox1.text =db_type; textbox2.text = decryptdes(db_website, 信息md5加密字符串); textbox3.text = decryptdes(db_username, 信息md5加密字符串); textbox4.text = decryptdes(db_password, 信息md5加密字符串); } else //reader返回false,搜索没有找到 { messagebox.show(对不起,没有找到!, 搜索提示); return; } } } } } } //下拉框搜索 private void combobox1_selectedindexchanged(object sender, eventargs e) { string connectionstring = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改; { using (oledbconnection conn = new oledbconnection(connectionstring)) { conn.open();//打开连接 //创建sql命令语句 using (oledbcommand cmd = conn.createcommand()) { //sql查询语句 cmd.commandtext = select * from t_users where account_type=' + combobox1.text +'; //读取查询结果内容 using (oledbdatareader reader = cmd.executereader()) { if (reader.read()) { textbox1.text =reader.getstring(reader.getordinal(account_type)); textbox2.text = decryptdes((reader.getstring(reader.getordinal(account_website))), 信息md5加密字符串); textbox3.text = decryptdes((reader.getstring(reader.getordinal(account_username))), 信息md5加密字符串); textbox4.text = decryptdes((reader.getstring(reader.getordinal(account_password))), 信息md5加密字符串); } else { combobox1.items.remove(combobox1.text); return; } } } } } } /* 在winform中,系统默认是不能够禁用窗体的关闭功能, * 但是,有时我们需要这种功能来屏蔽用户随便或不小心关闭造成的系统问题。 * 该方法操作起来十分简便,只要将以下一段代码添加到窗体累中就可以实现禁止窗体关闭按钮 * 该方法让窗体的关闭按钮还是存在的,但是,鼠标操作关闭按钮是没有效果的。 */ /****************************************************************************/ //禁用鼠标右上角关闭按钮 protected override void wndproc(ref message m) { const int wm_syscommand = 0x0112; const int sc_close = 0xf060; if (m.msg == wm_syscommand && (int)m.wparam == sc_close) { return; } base.wndproc(ref m); } /***********************************************************************/ //系统维护 private void button5_click(object sender, eventargs e) { form3 fm3 = new form3(); this.hide(); fm3.show(); } //退出系统 private void button7_click(object sender, eventargs e) { application.exit(); } }}
窗体三源码:
using system;using system.windows.forms;using system.data.sqlclient;using system.data.oledb;using system.security.cryptography;using system.text;namespace 账号密码管理系统1._0{ public partial class form3 : form { public form3() { initializecomponent(); } //重置 private void button2_click(object sender, eventargs e) { textbox1.text = ; textbox2.text = ; textbox3.text = ; textbox4.text = ; textbox5.text = ; } //修改 private void button1_click(object sender, eventargs e) { if (textbox4.text == textbox5.text) { //与数据库建立连接 string connectionstring = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改; { using (oledbconnection conn = new oledbconnection(connectionstring)) { conn.open();//打开连接 //创建sql命令语句 using (oledbcommand cmd = conn.createcommand()) { //sql查询语句 cmd.commandtext = select * from t_system where sys_username=' + getmd5(textbox1.text) + ';; //读取查询结果内容 using (oledbdatareader reader = cmd.executereader()) { if (reader.read())//判断用户名是否存在 { string dbpassword = reader.getstring(reader.getordinal(sys_password)); if (dbpassword == getmd5(textbox2.text)) //原来密码输入正确 { //更新数据库 //添加信息插入到数据库内 /***********************************************************************/ //与数据库建立连接 string connectionstring2 = provider=microsoft.jet.oledb.4.0;data source=account_system.mdb;jet oledb:database password=数据库密码设置处,此处已经修改; { using (oledbconnection conn2 = new oledbconnection(connectionstring2)) { conn2.open();//打开连接 //创建sql命令语句 using (oledbcommand insert_cmd = conn2.createcommand()) { //sql查询语句 insert_cmd.commandtext = update t_system set sys_username=' + getmd5(textbox3.text) + ',sys_password=' + getmd5(textbox4.text) + ';; insert_cmd.executenonquery(); } } } messagebox.show(恭喜您,修改成功!, 系统维护提示); } else//原密码输入错误 { messagebox.show(对不起,原密码输入错误); return; } } else { messagebox.show(原用户名输入错误!); return; } } } } } } else { messagebox.show(修改失败,新密码与确认密码不一致!, 修改错误提示); return; } } //md5加密算法 public static string getmd5(string str) { md5 md5 = md5.create(); byte[] buffer = encoding.default.getbytes(str); byte[] md5buffer = md5.computehash(buffer); string strnew = ; for (int i = 0; i ) { strnew += md5buffer[i].tostring(x2); } return strnew; } private void button3_click(object sender, eventargs e) { form2 fm2 = new form2(); this.hide(); fm2.show(); } }}
其它类似信息

推荐信息