Advertisement
3_2004-2005 Security #144849

Simple Password Protection

Posted by Unknown (emerald.bbs@bbs.cs.nthu.edu.tw) to newsgroup tw.bbs.comp.www (30 September, 1998) Description: A simple script that allows only users who know a fixed password to visit your pages. The password is part of the HTML source, so this script provides only basic security. (The password of the demo page is 12345). Instructions

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
<!----------------------------------------Simple Password ProtectionJavaScript archived by JavaScript Cornerhttp://pbc.bhcom1.com-------------------------------------------->
<head>
<!------------------------------------------########## Script Part 1 ###################Copy this part into the HEAD of your page------------------------------------------->
<script language="JavaScript">
var password ="12345"; //set this to the desired string
var protected_page ="../common/2ndwindow.htm"; //set this to the destination URL
var pd="";
pd=prompt("You are about to enter a restricted zone. Password:","");
if(pd!=password)
{
alert("Invalid password");
history.back();
}
else
{
alert("Password accepted");
window.location.href=protected_page;
}
</script>
<!------------------------------------------########## End of Script Part 1 ############------------------------------------------->
<title>Simple Password Protection</title>
</head>
<body bgcolor="#000000" text="#FFFF00" link="#00FFFF" vlink="#C0C0C0">
<p align="center"><img src="../../bitmaps/jsbanner.gif" width="500" height="25"></p>
<h2 align="center">Simple Password Protection</h2>
</body>
</html>

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Authenticate a SMTP Server in ASP.NET -- By Kaustav Neogy</title>
</head>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
 <tr>
 <td width="100%">
 <p align="justify"><font face="Verdana">In .NET we can use the 
 System.Web.Mail Namespace to send mails. The SMTPMail Class provides 
 properties and methods for sending messages using the Collaboration Data 
 Objects for Windows 2000 (CDOSYS) message component. However there exists no 
 direct way to use authentication with a SMTP Server. Here’s a quick 
 workaround to it.<br>
&nbsp;</font></td>
 </tr>
 <tr>
 <td width="100%"> </td>
 </tr>
 <tr>
 <td width="100%">&nbsp;</td>
 </tr>
 <tr>
 <td width="100%"><b><font face="Verdana">Code:<br>
 </font></b></td>
 </tr>
 <tr>
 <td width="100%">&nbsp;</td>
 </tr>
 <tr>
 <td width="100%"><font face="Verdana" size="2" color="#0000FF">Public Sub 
 Send_Mail_With_Auth(ByVal szTo As String, ByVal szFrom As String, ByVal 
 szSubject As String, ByVal szBody As String)<br>
 <br>
 Dim myMsg<br>
 Dim myConfig<br>
 Dim Flds<br>
 <br>
 Const cdoSendUsingPort = 2<br>
 Const cdoBasic As Integer = 1<br>
 <br>
 myMsg = CreateObject("CDO.Message")<br>
 myConfig = CreateObject("CDO.Configuration")<br>
 Flds = myConfig.Fields<br>
 <br>
 With Flds<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 
 cdoSendUsingPort<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "your_smtp_server"<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") 
 = 10<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = 
 "username"<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = 
 "password"<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 
 cdoBasic<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 .Update()<br>
 End With<br>
 <br>
 With myMsg<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 .Configuration = myConfig<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 .To = szTo<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 .From = szFrom<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 .Subject = szSubject<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 .HTMLBody = szBody<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 .Send()<br>
 End With<br>
 <br>
 myMsg = Nothing<br>
 myConfig = Nothing<br>
 Flds = Nothing<br>
 <br>
 End Sub</font></td>
 </tr>
 <tr>
 <td width="100%"> </td>
 </tr>
</table>
</html>
Original Comments (3)
Recovered from Wayback Machine