XSS for domain takeover

TLDR

(with thanks to CapnWarhol for the summary)

- If you can execute XSS code on a site, you can set cookies
- If you can set cookies, there may be one which outputs in-page on every request
- If you save script in that cookie, you can send <script>window.location.href=“http://my-website.com/”</script> with every infected request, and functionally “take over” the domain.


Who doesn’t love XSS? Simple to find, simple to execute, and sometimes simple to bypass XSS auditors.

For bypassing Chrome auditor, if the XSS is printed directly in a <script> tag then it’ll bypass the XSS auditor. Example: index.php?value=123
Prints into HTML: <script>var value=‘123’;</script> - so if we use index.php?value=k’-alert(0)-‘k, then our xss will execute bypassing all auditors.

Firefox is simple.. no XSS protection. Safari (for mobile users) is typically the same as Chrome and blocks most stuff, and IE? Well who uses IE.

C‘mon, show me the XSS domain takeover

Ok so onward to how XSS can take over domains! First, we must find a vulnerable cookie that is printed into the DOM of the HTML, and for this example we’re going to use InstaShag.com.

In the screenshot below, we can see if the cookie “site” is set to XSS, it’ll be printed into the DOM of the HTML. This is our vulnerable cookie.

Notice how it also sets the cookie value back to the XSS? So this is persisent. Brilliant. Now we need XSS to set this cookie.

5 mins later…

That was easy! Now let’s create a script to set the cookie. (With thanks to google because i’m lazy to code JS).

So this will remove the cookie, and re-set it to our XSS. Now let’s visit Instashag.com and see what happens…

So simple XSS just injected xss to the cookie, and now anytime someone visits my site, then visits instashag.com, will have the XSS executed.

Note: They only have to visit my site ONCE to have the XSS injected to the cookie. From then on anytime they visit Instashag, XSS will execute (if you set the cookie length to expire in like a year or w/e).

So how did you take over the domain?

Set the XSS to <script>top.location.href=‘http://www.yoursite.com/’;</script> and they’ll be instantly redirected. :)

So is this bad?

Well of course. Many companies who run bug bounties tend to pay low amounts because it’s “nothing special”. XSS exists on so many sites. Imagine if your bank had XSS on it (aswell as a vuln cookie), and you was just browsing the internet minding your own business. Behind the scenes, XSS could of executed without you knowing. Now when you try visit your bank, you could be redirected to a malicious site. Bad huh? But of course, they could of also stole your cookie sessions etc etc.

时间: 2025-01-12 18:48:16

XSS for domain takeover的相关文章

Hijacking tons of Instapage expired users Domains &amp; Subdomains

Hello all  so this post is about how I was able to hijack ton’s of domains/subdomains who using Instapage if there service got expired. What is instapage ? Instapage is a service that lets you build landing pages for your online marketing and promoti

Web安全--XSS现代WAF规则探测及绕过技术

XSS现代WAF规则探测及绕过技术初始测试 1.使用无害的payload,类似<b>,<i>,<u>观察响应,判断应用程序是否被HTML编码,是否标签被过滤,是否过滤<>等等: 2.如果过滤闭合标签,尝试无闭合标签的payload(<b,<i,<marquee)观察响应: 3.尝试以下的payload 1 <script>alert(1);</script> 2 <script>prompt(1);<

较有意思的Apple XSS(CVE-2016-7762)漏洞

文章作者:Avfisher0x00 前言应CVE作者的要求帮忙分析一下这个漏洞,实际上这是一个思路比较有意思的Apple XSS(CVE-2016-7762).漏洞作者确实脑洞比较大也善于尝试和发掘,这里必须赞一个!0x01 分析与利用官方在2017年1月24日发布的安全公告中如下描述: 可利用设备:iPhone 5 and later, iPad 4th generation and later, iPod touch 6th generation and later 漏洞影响:处理恶意构造的

XSS与CSRF(一)

XSS 概念 XSS(Cross Site Scripting)跨站脚本攻击是指攻击者利用网站程序对用户输入过滤不足,输入可以显示在页面上对其他用户造成影响的HTML代码,从而盗取用户资料.利用用户身份进行某种动作或者对访问者进行病毒侵害的一种攻击方式.为了与层叠样式表(Cascading Style Sheets)的缩写CSS区分开,跨站脚本攻击通常简写为XSS. 原理就是:恶意攻击者往Web页面里插入恶意html代码,当用户浏览该页之时,嵌入其中Web里面的html代码会被执行,从而达到恶意

JSONP存在的JSON Hijacking漏洞以及与csrf/xss漏洞的关系

在实习过程中接触过所谓的JSON Hijacking 漏洞,但最近在写论文时发现理解得不深,好像跟xss与csrf又有点区别与联系,索性深入学习了下 JSONP. 下面一段话截取自:http://stackoverflow.com/questions/2067472/what-is-jsonp-all-about   仔细看看就比较清晰了. Say you're on domain abc.com, and you want to make a request to domain xyz.com

XSS - 禁止浏览器读取Cookie - HttpOnly

1.什么是HttpOnly? 如果您在cookie中设置了HttpOnly属性,那么通过js脚本将无法读取到cookie信息,这样能有效的防止XSS攻击,具体一点的介绍请google进行搜索.   C#  HttpCookie myCookie = new HttpCookie("myCookie");   myCookie.HttpOnly = true;   Response.AppendCookie(myCookie); javaee response.setHeader(&qu

XSS前置课程--同源策略

什么是同源策略: 在用户浏览互联网中的网页的过程中,身份和权限的思想是贯穿始终的 同源策略(Same-Origin Policy),就是为了保证互联网之中,各类资源的安全性而诞生的产物,它实际上是一个众多浏览器厂商共同遵守的约定.同源策略是浏览器中基本的安全功能,缺少同源策略,很多浏览器的常规功能都会受到影响,可以说WEB是构建在同源策略基础之上的. 如果WEB世界没有同源策略,当你登录FreeBuf账号并打开另一个站点时,这个站点上的JavaScript可以跨越读取你的FreeBuf账号数据,

XSS跨站点脚本的介绍和代码防御

0x01 介绍 可能会窃取或操纵客户会话和 cookie,它们可能用于模仿合法用户,从而使黑客能够以该用户身份查看或变更用户记录以及执行事务在以下情况下会发生跨站点脚本编制 (XSS) 脆弱性: [1] 不可信数据进入 Web 应用程序,通常来自 Web 请求. [2] Web 应用程序动态生成了包含此不可信数据的 Web 页面. [3] 页面生成期间,应用程序不会禁止数据包含可由 Web 浏览器执行的内容,例如 JavaScript.HTML 标记.HTML 属性.鼠标事件.Flash 和 A

《白帽子讲WEB安全》学习笔记之第3章 跨站脚本攻击(xss)

第3章 跨站脚本攻击(xss) 3.1 xss简介 恶意攻击者往Web页面里插入恶意html代码,当用户浏览该页之时,嵌入其中Web里面的html代码会被执行,从而达到恶意用户的特殊目的. XSS攻击:跨站脚本攻击(Cross Site Scripting),为不和层叠样式表(Cascading Style Sheets, CSS)的缩写混淆.故将跨站脚本攻击缩写为XSS. XSS本质就是HTML注入 XSS的分类: (1)     反射型XSS: 一个恶意构造了Web的URL (2)