ASP 의 SQL 주입식 공격 을 방지 하 는 두 가지 기능

sql 주입 공격 을 방지 하 는 함수 입 니 다.여러분 은 직접 사용 할 수 있 습 니 다.그러나 여러분 은 사용 만 할 수 있 습 니까?안전 의식 을 강화 해 야 합 니 다

'==========================
' SQL
'==========================
function ForSqlForm()
dim fqys,errc,i,items
dim nothis(18)
nothis(0)="net user"
nothis(1)="xp_cmdshell"
nothis(2)="/add"
nothis(3)="exec%20master.dbo.xp_cmdshell"
nothis(4)="net localgroup administrators"
nothis(5)="select"
nothis(6)="count"
nothis(7)="asc"
nothis(8)="char"
nothis(9)="mid"
nothis(10)="'"
nothis(11)=":"
nothis(12)=""""
nothis(13)="insert"
nothis(14)="delete"
nothis(15)="drop"
nothis(16)="truncate"
nothis(17)="from"
nothis(18)="%"
'nothis(19)="@" 
errc=false
for i= 0 to ubound(nothis)
  for each items in request.Form
  if instr(request.Form(items),nothis(i))<>0 then
   response.write("<div>")
   response.write(" :" & server.HTMLEncode(request.Form(items)) & "<br> :" & nothis(i))
   response.write("</div>")
   response.write(" , !<a href=""#"" onclick=""history.back()""> </a>")
   response.End()
  end if
  next
next
end function
'==========================
' SQL
'==========================
function ForSqlInjection()
dim fqys,errc,i
dim nothis(19)
fqys = request.ServerVariables("QUERY_STRING")
nothis(0)="net user"
nothis(1)="xp_cmdshell"
nothis(2)="/add"
nothis(3)="exec%20master.dbo.xp_cmdshell"
nothis(4)="net localgroup administrators"
nothis(5)="select"
nothis(6)="count"
nothis(7)="asc"
nothis(8)="char"
nothis(9)="mid"
nothis(10)="'"
nothis(11)=":"
nothis(12)=""""
nothis(13)="insert"
nothis(14)="delete"
nothis(15)="drop"
nothis(16)="truncate"
nothis(17)="from"
nothis(18)="%"
nothis(19)="@" 
errc=false
for i= 0 to ubound(nothis)
if instr(FQYs,nothis(i))<>0 then
errc=true
end if
next
if errc then
response.write " !<a href=""#"" onclick=""history.back()""> </a>"
response.end
end if
end function

좋은 웹페이지 즐겨찾기