xss

Preventing XSS from within HTML elements

隐身守侯 提交于 2020-01-24 12:53:46
问题 Is the following enough to prevent XSS from inside HTML elements? function XSS_encode_html ( $str ) { $str = str_replace ( '&', "&", $str ); $str = str_replace ( '<', "<", $str ); $str = str_replace ( '>', ">", $str ); $str = str_replace ( '"', " "", $str ); $str = str_replace ( '\'', " '", $str ); $str = str_replace ( '/', "/", $str ); return $str; } As mentioned here: - https://www.owasp.org/index.php/Abridged_XSS_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted

如何快速发现XSS跨站攻击漏洞

两盒软妹~` 提交于 2020-01-24 06:45:26
教你如何快速发现XSS跨站攻击漏洞 什么是XSS跨站攻击? 跨站脚本攻击(Cross Site Scripting),为了不和层叠样式表(Cascading Style Sheets, CSS)的缩写混淆,故将跨站脚本攻击缩写为XSS。恶意攻击者往Web页面里插入恶意的Script代码,当用户浏览该页之时,嵌入其中Web里面的Script代码会被执行,从而达到恶意攻击用户的目的。(以上内容来自百度百科) 其实简单理解,就是我们的程序,在参数传入时,没有对输入字符串中特殊字符或字符串做合理的检查和处理,如果参数传入的内容中,包含了恶意代码,那么我们的程序就会把这段恶意代码在浏览器中执行。那么,XSS跨站攻击会给我们带来哪些危害呢?下面的这些内容,或许你并不陌生: 1、钓鱼欺骗 2、网站挂马 3、身份盗用 4、盗取网站用户信息 5、垃圾信息发送 6、劫持用户Web行为 7、XSS蠕虫 在哪些地方需要进行XSS跨站攻击的测试验证? 可传参的URL中 可输入内容的表单 怎么快速判断是否有XSS跨站攻击注入点? 即在表单填写框中直接注入攻击脚本(一般都是JS脚本),如在表单中输入JS内容后,正常预期程序是不应该让脚本执行的,如果程序没有对输入内容做有效处理,则提交后程序会执行我们输入的JS代码。 XSS跨站攻击测试示例 下面测试步骤举例以可视化当前暂未被修复的一个XSS跨站攻击点为例

跨站点脚本攻击的防范(ZT)

你。 提交于 2020-01-23 13:11:41
转帖自朋友的Blog: http://www.zhangsichu.com/blogview.asp?Content_Id=104 跨站点脚本攻击在Web开发中是个非常敏感的安全问题。 跨站点脚本攻击(XSS)FAQ 这篇文章 http://tech.idv2.com/2006/08/30/xss-faq/ 讲述了跨站点脚本攻击的常见情况。 下面摘引自原文部分章节: ------------------------------------------------------------------------ 什么是跨站脚本攻击? 跨站脚本攻击(也称为XSS)指利用网站漏洞从用户那里恶意盗取信息。用户在浏览网站、使用即时通讯软件、甚至在阅读电子邮件时,通常会点击其中的链接。攻击者通过在链接中插入恶意代码,就能够盗取用户信息。攻击者通常会用十六进制(或其他编码方式)将链接编码,以免用户怀疑它的合法性。网站在接收到包含恶意代码的请求之后会产成一个包含恶意代码的页面,而这个页面看起来就像是那个网站应当生成的合法页面一样。许多流行的留言本和论坛程序允许用户发表包含 HTML和javascript的帖子。假设用户甲发表了一篇包含恶意脚本的帖子,那么用户乙在浏览这篇帖子时,恶意脚本就会执行,盗取用户乙的 session信息。有关攻击方法的详细情况将在下面阐述。 XSS和CSS是什么意思?

Do I need to sanitize the user input Laravel

不打扰是莪最后的温柔 提交于 2020-01-22 09:39:08
问题 I am using Laravel 4 with Eloquent. When I get the user input I just use $name=Input::get('name') and then I do $a->name=$name; I don't know if the function Input::get protect me from SQL Injection and XSS. If it does not, what do I have to do to sanitize the input? And, when I show the value in my view, shall I use {{$a}} or {{{$a}}} Greetings and thanks. 回答1: Laravel uses PDO's parameter binding, so SQL injection is not something you should worry about. You should read this though. Input:

Do I need to sanitize the user input Laravel

两盒软妹~` 提交于 2020-01-22 09:38:07
问题 I am using Laravel 4 with Eloquent. When I get the user input I just use $name=Input::get('name') and then I do $a->name=$name; I don't know if the function Input::get protect me from SQL Injection and XSS. If it does not, what do I have to do to sanitize the input? And, when I show the value in my view, shall I use {{$a}} or {{{$a}}} Greetings and thanks. 回答1: Laravel uses PDO's parameter binding, so SQL injection is not something you should worry about. You should read this though. Input:

Web常见漏洞

早过忘川 提交于 2020-01-22 07:23:05
1.sql注入 2.xss(跨站脚本) XSS 概念: 通常指黑客通过HTML注入纂改了网页,插入恶意脚本,从而在用户浏览网页时,控制用户浏览器的一种攻击。 XSS 有三种: 反射型xss:只是简单地把用户输入的数据反射给浏览器,简单来说,黑客往往需要用户诱使用户点击一个恶意链接,才能攻击成功。 存储型XSS:将用户输入的数据存储在服务器端。 DOM XSS:通过修改页面的DOM节点形成的XSS。 反射型xss我之前写过关于它的文章了:https://www.cnblogs.com/xiaoqiyue/p/8645108.html 存储型xss攻击流程: 一个论坛提供了留言板功能,恶意用户在留言板内插入恶意的html或者js代码,并且提交,那么这段恶意代码就会被保存进入数据库中,然后其他用户在浏览这个论坛时,浏览器会解释执行这段恶意代码,也就说当其他用户浏览的时候,这段代码就会窃取用户的cookie(当然存储型xss还可以将网站重定向到一个钓鱼网站,或者重新更改页面内容,欺骗用户输入用户名,密码,然后提交到恶意用户的服务器上) 3.文件包含 4.命令执行 原理:由于开发人员在编写源代码时,没有对源代码中可执行的特殊函数入口做过滤,导致客户端可以提交一些cmd命令,并交由服务器程序执行。导致攻击者可以通过浏览器或者其他客户端软件提交一些cmd命令(或者bash命令)至服务器程序

刷题之旅第8站,DVWA XSS stored (low,medium,high)

点点圈 提交于 2020-01-21 17:28:33
一、什么是XSS stored XSS攻击是Web攻击中最常见的攻击方法之一,它是通过对网页注入可执行代码且成功地被浏览器 执行,达到攻击的目的,形成了一次有效XSS攻击,一旦攻击成功,它可以获取用户的联系人列表,然后向联系人发送虚假诈骗信息,可以删除用户的日志等等,有时候还和其他攻击方式同时实 施比如SQL注入攻击服务器和数据库、Click劫持、相对链接劫持等实施钓鱼,它带来的危害是巨 大的,是web安全的头号大敌。 二、DVWA 实战 1、low 难度 Name里内容有长度限制,那么就随便填, Message 中填入js 代码。 <script>alert(/xsSSSs/)</script> 成功造成XSS攻击 2、medium难度 看一下PHP源码 <?php if ( isset ( $_POST [ 'btnSign' ] ) ) { // Get input $message = trim ( $_POST [ 'mtxMessage' ] ) ; $name = trim ( $_POST [ 'txtName' ] ) ; // Sanitize message input $message = strip_tags ( addslashes ( $message ) ) ; $message = ( ( isset ( $GLOBALS [ "___mysqli

Should I sanitize HTML markup for a hosted CMS?

十年热恋 提交于 2020-01-21 11:56:29
问题 I am looking at starting a hosted CMS-like service for customers. As it would, it would require the customer to input text which would be served up to anyone that comes to visit their site. I am planning on using Markdown, possibly in combination with WMD (the live markdown preview that SO uses) for the big blocks of text. Now, should I be sanitizing their input for html? Given that there would only be a handful of people editing their 'CMS', all paying customers, should i be stripping out

How to restrict DOS attack with Web API

不问归期 提交于 2020-01-21 06:59:27
问题 I am planning to develop a internet site using MVC4 and Web APi. Its a simple application which will display a customer information based on search. For Search functionality I am calling webApi using Ajax get method (I know i should be using Post, but consider this is the current implementation). My Api call is " /api/Data/getSearchResults/?companyName='" + companyName I feel this piece of line can be used as a DOS attack to bring down my server. Is there way i can use Microsoft Anti-XSS

JS篇 同源策略、CORS、XSS、SessionCookie

女生的网名这么多〃 提交于 2020-01-21 03:27:07
同源策略: 如何引用: (iFrame指的是iframe DOM节点) 1. 引用iframe的window对象:iFrame.contentWindow 2. 引用iframe的document对象:iFrame.contentDocument,或者:iFrame.contentWindow.document 示例: 两个页面,前者页面中嵌入iframe,src指向后者: 1. test.nuomi.com/link1.vm 2. nuomi.com/link2.vm; 同源要求:Protocols, domains, and ports均相同 子域名不同的两个站:test.nuomi.com, nuomi.com,如果要通信, 都 必须设置为统一的域名:document.domain=nuomi.com; 即使其中一个已经是域名:nuomi.com,仍然需要 明确调用 :document.domain=nuomi.com; document.domain设值: 1. 只能是当前域名的suffix,否则报错:Uncaught SecurityError: Failed to set the 'domain' property on 'Document': 'test' is not a suffix of 'test.nuomi.com'. 2. 设值为com也会报错:'com'