<%
'Asp anti-injection solution
'Special page processing
'Because some pages are passed through streaming (for example, a form containing a file to be uploaded)
'An error occurs if you use a single exhaustive Form object.
'So you need to filter out these pages and use SQL ("checked strings") on the page.
'Garbage pig zero@new57.com
'Http: // blog.111cn.net/cfaq
'Put the include method on this page in the header so that all pages can be called. For example, include in conn. asp
'If you have a streaming upload page, add the page to the table page to prevent form conflict.
Dim N_no, N_noarray, req_Qs, req_F, N_ I, N_dbstr, Conn, N_rs, N_userIP, N_thispage
N_userip = Request. ServerVariables ("REMOTE_ADDR ")
N_thispage = LCase (Request. ServerVariables ("URL "))
N_no = "'|; | and | exec | insert | select | delete | update | count | * | % | chr | mid | master | truncate | char | declare "'can be modified on your own to suspect injection operations. string
N_noarray = split (LCase (N_no), "| ")
Call DBopen ()
Call N_check_Qs ()
Call N_checkPage ()
Call DBCLose ()
'If the current page is a special page, N_check_form () is called ()
Sub N_checkPage ()
Set N_rs = server. CreateObject ("ADODB. RecordSet ")
N_rs.open "select * from page where spcpage like '%" & N_thispage & "%'", conn, 1, 1
If (N_rs.eof AND N_rs.Bof) then
Call N_check_form ()
End if
N_rs.Close ()
Set N_rs = nothing
End sub
'Check the specified string
Sub N_ SQL (agsql)
'The database is not recorded here. If you want to change it, modify it yourself.
N_check "CUS", req_Qs, "OTHER"
End sub
'Check Request. Form
Sub N_check_form ()
If Request. Form <> "" Then
For Each req_F In Request. Form
N_check req_F, Request. Form (req_F), "POST"
Next
End if
End sub
'Check Request. QueryString
Sub N_check_Qs ()
If Request. QueryString <> "Then
For Each req_Qs In Request. QueryString
N_check req_Qs, Request. QueryString (req_Qs), "GET"
Next
End if
End sub
'Detection
Sub N_check (ag, agsql, sqltype)
For N_ I = 0 To Ubound (N_noarray)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service