网站360检测发现 [高危]跨站脚本攻击漏洞 文件,用以下方法处理

阿贝儿儿 2015-02-07 01:06:11
网站360检测发现 [高危]跨站脚本攻击漏洞 文件,用以下方法处理

1.在该文件中添加文件Neeao_SqlIn.asp

2.在该文件中添加文件360_safe3

3.用dvHTMLEncode和Server.HtmlEncode过滤数据库读出来的数据

4.用RegExpTest过滤自己认为需要过滤的数据

但是还是显示[高危]跨站脚本攻击漏洞

请问SQL语句中存在and或or字符该如何过滤, 还有其他什么办法来处理这个事情
...全文
890 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
sp198373 2015-04-09
  • 打赏
  • 举报
回复
能给看看上面的那些地方不对吗?不懂代码。。。。看晕了
sp198373 2015-04-09
  • 打赏
  • 举报
回复
<!--#include file="conn.asp"--> <!--#include file="inc/config.asp"--> <!--#include file="fenye_id.asp"--> <% class_1=trim(request("class_1")) class_2=trim(request("class_2")) class_3=trim(request("class_3")) sell_type=trim(request("sell_type")) game_type=trim(request("game_type")) if game_type ="交换帐号" then response.Redirect("id_change_id.asp?class1="&class_1&"&class2="&class_2&"&class3="&class_3) end if set rs=server.CreateObject("adodb.recordset") sql="select * from game where isnot =1 " if class_1 <> "" then sql=sql&" and class_1 ="&class_1 end if if class_2 <> "" then sql=sql&" and class_2 ="&class_2 end if if class_3 <> "" then sql=sql&" and class_3 ="&class_3 end if if game_type = "全部物品" then game_type = "" end if if game_type <> "" then sql=sql&" and game_type ='"&game_type&"'" end if if sell_type <> "" then sql=sql&" and title like '%"&sell_type&"%'" set s=conn.execute("select * from search_keywords where search_name ='"&sell_type&"'") if s.eof then conn.execute("insert into search_keywords (search_name,times) values ('"&sell_type&"',1)") else conn.execute("update search_keywords set times =times + 1 where search_name= '"&sell_type&"'") end if end if sql=sql&" order by id desc" rs.open sql,conn,3,1 %> <html> <head> <title>搜索结果 关键字[ <%=sell_type%> ]---<%=web_name%></title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <link href="css/Body.css" rel="stylesheet" type="text/css" /> <link href="css/SearchCss.css" rel="stylesheet" type="text/css" /> <link href="css/Foot.css" rel="stylesheet" type="text/css" /> <link href="css/base.css" rel="stylesheet" type="text/css" /> <link href="css/home.css" rel="stylesheet" type="text/css" /> <link href="css/head.css" rel="stylesheet" type="text/css" /> <link href="css/bra-panel.css" rel="stylesheet" type="text/css" /> <link href="css/shou.css" rel="stylesheet" type="text/css" /> <script language=JavaScript src="js/function1.js"></script> <style type="text/css"> <!-- body,td,th { font-size: 12px; } body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } a { color: #000000; } a:link { text-decoration: none; } a:visited { text-decoration: none; color: #000000; } a:hover { text-decoration: none; color: #FF6600; } a:active { text-decoration: none; color: #000000; } .buy_abc{ font-size:14px; font-weight:bolder; text-decoration: none; height: 20px; width: 20px; border: thin solid #3CB3EC; } .STYLE2 {color: #0066FF} .STYLE5 {color: #FF6633} .STYLE10 {font-size: small} .STYLE11 {color: #3333FF} --> </style></head> <body> <!--#include file="headtop.asp"--> <table width="980" border="0" align="center" cellspacing="2" cellpadding="0"> <tr> <td width="100%" valign="top" align="center"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFCC"> <tr> <td height="35"><strong> <IMG alt="寄售" src="images/jishou.gif"> 出售商品  <IMG alt="担保" src="images/danbao.gif"> 求购商品 <IMG alt="担保" src="images/id.gif"> 工会、英雄帖  </strong><strong> </strong></td> </tr> <tr> <td height="2"></td> </tr> <tr> <td height="50" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="40"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="345" height="26"> <span class="STYLE10 STYLE2"><span class="f-12 STYLE11">当前</span><span class="f-12 STYLE11">关 键 字:</span>[<strong> <%=sell_type%>]</strong></span></td> <td width="244" align="center" valign="middle"><font size="2"><strong><span class="STYLE2">没找到合适信息?你可以试试发布</span></strong><span class="STYLE2"><strong>功能</strong></span></font><font size="2" color="#FF6600"><strong>:</strong></font></td> <td width="125" align="right"><a href="woyaomai.asp" target="_self"><img src="images/kjfabu.jpg" width="105" height="35" border="0"></a> </td> </tr> <tr> <td height="8" colspan="3" bgcolor="#2E98D4"></td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="35" colspan="2"> 信息标题、类型、游戏/区/服</td> <td width="10%" align="center">类型</td> <td width="15%" align="center">联系QQ </td> <td width="10%" align="center">信息状态</td> </tr> <tr> <td height="1" colspan="6" bgcolor="#CCCCCC"></td> </tr> <%i=0 myPagesize=15 line=myPagesize call myPages(Rs,myPagesize) while not rs.eof and line > 0 i=i+1 set rs1=conn.execute("select * from game_user where user_name ='"&rs("add_user")&"'") if not rs1.eof then end if%> <tr onMouseOver="this.style.backgroundColor='#EEF8F9'" onMouseOut="this.style.backgroundColor=''"> <td width="2%" height="50"></td> <td width="62%" valign="middle"><br> <div class="hehe"><a href="show_pro.asp?id=<%=rs("id")%>"><font color="#CC99CC">■</font> <font color="#66CC00">[ </font></a><a href="?game_type=<%=rs("game_type")%>"><%=rs("game_type")%></a><a href="show_pro.asp?id=<%=rs("id")%>"><font color="#66CC00"> ]</font></a> <a href="show_pro.asp?id=<%=rs("id")%>"> <b><font color="#0000BD" style="FONT-SIZE: 11pt;"><%=rs("title")%></font></b></a></div> <br>  游戏/区/服: <%set c1=conn.execute("select * from game_class where id="&rs("class_1")) if not c1.eof then response.Write (server.htmlencode("<a href=?class_1="&c1("id")&">"&c1("name")&"</a>")) end if%> / <%set c2=conn.execute("select * from game_class where id="&rs("class_2")) if not c2.eof then response.Write (server.htmlencode("<a href=?class_2="&c2("id")&">"&c2("name")&"</a>")) end if%> / <%set c3=conn.execute("select * from game_class where id="&rs("class_3")) if not c3.eof then response.Write (server.htmlencode("<a href=?class_3="&c3("id")&">"&c3("name")&"</a>")) end if%>          信息种类:<a ><%=rs("game_type")%></a>      信用星级:<%=xinyong(rs("add_user"))%>      用户身份: <% if rs1("idpic")="1" then%> <img src="ioc/idpic.gif" title="身份已通过审核"> <%end if%> <% if rs1("vip_img")="1" then%> <img src="ioc/vip.gif" title="VIP用户"> <%end if%> <br> <br> <br></td> <td align="center"><%if trim(rs("sell_type")) = 1 then response.Write(server.htmlencode("<img src='images/jishou.gif'>")) elseif trim(rs("sell_type")) = 2 then response.Write (server.htmlencode("<img src='images/danbao.gif'>")) else response.Write( server.htmlencode("<img src='images/id.gif'>")) end if if rs("yajin") > 100 then response.Write(server.htmlencode( " <img src='images/pei.gif'>")) end if%> </td> <td align="center"><font color="#FF0000" style="font-size:18"><strong><%=rs("pro_price")%></strong></font></td> <td align="center"><%if rs("issale") = 1 then response.Write (server.htmlencode("<img src=images/tag_jyz.gif>")) elseif rs("issale") = 2 then response.Write(server.htmlencode("<img src=images/tag_jywc.gif>")) elseif rs("issale") = 3 then response.Write (server.htmlencode("")) else response.Write(server.htmlencode("未交易")) end if%></td> <td width="1%" align="center"> </td> </tr> <tr> <td height="1" colspan="6" bgcolor="#CCCCCC"></td> </tr> <%rs.movenext line=line-1 Wend %> </table></td> </tr> </table></td> </tr> <tr> <td height="30" bgcolor="#F4F4F4"> <%Call listpages(mycondition,class_1,class_2,class_3,game_type,sell_type) %></td> </tr> </table> </td> </tr> </table> <td ><a href="http://act.17173.com/os/2015/04/sjlb0403/" target="_self"><img src="guanggao/dbgg.jpg" width="980" height="58" border="0"></a> </td> <!--#include file="foot.asp"--> </body> </html>
三楼の郎 2015-02-10
  • 打赏
  • 举报
