簡單的ASP防注入代碼 360
使用方法如下:
1. 把以下代碼保存為_safe.asp,然后放到站點根目錄即可。
<%
On Error Resume Next
if request.querystring<>"" then call stophacker(request.querystring,"'|(alert|confirm|prompt)|<[^>]*?>|^+/v(8|9)|onmouse(over|move)=|(and|or).+?(>|<|=|in|like)|/*.+?*/|
if Request.ServerVariables("HTTP_REFERER")<>"" then call test(Request.ServerVariables("HTTP_REFERER"),"'|(and|or).+?(>|<|=|in|like)|/*.+?*/|
if request.Cookies<>"" then call stophacker(request.Cookies,"(and|or).{1,6}?(=|>|<|in|like)|/*.+?*/|
call stophacker(request.Form,"^+/v(8|9)|(and|or).{1,6}?(=|>|<|in|like)|/*.+?*/|
如果您的問題還未解決可以聯系站長付費協助。
function test(values,re)
dim regex
set regex=new regexp
regex.ignorecase = true
regex.global = true
regex.pattern = re
if regex.test(values) then
IP=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If IP = "" Then
IP=Request.ServerVariables("REMOTE_ADDR")
end if
'slog("
操作IP: "&ip&"
操作時間: " & now() & "
操作頁面:"&Request.ServerVariables("URL")&"
提交方式: "&Request.ServerVariables("Request_Method")&"
提交參數: "&l_get&"
提交數據: "&l_get2)
操作IP: "&ip&"
操作時間: " & now() & "
操作頁面:"&Request.ServerVariables("URL")&"
提交方式: "&Request.ServerVariables("Request_Method")&"
提交參數: "&l_get&"
提交數據: "&l_get2)
Response.Write("
您的提交帶有不合法參數,謝謝合作!
")
您的提交帶有不合法參數,謝謝合作!
Response.end
end if
set regex = nothing
end function
function stophacker(values,re)
dim l_get, l_get2,n_get,regex,IP
for each n_get in values
for each l_get in values
l_get2 = values(l_get)
set regex = new regexp
regex.ignorecase = true
regex.global = true
regex.pattern = re
if regex.test(l_get2) then
IP=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If IP = "" Then
IP=Request.ServerVariables("REMOTE_ADDR")
end if
'slog("
操作IP: "&ip&"
操作時間: " & now() & "
操作頁面:"&Request.ServerVariables("URL")&"
提交方式: "&Request.ServerVariables("Request_Method")&"
提交參數: "&l_get&"
提交數據: "&l_get2)
操作IP: "&ip&"
操作時間: " & now() & "
操作頁面:"&Request.ServerVariables("URL")&"
提交方式: "&Request.ServerVariables("Request_Method")&"
提交參數: "&l_get&"
提交數據: "&l_get2)
Response.Write("
您的提交帶有不合法參數,謝謝合作!
")
您的提交帶有不合法參數,謝謝合作!
Response.end
end if
set regex = nothing
next
next
end function
sub slog(logs)
dim toppath,fs,Ts
toppath = Server.Mappath("/index.asp")
Set fs = CreateObject("scripting.filesystemobject")
If Not Fs.FILEEXISTS(toppath) Then
Set Ts = fs.createtextfile(toppath, True)
Ts.close
end if
Set Ts= Fs.OpenTextFile(toppath,8)
Ts.writeline (logs)
Ts.Close
Set Ts=nothing
Set fs=nothing
end sub
%>
2.在所需要防護的頁面加入代碼
就可以做到頁面防注入、跨站。
如果想整站防注,就在網站的一個公用文件中,如數據庫鏈接文件conn.asp中!
添加來調用本代碼,趕快去試試吧!
如果您的問題還未解決可以聯系站長付費協助。

有問題可以加入技術QQ群一起交流學習
本站vip會員 請加入無憂模板網 VIP群(50604020) PS:加入時備注用戶名或昵稱
普通注冊會員或訪客 請加入無憂模板網 技術交流群(50604130)
客服微信號:15898888535
聲明:本站所有文章資源內容,如無特殊說明或標注,均為采集網絡資源。如若內容侵犯了原著者的合法權益,可聯系站長刪除。
熱門
應用市場
-
¥100 采集文章自動推送百度插件 PHP插件支持推送百度當天文章
2024-12-30
-
¥50 pbootcms副欄目多選功能 默認只能多選一個 此插件可多選多個欄目
2024-12-30
-
¥200 網站維護/網站修改/問題解決/網站搬遷/php修改/asp修改/網站搬家
2024-12-30
-
¥100 根據標題生成圖片,文章頁自動配標題配圖,避免版權問題,所有cms通用php
2024-12-30