P
Paul M
Hi
First of all thankyou Thomas and Stefan for helping with the sql injection
on password protecting pages I have now solved it. But I have found another
security issue
The script below sends a user there username and password to there email.
How can I add some serverside script to stop any sql injection attacking the
database from this angle
Thanks Paul M
This is above the head
<%@ LANGUAGE="VBSCRIPT" %>
<% Option Explicit %>
<%
Dim DATA_PATH, objDC, objRS, email, user, pass, sendmail
'Maps to database. Change to your database path.
DATA_PATH=Server.Mappath("fpdb/databasesearch.mdb")
' Create and establish data connection
Set objDC = Server.CreateObject("ADODB.Connection")
objDC.ConnectionTimeout = 15
objDC.CommandTimeout = 30
objDC.Open "DBQ=" & DATA_PATH & ";Driver={Microsoft Access Driver (*.mdb)};
DriverId=25;MaxBufferSize=8192;Threads=20;", "admin", "password"
Set objRS = Server.CreateObject("ADODB.Recordset")
email=request.form("email")
'you may need to adjust this to suit your database
objRS.Open "SELECT * FROM Results WHERE email = '" & email & "'", objDC, 0,
1
%>
and this is in the body
'checks if email address exists in the database before sending a message.
if objrs.EOF then
%>
<B><font face="Arial" size="2" color="red">Sorry<br>
We can't find this email address <%=email%>. If you are
sure the email address is correct
please contact us for assistance, or click the back
button
to correct it . </font></B>
<% Else %>
<%
'sets variables
email = request.form("email")
'chooses username and password from database that correspond to submitted
email address.
user = objrs.Fields("user_name")
pass = objrs.Fields("pass_word")
Set sendmail = Server.CreateObject("CDONTS.NewMail")
'put the webmaster address here
sendmail.From = "(e-mail address removed)"
'The mail is sent to the address entered in the previous page.
sendmail.To = email
'Enter the subject of your mail here
sendmail.Subject = "The marketing for Good Login Information You Requested"
'This is the content of thr message.
sendmail.Body = "Hi. Here are your login details needed to search for
Projects in the Database." & vbCrlf & vbCrlf _
& "Username=" & user & vbCrlf _
& "Password=" & pass & vbCrlf
'this sets mail priority.... 0=low 1=normal 2=high
sendmail.Importance = 2
sendmail.Send
%><font face="Arial" size="2" color="#808080">
Your login information has been mailed to
<%=email%>.<br>
You should receive it shortly.
<%
' Close Data Access Objects and free DB variables
objDC.Close
Set objRS = Nothing
Set objDC = Nothing
Set sendmail = Nothing
%>
<%end if%>
First of all thankyou Thomas and Stefan for helping with the sql injection
on password protecting pages I have now solved it. But I have found another
security issue
The script below sends a user there username and password to there email.
How can I add some serverside script to stop any sql injection attacking the
database from this angle
Thanks Paul M
This is above the head
<%@ LANGUAGE="VBSCRIPT" %>
<% Option Explicit %>
<%
Dim DATA_PATH, objDC, objRS, email, user, pass, sendmail
'Maps to database. Change to your database path.
DATA_PATH=Server.Mappath("fpdb/databasesearch.mdb")
' Create and establish data connection
Set objDC = Server.CreateObject("ADODB.Connection")
objDC.ConnectionTimeout = 15
objDC.CommandTimeout = 30
objDC.Open "DBQ=" & DATA_PATH & ";Driver={Microsoft Access Driver (*.mdb)};
DriverId=25;MaxBufferSize=8192;Threads=20;", "admin", "password"
Set objRS = Server.CreateObject("ADODB.Recordset")
email=request.form("email")
'you may need to adjust this to suit your database
objRS.Open "SELECT * FROM Results WHERE email = '" & email & "'", objDC, 0,
1
%>
and this is in the body
'checks if email address exists in the database before sending a message.
if objrs.EOF then
%>
<B><font face="Arial" size="2" color="red">Sorry<br>
We can't find this email address <%=email%>. If you are
sure the email address is correct
please contact us for assistance, or click the back
button
to correct it . </font></B>
<% Else %>
<%
'sets variables
email = request.form("email")
'chooses username and password from database that correspond to submitted
email address.
user = objrs.Fields("user_name")
pass = objrs.Fields("pass_word")
Set sendmail = Server.CreateObject("CDONTS.NewMail")
'put the webmaster address here
sendmail.From = "(e-mail address removed)"
'The mail is sent to the address entered in the previous page.
sendmail.To = email
'Enter the subject of your mail here
sendmail.Subject = "The marketing for Good Login Information You Requested"
'This is the content of thr message.
sendmail.Body = "Hi. Here are your login details needed to search for
Projects in the Database." & vbCrlf & vbCrlf _
& "Username=" & user & vbCrlf _
& "Password=" & pass & vbCrlf
'this sets mail priority.... 0=low 1=normal 2=high
sendmail.Importance = 2
sendmail.Send
%><font face="Arial" size="2" color="#808080">
Your login information has been mailed to
<%=email%>.<br>
You should receive it shortly.
<%
' Close Data Access Objects and free DB variables
objDC.Close
Set objRS = Nothing
Set objDC = Nothing
Set sendmail = Nothing
%>
<%end if%>