| 网站首页 | VB.Net实例分析 | .Net技术文摘 | 下载中心 | VB.Net书籍笔记 | .Net源码 | VBS脚本与组件调用 | Windows2008技术文摘 | 给我们留言 | 
最新公告:

  没有公告

您现在的位置: 乐博网 >> Asp.Net应用技巧 >> 技术文摘正文
最新推荐 更多内容
Serv-U密码加密原理并实现( ASP.NET基于C# )
Serv-U密码加密原理并实现( ASP.NET基于C# )
作者:Jakie    来源:btbbt     更新时间:2011-3-16

   Serv-U的确比iis6.0自带的那个ftp强大很多,感觉确实不错,不管从性能还是功能,不过能在线管理就更方便了,在网上找了一些在线更改Serv-U的密码的教程,但是多数写的都不明白,有些还是用ASP写的,呵呵,我的ASP不好,再说学校的学弟学妹也是用.NET的比较多,是吧.....呵呵,废话少说,教程开始
  本教程纯属原创,如有雷同,均为盗版
------------------------------------------------------------------------------------------------ 
   首先,大家要了解Serv-U的工作模式,它可以将帐户信息保存在MySql和SQL Server 等数据库上,但是前提要建立ODBC数据源,我想对于软件班想当程序员的同学们,这个不成问题吧,呵呵
=======================================================
如何设置Serv-U的ODBC功能
=======================================================
如何用Serv-U连接ODBC|
1、可以在 FTP所在服务器安装一个 SQL Server  数据库,也可以使用
论坛
自带的数据库。建议在 FTP所在服务器安装一个全新的  SQL Server。
2、配置DSN。到Windows的管理工具,数据源(ODBC)。在用户 DSN,点击“添加”,选择"SQL Server",然后点击完成。
在接下来出现的对话框中,Data Source Name(名称) 填写任意一个DSN名字,比如Serv-U。下面填写储存FTP信息的SQL Server 数据库信息,包括主机名,用户名密码等。OK后进行下一步。
3、打开Serv-U管理器,新建一个域名,在域名添加向导的第4步Domain type中选择Store in ODBC database。
4、打开Serv-U安装目录下的ServUDaemon.ini文件,做以下*作:
(1)用下面的代码覆盖原来的ODBCSource、ODBCTables、ODBCColumns
------------------------------------------
ODBCSource=Serv-U||
ODBCTables=useraccounts|groupaccounts|userdiraccess|groupdiraccess|useripaccess|groupipaccess
ODBCColumns=Name|Password|SkeyValues|HomeDir|LogMesfile|Access|Disable|Needsecure|RelPaths|

HideHidden|AlwaysLogin|ChangePass|QuotaEnable|MaxIp|MaxSpeedUp|MaxSpeedDown|MaxUsers|

idleTimeOut|SessionTimeOut|RatioUP|RatioDown|RatioCredit|QuotaCurrent|QuotaMax|Expiration|Privilege|

PassType|RatioType|Groups|Notes|Index

------------------------------------------

用户密码的加密方法可以在Serv-U官方网站的知识库查到
  
http://rhinosoft.com/KBArticle.asp?RefNo=1177&prod=su
Manually Entering Encrypted Passwords into the ServUDaemon.ini File
To generate an encrypted password, first two random characters (the salt - in the range a..z, A..Z) are added to the beginning of the clear-text password. This is then hashed using MD5 and the resulting hash is hex-encoded. The result of this is written as plain-text starting with the 2 salt characters followed by the hex-encoded hash.
For a user account in the .ini file, this will look like:
Password=cb644FB1F31184F8D3D169B54B3D46AB1A
The salt is the string "cb", the MD5 hash is "644FB1F31184F8D3D169B54B3D46AB1A".
When verifying a users password, Serv-U will do the same. It parses the salt from the users stored password (ie. "cb" in this case), prepends it the password the user sent to it by the client, MD5 hashes it, and compares the result with the stored hash. If the values are equal, then the entered password is correct.

------------------------------------------------------------------------------------------------

简单的解释一下,例如有个用户的密码是 123456其MD5值是
E10ADC3949BA59ABBE56E057F20F883E
Serv-U的加密方式是
产生两位随机的从 a...z 的字母,例如 ab
将 ab放到密码的前面,也就是ab123456,在将其用MD5加密,也就是872BE7378D2E5C4B747F2547144C6DC5
再把ab加到ab123456的MD5值的前面,也就是
ab872BE7378D2E5C4B747F2547144C6DC5
这个就是Serv-U最终的密码了,呵呵
了解了原理,下面就用ASP.NET实现这个效果

------------------------------------------------------------------------------------------------

    protected void Page_Load(object sender, EventArgs e)
    {
        string ran = this.rdom() //定义变量ran存储rdom()函数返回的随机数
        //在我的电脑上产生的随机字符是 zk
        string pass = "123456" //要加密的密码 123456
        Response.Write("随机字符是:" + ran + "\t")
        Response.Write("生成的密码是:" + md5_pass(ran, pass))
    }
    protected string rdom() //定义一个产生两位从a..z的函数
    {
        string strran = ""  //定义字符串
        Random ran = new Random()
        strran += Convert.ToChar(ran.Next(26) + a ).ToString() + Convert.ToChar(ran.Next(26) + a ).ToString() //将随机产生的两个字母相连.例如:a+b=ab
        return strran
    }
     protected string md5_pass(string rdoms, string md5) //定义一个加密的函数,加密结果返回
    {
        string strmd5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile ( rdoms + md5 , "MD5")  //把两位随机字母和md5连接并再次进行MD5加密
        return rdoms + strmd5 //将两位随机字母与加密后的MD5值再次连接
    }

------------------------------------------------------------------------------------------------

输出结果

随机字符是:zk 生成的密码:zkFE7CE0A9173FF8DFEBBC87EC928D98C4

------------------------------------------------------------------------------------------------

  • 上一篇:

  • 下一篇: 没有了
  • 【字体: 】【打印此文】【关闭窗口
      相关文章:(只显示最新16条)
    VB.Net FileZilla密码加解密的方法
    C# FileZilla密码加密的源代码(乐博网原创)
    C#管理Serv-U6.4.0.6的方法
    VB.Net实现FTP编程的学习笔记.04.[乐博网]
    VB.Net实现FTP编程的学习笔记.03.[乐博网]
    VB.Net实现FTP编程的学习笔记.02.[乐博网]
    VB.Net实现FTP编程的学习笔记.01.[乐博网]
    VB.Net实现Ftp上传的方法[乐博网原创]
    VB.Net实现Ftp下载的方法[乐博网原创]
    VB.Net实现登陆Ftp的方法[乐博网原创]
    VB.Net实现FTP下载文件的两种方法

    | 设为首页 | 加入收藏 | 联系站长 | | 友情链接 | 版权申明 |
    乐博网欢迎各种媒体转载我们的原创作品[转载请注明出处];我们鼓励更多VB.Net开发者一起加入研究与探讨;如发现文章访问错误、内容错误或版权疑问、内容有违相关法律(如涉及政治、色情、反动或散布虚假有害信息)等情况,请及时向我们举报,我们将及时纠正!
    联系邮箱:Shiny#vip.qq.com (#替换为@) QQ交流群: 40797788 [闽ICP备05014267号]