首页 > 精选文章 > ASP技术 > 正文

GET方式SQL注入攻击网站入侵防守代码.

GET方式SQL注入攻击网站入侵防守代码.
'--------------------------------------------------------------------------
http://61.144.185.39/System_BBS_ShowInfo.asp?pid=1&cid=8';exec%20master.dbo.xp_cmdshell%20"net user test test /add;--&aid=8&sid=4&page=1
http://61.144.185.39/System_BBS_ShowInfo.asp?pid=1&cid=8';exec%20master.dbo.xp_cmdshell%20"net localgroup administrators test /add;--&aid=8&sid=4&page=1
'--------------------------------------------------------
以上代码即为SQL inject即SQL注入攻击网站方案.
如果以上的系统采用的是SQL数据库而且是SA帐号.
且无以下代码作为防守.则以上代码执行后的结果就是
机器上的超管组增加一个TEST用户.

闲人勿试以上代码,否则被网警....与本人无关......

以下代码仅供WEB工作者使用.

qs=request.servervariables("query_string")
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)="%"
errc=false
for i= 0 to ubound(nothis)
if instr(Qs,nothis(i))<>0 then
errc=true
end if
next
if errc then
response.write "<script language=""javascript"">"
response.write "parent.alert('很抱歉!你正在试图攻击本服务器或者想取得本服务器最高管理权!将直接转向首页..');"
response.write "self.location.href='default.asp';"
response.write "</script>"
response.end
end if


--------------------

以上只能防止GET方式的SQL注入攻击.
采用的时候只须在接受任何参数前使用即可.
可以依需要增加过滤参数.
马上把此代码加入到conn.asp中.
可以增加一定的安全强度.但并不是绝对安全.

POST防守方式要小心过滤一些必要的参数.
  • 上一篇:chr()全接触
  • 下一篇:用VB做asp调用的dll的通用代码
  • 了解这些字:方的意思 式的意思 注的意思 入的意思 攻的意思 击的意思 网的意思 站的意思