xss

Why can't we have some AntiXss Literal html tag

混江龙づ霸主 提交于 2019-12-24 08:37:12
问题 Nowadays I am learning about web security, XSS, etc. As XSS basically targets a client-agent (web browser) by injecting some malicious code that is executed by the web browser as it was inserted by an authenticated user. Now the question is Why can't we have a tag in html that just shows literals and prevents the execution of anything inside it? Something like: <!-- The code below will not be executed and just treated as literal content by a web browser --> <ltrl> <script type="text

xss攻击入门

烈酒焚心 提交于 2019-12-24 07:12:52
xss表示Cross Site Scripting(跨站脚本攻击),它与SQL注入攻击类似,SQL注入攻击中以SQL语句作为用户输入,从而达到查询/修改/删除数据的目的,而在xss攻击中,通过插入恶意脚本,实现对用户游览器的控制。 xss攻击可以分成两种类型: 非持久型攻击 持久型攻击 下面我们通过具体例子,了解两种类型xss攻击。 1.非持久型xss攻击 顾名思义,非持久型xss攻击是一次性的,仅对当次的页面访问产生影响。非持久型xss攻击要求用户访问一个被攻击者篡改后的链接,用户访问该链接时,被植入的攻击脚本被用户游览器执行,从而达到攻击目的。 假设有以下index.php页面: <?php $name = $_GET['name']; echo "Welcome $name<br>"; echo "<a href="http://www.cnblogs.com/bangerlee/">Click to Download</a>"; ?> 该页面显示两行信息: 从URI获取 'name' 参数,并在页面显示 显示跳转到一条URL的链接 这时,当攻击者给出以下URL链接: index.php?name=guest<script>alert('attacked')</script> 当用户点击该链接时,将产生以下html代码,带'attacked'的告警提示框弹出: Welcome

New Way To Prevent XSS Attacks

