DOM Based Cross Site Scripting

简介: 版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明http://superhei.

版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://superhei.blogbus.com/logs/10578816.html

现在xss非常流行.而且跑xss的工具到处都是,导致就和sqlinj一样,很多大站 基本很难找到很明显的xss bug了,以往我们查找xss 一般都黑盒,而且效果很明显,对于白盒,一般都是基于Server language如[php/asp/jsp ....]查找变量输出语句如:print/echo ….等.

今天刚看看大牛Amit Klein在2005写[DOM Based Cross Site Scripting or XSS of the Third Kind]:http://www.webappsec.org/projects/articles/071105.html 提到的DOM的xss比上面提到的那些更加难以发现,就luoluo牛说的找基于dom的xss才是王道 :)
找这类的xss需要分析js本身的代码,这样我们可以就和分析Server language的一些漏洞一样分析js了: 就和php等一样漏洞的产生是: 变量—>输出函数 ,而js是 变量—>输出给浏览器 那么我们要找dom-xss就是分析变量的’提取’和’输出’语句了

比如变量的’输出’给浏览器执行的一些对象:document.write,eval …等等
变量’输入/提取’:document的一些对象 如document.URL document.location …等等

就和Amit Klein文章里列举的那些:

2. Analyzing and hardening the client side (Javascript) code. Reference to DOM objects that may be influenced by the user (attacker) should be inspected, including (but not limited to):

document.URL
document.URLUnencoded
document.location (and many of its properties)
document.referrer
window.location (and many of its properties)
Note that a document object property or a window object property may be referenced syntactically in many ways – explicitly (e.g. window.location), implicitly (e.g. location), or via obtaining a handle to a window and using it (e.g. handle_to_some_window.location).

Special attention should be given to scenarios wherein the DOM is modified, either explicitly or potentially, either via raw access to the HTML or via access to the DOM itself, e.g. (by no means an exhaustive list, there are probably various browser extensions):

Write raw HTML, e.g.:
document.write(…)
document.writeln(…)
document.body.innerHtml=…
Directly modifying the DOM (including DHTML events), e.g.:
document.forms[0].action=… (and various other collections)
document.attachEvent(…)
document.create…(…)
document.execCommand(…)
document.body. … (accessing the DOM through the body object)
window.attachEvent(…)
Replacing the document URL, e.g.:
document.location=… (and assigning to location’s href, host and hostname)
document.location.hostname=…
document.location.replace(…)
document.location.assign(…)
document.URL=…
window.navigate(…)
Opening/modifying a window, e.g.:
document.open(…)
window.open(…)
window.location.href=… (and assigning to location’s href, host and hostname)
Directly executing script, e.g.:
eval(…)
window.execScript(…)
window.setInterval(…)
window.setTimeout(…)
那么我们分析dom-xss就可以直接分析那些js的函数了,那么我们怎么分析呢,和PHP等一样我们可以用grep等一些静态的方法,那么动态的方法呢? 可以使用基于proxy的中间自动fuzz,还有luoluo提出的js函数的’hook’等等 …期待luoluo牛的fuzz-tool

另外在利用或者触发dom-xss要注意一个js的特点就是[js闭合标签优先]:http://superhei.blogbus.com/logs/10073294.html的特点.
最后感谢luoluo牛的耐心的指导,还有jx分享他的0day :)

目录
相关文章
|
监控 JavaScript 安全
DOM Based XSS的防范措施有哪些
【8月更文挑战第25天】DOM Based XSS的防范措施有哪些
330 3
|
JavaScript 安全 前端开发
介绍DOM Based XSS
【8月更文挑战第25天】介绍DOM Based XSS
386 1
|
JavaScript 安全
DOM XSS Scanner - Find DOM based XSS Security Vulnerabilities
https://github.com/yaph/domxssscanner http://code.
1066 0
|
XML JavaScript 数据格式
XML DOM 遍历节点树
XML DOM 遍历节点树
|
JavaScript
DOM 节点列表长度(Node List Length)
DOM 节点列表长度(Node List Length)
|
JavaScript
DOM 节点列表长度(Node List Length)
DOM 节点列表长度(Node List Length)
|
JavaScript
HTML DOM 节点树
HTML DOM 节点是指在 HTML 文档对象模型中,文档中的所有内容都被视为节点。整个文档是一个文档节点,每个 HTML 元素是元素节点,元素内的文本是文本节点,属性是属性节点,注释是注释节点。DOM 将文档表示为节点树,节点之间有父子和同胞关系。
|
JavaScript
HTML DOM 节点
HTML DOM(文档对象模型)将HTML文档视为节点树,其中每个部分都是节点:文档本身是文档节点,HTML元素是元素节点,元素内的文本是文本节点,属性是属性节点,注释是注释节点。节点间存在父子及同胞关系,形成层次结构。
|
XML JavaScript 数据格式
XML DOM 遍历节点树
XML DOM 遍历节点树
|
JavaScript
DOM 节点列表长度(Node List Length)
DOM 节点列表长度(Node List Length)