xss

How do I html_escape text data in a sinatra app?

限于喜欢 提交于 2020-01-11 08:26:11
问题 I have a small Sinatra app which generates html fragments for me from an ERB template. How do I html_escape the output? The <%=h somestring %> helper does not exist in Sinatra. 回答1: Rack::Utils includes a HTML escape method. http://www.sinatrarb.com/faq.html#escape_html 回答2: require 'CGI' get '/html' do erb :view end def h(html) CGI.escapeHTML html end __END__ @@view <% File.open('my.html') do |f| %> <%=h f.read() %> <% end %> 来源: https://stackoverflow.com/questions/2123586/how-do-i-html

11个免费的Web安全测试工具

妖精的绣舞 提交于 2020-01-11 03:17:37
1.Netsparker Community Edition(Windows) 这个程序可以检测SQL注入和跨页脚本事件。当检测完成之后它会给你提供一些解决方案。 2.Websecurify(Windows, Linux, Mac OS X) 这是个简单易用的开源工具,此程序还有一些人插件支持,可以自动检测网页漏洞。运行后可生成多种格式的检测报告 3.Wapiti(Windows, Linux, Mac OS X) 这是一个用Python编写的开源的工具,可以检测网页应用程序,探测网页中存在的注入点。 4.N-Stalker Free Version(Windows) 此工具可一次检测100个以上的页面,包括跨页脚本的检测。 5.skipfish(Windows, Linux, Mac OS X) 这是一个轻量级的安全测试工具,处理速度很快,每秒可处理2000个请求。 6.Scrawlr(Windows) HP的一款免费软件,可检测SQL注入漏洞。 7.Watcher(Windows) 这个是Fiddler的插件,可在后台静默运行,可检测跨域提交等。。 8.x5s(Windows) 跟前一个一样也是Fiddler的插件,用于检测存在XSS漏洞,在网页提供给用户输入的地方是否有过滤<, >等字符。 9.Exploit-Me(Windows, Linux, Mac OS X)

Best Practice: User generated HTML cleaning

浪尽此生 提交于 2020-01-10 19:43:10
问题 I'm coding a WYSIWYG editor width designMode="on" on a iframe. The editor works fine and i store the code as is in the database. Before outputing the html i need to "clean" with php on the server-side to avoid cross-site-scripting and other scary things. Is there some sort of best practice on how to do this? What tags can be dangerous? UPDATE: Typo fixed, it's What You See Is What You Get. Nothing new :) 回答1: The best practice is to allow only certain things you know aren't dangerous, and

安全测试---AWVS简单安装介绍

不想你离开。 提交于 2020-01-10 01:50:50
使用AWVS对域名进行全局分析,深入探索: 首先,介绍一下AWVS这个工具。 Acunetix Web Vulnerability Scanner(简称AWVS)是一款知名的网络漏洞扫描工具,它通过网络爬虫测试你的网站安全,检测流行安全漏洞。伦敦时间2015年6月24日,官方发布了最新版AWVS 10。 这个工具大家可以到freebuf上去找找,在此我就不详细介绍了,现在我来介绍下是怎么使用这款犀利的神器。 我这里的AWVS是9.5版本的,是吾爱破解论坛的一位大牛破解的,在此,真心膜拜一下这位破解大牛。 好了,开始切入正题了 AWVS安装成功后,启动界面如下: 然后,我们点击左上角的new scan,添加一个即将扫描的URL:http://172.30.0.2 接着,点击下一步按钮,在scanning profile里面选择安全扫面的漏洞种类(其实就是payload) 默认,全部选择,在此,我们默认就可以了,继续点击下一步,这时候,AWVS会自动帮你 识别服务器的banner,OS类型,web中间件,服务端脚本类型等等信息,如下: 接着,点击下一步,来到这里 这个Login sequence,我要讲一下,当你的网站需要深入扫描的时候,我们就可以使用这个Login sequence功能,这个功能通过你输入网站的用户名密码登录之后,AWVS就可以扫描登录以后的权限页面,如果你不登录

常见Web安全问题攻防解析

↘锁芯ラ 提交于 2020-01-08 09:35:28
作者:studytime 原文: https://www.studytime.xin/ 简述 随着网络发展,网络信息安全的重要性,也变得越来越重要。此处整理了常见的 web 安全问题,俗话说安全无小事,也希望作为开发人员,在编码设计过程中,有所助益。 常见安全问题 XSS攻击 CSRF攻击 SQL注入攻击 文件上传漏洞 信息泄露 越权 设计缺陷 一、XSS攻击 定义:XSS (Cross Site Script),跨站脚本攻击,因缩写和 CSS (Cascading Style Sheets) 重叠,所以叫 XSS。XSS 的原理是恶意攻击者往 Web 页面里插入恶意可执行网页脚本代码,当用户浏览该页之时,嵌入其中 Web 里面的脚本代码会被执行,从而可以达到攻击者盗取用户信息或其他侵犯用户安全隐私的目的。 分类: 存储型:注入的恶意代码存储在服务器上(常用于留言板、论坛帖子、CRM),受害者请求服务器获取信息的时候,这些恶意代码就被浏览器成功执行。 反射型:注入的恶意代码没有存储在服务器上,通过引诱用户点击一个链接到目标网站进行实施攻击。 DOM型:注入的恶意代码并未显式的包含在web服务器的响应页面中,但会被页面中的js脚本以变量的形式来访问到的方式来进行实施攻击。 案例: 存储型:论坛帖子界面input输入框中,输入 <script>alert("xss")</script>