本小妞迷上赌 提交于 2019-12-24 04:56:10
问题 I have a website related to entertainment. So, I have thought to use a new method to prevent XSS Attack. I have created the following words list alert(, javascript, <script>,<script,vbscript,<layer>, <layer,scriptalert,HTTP-EQUIV,mocha:,<object>,<object, AllowScriptAccess,text/javascript,<link>, <link,<?php, <?import, I have thought that because my site is related to entertainment, So I do not expect from a normal user (other than malicious user) to use such kind of words in his comment. So,

Why does React.js' API warn against inserting raw HTML?

拈花ヽ惹草 提交于 2019-12-24 02:18:40
问题 From the tutorial But there's a problem! Our rendered comments look like this in the browser: " <p>This is <em>another</em> comment</p> ". We want those tags to actually render as HTML. That's React protecting you from an XSS attack. There's a way to get around it but the framework warns you not to use it: ... <span dangerouslySetInnerHTML={{__html: rawMarkup}} /> This is a special API that intentionally makes it difficult to insert raw HTML, but for Showdown we'll take advantage of this

XSS 漏洞原理及防御方法

烈酒焚心 提交于 2019-12-24 00:38:00
XSS跨站脚本攻击:两种情况。一种通过外部输入然后直接在浏览器端触发,即反射型XSS;还有一种则是先把利用代码保存在数据库或文件中,当web程序读取利用代码并输出在页面上时触发漏洞,即存储型XSS。DOM型XSS是一种特殊的反射型XSS。 危害:前端页面能做的事它都能做。(不仅仅盗取cookie、修改页面等) 1、 挖掘经验 XSS挖掘的关键在于寻找有没有被过滤的参数,且这些参数传入到输出函数。 常用输出函数:print、print_r、echo、printf、sprintf、die、var_dump、var_export,所以只要寻找带有变量的这些函数即可。 XSS漏洞挖掘受浏览器影响比较大,最重要的还要掌握各种浏览器容错、编码等特性和数据协议。 常出现场景:文章发表、评论、留言、注册资料的地方、修改资料的地方等; 2、 反射型XSS 黑盒测试时:只需要将尖括号、单双引号等提交到web服务器,检查返回的html页面里面有没有保留原来的特殊字符即可判断; 白盒测试时:只需寻找带有参数的输出函数,然后根据输出函数对输出的内容回溯输入参数,观察有没有过滤; 例如: 代码中:oauth_signature 参数未经任何过滤,直接输出,则可以直接用GET方式注入代码。 3、 存储型XSS 就是需要先把利用代码保存在例如数据库或文件中,当web

WEB漏洞 XSS(一)

天大地大妈咪最大 提交于 2019-12-24 00:37:23
1、xss的形成原理 xss 中文名是“跨站脚本攻击”,英文名“Cross Site Scripting”。 xss也是一种注入攻击,当web应用对用户输入过滤不严格,攻击者写入恶意的脚本代码(HTML、JavaScript)到网页中时,如果用户访问了含有恶意代码的页面,恶意脚本就会被浏览器解析执行导致用户被攻击。 常见的危害有:cookie窃取,session劫持,钓鱼攻击,蠕虫,ddos等。 2、xss的分类 xss根据特性和利用方式可以分成三大类,反射性xss 、存储型xss、DOM型xss、 反射性: 一般出现在URL参数中,以及网站搜索栏中,由于需要点击包含恶意代码的URL才可以触发,并且只能触发一次,也称为非持久性xss。 存储型:一般出现在留言板上,评论处,个人资料填写,等需要用户可以对网站写入数据的地方,比如一个论坛处由于对用户输入过滤不严格,导致攻击者在写入一段窃取cookie的恶意JavaScript代码到评论处,这段恶意代码会写入数据库中,当其他用户浏览写入代码的页面时,网站从数据库中读取恶意代码显示到网页中被浏览器执行,导致用户的cookie被窃取攻击者无需受害者密码既可以登陆账户,所以也被成为持久性xss,持久性xss比反射性xss危害性大得多。 3、dom型xss DOM xss是基于dom文件对象模型的,前端脚本通过dom动态修改页面

XSS javascript, exploit check

夙愿已清 提交于 2019-12-24 00:05:04
问题 I am currently working on a page where I need the user to input several variables which when submitted are then displayed throughout the page. Problem is, it needs to be 100% secure code and whilst I'm ok using PDO/mysql etc javascript is not something I'm very fluent in. At the moment, I have the following: <script language="JavaScript"> function showInput() { document.getElementById('var1').innerText = document.getElementById("user_var1").value; document.getElementById('var2').innerText =

XSS Attacks Prevention

半世苍凉 提交于 2019-12-23 16:23:43
问题 I've found a "database" of many XSS attacks and while this list provides quite a big list of attacks are there are any other attacks that didn't fall in the XML, what to look out for and most unexpected? 回答1: I've used HTML Purifier to allow users to input only specific, safe, HTML into comment text boxes before. It does a very nice job, and has very good documentation. For everything else, like a simple text box, or select box, when writing the value to the page I always run it through

Example of bad React dangerouslySetInnerHTML?

折月煮酒 提交于 2019-12-23 13:06:36
问题 Is there an example of misuse of dangerouslySetInnerHTML in ReactJS? Everytime I look this up, it's just someone waving their hand and saying "cross site scripting." I've seen dangerouslySetInnerHTML used to load CSS files with a css loading npm module: import {stylesheet, classNames} from '../static/css/styles.css' <Head><style dangerouslySetInnerHTML={{__html: stylesheet}} /></Head> And I'm contemplating using dangerouslySetInnerHTML for some script tags for social media share buttons that

Securely posting and then printing JavaScript tags

久未见 提交于 2019-12-23 12:51:12
问题 I am trying to develop a back-end Ad Checking application in PHP. We have lots of places where ads can be shown and almost all of them has its unique requirements (they are shown inside games, that is why everyone is different in size, weight, format, etc.). Since this can cause lots of confusions on campaigns targeting different games (with the agencies sending us ads with the wrong formats), we need to check every ad to make sure it works as expected. The application works fine if our