Jan 16

Evita el SQL injection en ASP

Tag: ASP, Internet, Software, Tecnologiadeambulando @ 9:58 pm

Esta función ya os la presenté anteriormente pero ayer me decidí a mejorarla basándome en este pdf

function limpia(text,encode)
dim banned,i
limpia=text
banned = array("""","'","&","--","select","insert","update","delete","drop")
for i = 0 to uBound(banned)
limpia = replace(limpia, banned(i),"")
next
if encode=true then
limpia=server.htmlencode(limpia)
end if
end function

2 Responses to “Evita el SQL injection en ASP”

  1. German says:

    <%
    function validar_entrada( input )
    palabras = array( “script”, “select”, “insert”, “update”, “delete”,”drop”,”DECLARE”,”declare”,”EXEC”,”exec” ,”VARCHAR”,”varchar” , “–”, “‘” )
    validar_entrada = True
    for i = lbound( palabras ) to ubound( palabras )
    if ( instr( 1, input, palabras(i), vbtextcompare ) 0 ) Then
    validar_entrada = false
    exit function
    end if
    Next
    end function

    %>

  2. deambulando says:

    hola german, no esta mal el codigo….pero…

    y si el usuario pone — como algo normal? ya no insertas nada en la BBDD?

Leave a Reply