首页 | 免费域名 | 个人服务器 | 一流信息监控拦截系统 | 虚拟主机知识库 | ASP 空间 | ASP技术大全 | 下载中心 | 客户服务中心
  7i24 > ASP技术大全 > ASP安全文摘 >
    7i24 .Com  
  口令保护

7i24.Com不停为您服务
口令保护

password.asp:提供一个输入界面
<%@ LANGUAGE="VBSCRIPT" %>

<!--- This example is a simple login system --->

<HTML>
<HEAD>
  <TITLE>Password.asp</TITLE>
</HEAD>

<BODY>
  <FORM ACTION="engine.asp" NAME="form1" METHOD="post">
     User Name: <INPUT TYPE="text" SIZE=30 NAME="username">
     <P>
     Password: <INPUT TYPE="password" SIZE=30 NAME="password">
     <P>
     <INPUT TYPE="submit" VALUE="Login">
  </FORM>
</BODY>
</HTML>


engine.asp:检验用户输入项
<%@ LANGUAGE="VBSCRIPT" %>

<%
  ' Connects and opens the text file
  ' DATA FORMAT IN TEXT FILE= "username<SPACE>password"

  Set MyFileObject=Server.CreateObject
("Scripting.FileSystemObject")
  Set MyTextFile=MyFileObject.OpenTextFile(Server.MapPath
("\path\path\path\path") & "\passwords.txt")

  ' Scan the text file to determine if the user is legal
  WHILE NOT MyTextFile.AtEndOfStream
     ' If username and password found
     IF MyTextFile.ReadLine = Request.form("username") & " " &
Request.form("password") THEN
        ' Close the text file
        MyTextFile.Close
        ' Go to login success page
        Session("GoBack")=Request.ServerVariables
("SCRIPT_NAME")
        Response.Redirect "inyougo.asp"
        Response.end
     END IF
  WEND

  ' Close the text file
  MyTextFile.Close
  ' Go to error page if login unsuccessful
  Session("GoBack")=Request.ServerVariables("SCRIPT_NAME")
  Response.Redirect "invalid.asp"
  Response.end

%>

invalid.asp :用户无效的口令时的页面
<%@ LANGUAGE="VBSCRIPT" %>

<!--- This example is a simple login system --->

<HTML>
<HEAD>
<TITLE>invalid.asp</TITLE>
</HEAD>

<BODY>
You have entered an invalid username or password.
<P>
<A HREF="password.asp">Try to log in again</A>
</BODY>
</HTML>

inyougo.asp:用户的口令正确
<%@ LANGUAGE="VBSCRIPT" %>

<!--- This example is a simple login system --->

<HTML>
<HEAD>
   <TITLE>In You Go</TITLE>
</HEAD>

<BODY>
   You have now entered the password protected page.
</BODY>
</HTML>

passwords.txt:包含口令的文本文件

gates bill
burns joe 


  2002年1月9日  阅读 1561 次  发送此页给朋友  来源:    版权争议  删除

相关文章:   近期热点:

上一篇: 关于WIN2000的入侵,以及安全防御等问题。
下一篇: 提高IIS的 安全性
返回上一层...
搜索:

(C)2004-2022 7i24.Com 保留所有权利