回复
引用 17 楼 abeier009 的回复:
那数据库字段tt里如果存在<script>alert('123')</script>,如果不过滤 那通过rs8("tt")读出来马上就可以显示<script>alert('123')</script>
"数据库字段tt里如果存在<script>alert('123')</script>",存在就存在呗,录入的本来就是这玩意,存储的也应该是这玩意才对,这有什么好奇怪的,不是这个东西才奇怪了,rs8("tt")读出来也应该是这东西,他们本就是一个东西应该完全相等,不知道你在这倒来倒去的干嘛,吃饱了闲的! 那通过rs8("tt")读出来马上就可以显示<script>alert('123')</script>,怎么直接显示,rs8("tt")读出来的东西又不会直接显示出来,你要显示rs8("tt")的内容不得通过以下这两种方式么 <%=rs8("tt")%> 和 <% response.write(rs8("tt")) %> 如果你直接用这种方法输出rs8("tt")的内容当然会有问题<script>部分会被当成html标签进行执行,但是如果改成 <%=server.htmlencode(rs8("tt"))%> 和 <% response.write(server.htmlencode(rs8("tt"))) %> 在页面上显示的是<script>alert('123')</script>,在页面的html源码里显示的是“<script>alert('123')</script>”,这就不会被执行,话说你知道什么是html源码不!
三楼の郎 2015-02-10
  • 打赏
  • 举报
