função de bloqueio com Sql Injection
Caríssimos, Boa noite!
Estou com um problema no código para bloquear a injeção do SQL.
Tenho 2 páginas ASP (logar.asp e acesso.asp)
A página logar.asp tem o formulário que eu passo os dados para a página acesso.asp que contém a função em javascript de bloqueio ao SQL Injection.
Mas quando eu envio esses dados para validação, ocorre o seguinte erro:
Erro de tempo de execução do Microsoft VBScript (0x800A000D)
Tipos incompatíveis: 'LimparTexto'
/teste/RPPS/teste11/conteudo/acesso.asp, line 41
A linha 41 é esta:
login = LimparTexto(Request.QueryString("login"))
Segue os respectivos códigos na integra:
logar.asp
<!--#include file="includes/config.asp"-->
<!--#include file="includes/abrebanco.asp"--><head>
<title><%=titulo%></title>
<link href="<%=local%>includes/styles/link.css" rel="stylesheet" type="text/css">
<style><!--
font { font-family: Arial; font-size: 11 }
-->
</style>
</head>
<body bgcolor="<%=fundo%>" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="778" height="0" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="249"><table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="56" height="260" valign="top" rowspan="2" bgcolor="#EBEBEB"></td>
<td width="570" height="260" rowspan="2" valign="top">
<div align="center">
<center><table width="97%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="0" valign="top"><form action="acesso.asp" method="get">
<p> </p>
<table width="65%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="0" colspan="2"><font size="4" face="Arial, Helvetica, sans-serif"><b>Administrar Imobiliária</b></font></td>
</tr>
<tr>
<td height="0" colspan="2"> </td>
</tr>
<tr>
<td height="0" colspan="2"><div align="center"><font color="#FF0000" size="1" face="Verdana, Arial, Helvetica, sans-serif">*
Campos obrigatórios</font></div></td>
</tr>
<tr>
<td width="52%"><%=fonte02%>Login:*</td>
<td width="48%"><input name="login" type="text" maxlength="10" class="formindex"></td>
</tr>
<tr>
<td><%=fonte02%>Senha:*</td>
<td><input type=password name="senha" class="formindex"></td>
</tr>
<tr>
<td> </td>
<td><input type="reset" value="Limpar" style="font-family: Arial; font-size: 11"> <input type="submit" value="OK" style="font-family: Arial; font-size: 11"></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><div align="center"><%=fonte01%><a href="javascript:window.history.go(-1)">Voltar</a></div></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</form></td>
</tr>
</table></center>
</div>
</td>
<td width="154" valign="top">
Acesso.asp
<script type="text/javascript" language="javascript">
function LimparTexto(str){
str = trim(str)
str = lcase(str)
str = replace(str,"=","")
str = replace(str,"'","")
str = replace(str,"")
str = replace(str," or ","")
str = replace(str," and ","")
str = replace(str,"(","")
str = replace(str,")","")
str = replace(str,"<","[")
str = replace(str,">","]")
str = replace(str,"update","")
str = replace(str,"-shutdown","")
str = replace(str,"--","")
str = replace(str,"'","")
str = replace(str,"#","")
str = replace(str,"$","")
str = replace(str,"%","")
str = replace(str,"¨","")
str = replace(str,"&","")
str = replace(str,"'or'1'='1'","")
str = replace(str,"--","")
str = replace(str,"insert","")
str = replace(str,"drop","")
str = replace(str,"delet","")
str = replace(str,"xp_","")
str = replace(str,"select","")
str = replace(str,"*","")
LimparTexto = str
}
</script>
<%@Language=VBScript%>
<% dim cnpath, DB, acesso, login, senha
cnpath="DBQ=" & server.mappath("../noticias/noticias.mdb")
Set DB = Server.CreateObject("ADODB.Connection")
DB.Open "DRIVER={Microsoft Access Driver (*.mdb)}; "& cnpath
login = LimparTexto(Request.QueryString("login"))
senha = LimparTexto(Request.QueryString("senha"))
Set acesso=DB.Execute("SELECT * FROM admin WHERE login='"&login&"' AND senha='"&senha&"'")
if acesso.eof then
Response.Redirect"logar.asp"
else
Session("login")=login
'Session("usuario")=acesso("usuario")
Session("senha")=acesso("senha")
Session("login")=acesso("login")
Response.Redirect"identificado.asp"
end if
DB.close
%>
Grato
Jardel
Discussão (7)
Carregando comentários...