避免XSS攻击

允我心安 提交于 2020-01-08 01:11:13
遭遇XSS攻击怎么解决 XSS的攻击手段 利用JavaScript或DOM方式进行攻击,XSS(脚本注入)提交,然后进行页面展示,影响页面的正常结构,还可以做钓鱼网站,来盗取用户的信息。 比如在页面评论 <scirpt> alert("马鲁斯!!") </script> 那么别的用户进来就会弹出 马鲁斯 !! 那么评论的是一条 <scirpt> location.href = www.xxx.com </script> 那么就会跳进入这个页面,不会是自己的本页面了。 所以被人可以模仿你完全相同的网站,来跳入钓鱼网站,盗取信息。 XSS攻击的防护 拦截所有请求,将特殊字符转换成html 1.首先创建一个类实现Flter,然后再写上这条代码。 2.创建一个 HttpServletRequest 类继承HttpServletRequestWrapper。 StringEscapeUtils.escapeHtml4() 方法是 common.lang包里面的 3.把 HttpServletRequest类new过去 然后 在 web.xml中配置filter过滤器就可以了 来源: https://www.cnblogs.com/llkang/p/12164450.html

Running a query and retrieving XML from an external site

三世轮回 提交于 2020-01-07 05:21:09
问题 I am trying to use Ajax to submit a query to an external database (http://foreignserver:1234/database?query="SELECT FROM WHERE"). The query will run and create an XML file which I would like to be returned. The external server is running on Apache Tomcat. I have done some research on cross-site scripting, but: -CORS is not an option because IE7 has to be supported. It also seems unnecessarily difficult to do in Tomcat. -easyXDM is not an option. -I am trying to do this with XML, and JSONP

I am getting Cross-Site Scripting: Poor Validation on a struts call to a bean class

放肆的年华 提交于 2020-01-07 03:19:07
问题 I scanned my application in HP Fortify and getting an issue Cross-Site Scripting: Poor Validation. I am using ESAPI library. I am getting this finding on a Struts application. <%@ taglib prefix="s" uri="/struts-tags" %> <form method='post' name='<s:property value='tableBean.formName'/>' action='Notification.action'> public String printApplications() throws IOException, ServletException { request.setAttribute(TableDisplayBean.TABLE_BEAN, tableBean); } What would be the proper syntax to use

Prevent Cross site scripting attack in asp.net C#

早过忘川 提交于 2020-01-06 20:59:49
问题 Below is the code for which I got checkmarx report stating that its vulnerable to stored XSS.it says the data layer gets data from the database, for the dt element. This element’s value then flows through the code without being properly filtered or encoded and is eventually displayed to the user in aspx page. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1

web安全之XSS注入漏洞

三世轮回 提交于 2020-01-06 14:30:18
XSS攻击简介 XSS攻击通常指的是通过利用网页开发时留下的漏洞,通过巧妙的方法注入恶意指令代码到网页,使用户加载并执行攻击者恶意制造的网页程序。这些恶意网页程序通常是JavaScript,但实际上也可以包括Java、 VBScript、ActiveX、 Flash 或者甚至是普通的HTML。攻击成功后,攻击者可能得到包括但不限于更高的权限(如执行一些操作)、私密网页内容、会话和cookie等各种内容。 XSS攻击原理 HTML是一种超文本标记语言,通过将一些字符特殊地对待来区别文本和标记,例如,小于符号(<)被看作是HTML标签的开始,<title>与</title>之间的字符是页面的标题等等。当动态页面中插入的内容含有这些特殊字符(如<)时,用户浏览器会将其误认为是插入了HTML标签,当这些HTML标签引入了一段JavaScript脚本时,这些脚本程序就将会在用户浏览器中执行。所以,当这些特殊字符不能被动态页面检查或检查出现失误时,就将会产生XSS漏洞。 XSS攻击案例 1、利用XSS弹警告窗: <script>alert(‘xss’)</script> 2、获取cookie形式:<script>alert(document.cookie)</script> 3、嵌入其他网站: <iframe src=http://baidu.com width=0 height=0><