回复

<%
dim a
a=replace(rs8("tt"),"'","''")
sql="select top 1 * from abc where dd = 'ffcc' and hh = '" & a & "' order by id"
response.write(sql)
sql="select top 1 * from abc where dd = 'ffcc' and hh = '" & replace(rs8("tt"),"'","''") & "' order by id"
response.write(sql)
%>
话说你数的清楚几个单引号几个双引号不!
阿贝儿儿 2015-02-09
  • 打赏
  • 举报
回复
是啊 就是用server.htmlencode来处理从数据库里读出来的所有数据了 但是还是显示[高危]跨站脚本攻击漏洞,这个事情我觉得宁愿信其有 不可信其无 万一有漏洞遭攻击了 那麻烦就更大了 我把文件中不断的一个一个部分删除后来进行测试,但是找不到漏洞地方啊 有没有其他办法来查出漏洞位置啊
阿贝儿儿 2015-02-09
  • 打赏
  • 举报
回复
sql="select top 1 * from abc where dd = 'ffcc' and hh = '"& replace(rs8("tt"),''','''') &"' order by id" SQL语句无法通过测试,会显示 Microsoft VBScript 编译器错误 错误 '800a03ea' 语法错误 要达到这个目的 dvHTMLEncode函数转换一下就可以达到这个目的 按你说的如果只用这个 <%=server.htmlencode(a)%> 那数据库字段tt里如果存在<script>alert('123')</script>,如果不过滤 那通过rs8("tt")读出来马上就可以显示<script>alert('123')</script> 现在把http://www.abc.com/a.asp?a=aaa <%=request("a")%> response.write(request("a")) <%=b%> 全部都套上 server.htmlencode 还显示[高危]跨站脚本攻击漏洞 所以才觉得晕啊
三楼の郎 2015-02-09
  • 打赏
  • 举报
回复
如果你只是想简单的对付360检测,只需要去找类似http://www.abc.com/a.asp?a=aaa这样传参数的页面,看看里面有没有类似 <%=request("a")%> 或者 <% response.write(request("a")) %> 或者 <% dim b b=request("a") response.write(b) %> <%=b%> 参考上面套上server.htmlencode就好了
阿贝儿儿 2015-02-09
  • 打赏
  • 举报
回复
就是把网页中所有rs("aa")改成Server.HTMLEncode(rs("aa")) request("id")改成Server.HTMLEncode(request("id")) 在SQL语句中我是用 <% function dvHTMLEncode(byval fString) if isnull(fString) or trim(fString) = "" then dvHTMLEncode = "" exit function end if fString = replace(fString, ">", "") fString = replace(fString, "<", "") fString = replace(fString, "'", "''") fString = replace(fString, CHR(32), " ") fString = replace(fString, " ", " ") dvHTMLEncode = fString end function %> sql="select top 1 * from abc where dd = 'ffcc' and hh = '"& dvHTMLEncode(rs8("tt")) &"' order by id" 我想不出还有什么地方需要用Server.HTMLEncode
三楼の郎 2015-02-09
  • 打赏
  • 举报
回复
引用 12 楼 abeier009 的回复:
是啊 就是用server.htmlencode来处理从数据库里读出来的所有数据了 但是还是显示[高危]跨站脚本攻击漏洞,这个事情我觉得宁愿信其有 不可信其无 万一有漏洞遭攻击了 那麻烦就更大了 我把文件中不断的一个一个部分删除后来进行测试,但是找不到漏洞地方啊 有没有其他办法来查出漏洞位置啊
如果你用了还被检测出问题,那就只说明一个问题,你没用好
三楼の郎 2015-02-08
  • 打赏
  • 举报
回复
如果你不太懂SQL注入方面的东西,建议你还是用Command对象进行数据库操作,用Parameter对象来包裹参数,具体方法可以参考http://blog.csdn.net/citybird/article/details/3599720
hookee 2015-02-08
  • 打赏
  • 举报
回复
XSS 和 SQL注入是两回事吧
三楼の郎 2015-02-08
  • 打赏
  • 举报
回复
360就是个垃圾,他的东西你也信
三楼の郎 2015-02-08
  • 打赏
  • 举报
回复
引用 6 楼 abeier009 的回复:
好像不行啊 把以下 sql="select top 1 * from abc where dd = 'ffcc' and hh = '"&rs8("tt")&"' order by id" 修改成 sql="select top 1 * from abc where dd = ''ffcc''and hh = '"&rs8("tt")&"' order by id" 无法显示 sql="select top 1 * from abc where dd = ‘”&ffcc&“’and hh = '"&rs8("tt")&"' order by id" 无法显示 sql="select top 1 * from abc where dd = ‘"&ffcc&"’and hh = '"&rs8("tt")&"' order by id" Microsoft VBScript 编译器错误 错误 '800a0408' sql="select top 1 * from abc where dd = '"&dvHTMLEncode("ffcc")&"' and hh = '"&rs8("tt")&"' order by id" 360检测还是高危
真2,是这样 sql="select top 1 * from abc where dd = 'ffcc' and hh = '"& replace(rs8("tt"),''','''') &"' order by id" 是把参数里的单引号替换成两个,不是把SQL语句里的单引号替换
三楼の郎 2015-02-08
  • 打赏
  • 举报
回复
替换单引号那个是sql注入攻击的解决办法之一,又不能解决跨站脚本攻击的问题,这是两个不同的问题好不啦。 跨站脚本攻击要用server.htmlencode处理,说白了就是把< > 转义成<和>,html里面<>阔起来的部分是html标签,如果你要输出<>字符应该用<>
阿贝儿儿 2015-02-08
  • 打赏
  • 举报
回复
好像不行啊 把以下 sql="select top 1 * from abc where dd = 'ffcc' and hh = '"&rs8("tt")&"' order by id" 修改成 sql="select top 1 * from abc where dd = ''ffcc''and hh = '"&rs8("tt")&"' order by id" 无法显示 sql="select top 1 * from abc where dd = ‘”&ffcc&“’and hh = '"&rs8("tt")&"' order by id" 无法显示 sql="select top 1 * from abc where dd = ‘"&ffcc&"’and hh = '"&rs8("tt")&"' order by id" Microsoft VBScript 编译器错误 错误 '800a0408' sql="select top 1 * from abc where dd = '"&dvHTMLEncode("ffcc")&"' and hh = '"&rs8("tt")&"' order by id" 360检测还是高危
阿贝儿儿 2015-02-08
  • 打赏
  • 举报
回复
谢谢CityBird 三楼一郎 说的很清楚 参考资料也写的很精辟 学习了 把单引号都变成2个单引号还是显示[高危]跨站脚本攻击漏洞,
Dogfish 2015-02-08
  • 打赏
  • 举报
回复
把单引号都变成2个单引号。这样就让单引号变成一个要处理的字串。
阿贝儿儿 2015-02-07
  • 打赏
  • 举报
回复
单引号替换成两个单引号 比如 sql="select top 1 * from abc where dd = 'ffcc' and hh = '"&rs8("tt")&"' order by id" 那要改成怎么样
suano 2015-02-07
  • 打赏
  • 举报
回复
360检测只管检测页面是不是输出了它认为危险的字符,而不会管是不是对数据库进行了操作。其实检测出来的问题并不一定真的有危险。如果你要让检测不显示所谓的存在跨域攻击,可能得对页面加载时输入的参数进行过滤,既在程序取得参数时就进行过滤而不管他是不是会要操作数据库。
slwsss 2015-02-07
  • 打赏
  • 举报
回复
单引号替换成两个单引号

28,398

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