Instead of the Request function in the ASP to prevent SQL injection

xiaoxiao2021-03-06  43

SQL injection vulnerabilities can be described as "a thousand miles of embankments, collapsed in the ant hole", which is extremely common online, usually because the programmer does not understand, or the program is not strict, or a parameter is forgotten. Here, I will give you a function, instead of the Request function in the ASP, can inject SAY NO to all SQL, the function is as follows:

Function SafeRequest (PARANAME, PARATYPE) '--- Incoming Parameters ---' PARANAME: Parameter Name - Characteristic 'Paratype: Parameter Type - Digital (1 means the above parameters are numbers, 0 means the above parameters are character)

DIM Paravalue Paravalue = Request (paraName) if Paratype = 1 Then if paravalue = "" or not isnumeric (paravalue) Then response.write "& paraName &" must be digital! "Response.end end if else Paravalue = Replace (Paravalue, "'" "") end if SafeRequest = ParavalueEnd Function

Function SafeRequest (PARANAME, PARATYPE) '--- Incoming Parameters ---' PARANAME: Parameter Name - Characteristic 'Paratype: Parameter Type - Digital (1 means the above parameters are numbers, 0 means the above parameters are character)

DIM Paravalue Paravalue = Request (paraName) if Paratype = 1 Then if paravalue = "" or not isnumeric (paravalue) Then response.write "& paraName &" must be digital! "Response.end end if else Paravalue = Replace (Paravalue, "'" "") end if SafeRequest = ParavalueEnd Function

转载请注明原文地址:https://www.9cbs.com/read-51727.html

New Post(0)