close

1 介紹

XSS 是網絡中最常見的漏洞,再配合其它的攻擊手段往往能輕易敲開服務器的大門。在各大漏洞平台中,XSS 漏洞也是數量最多的。本文介紹基於 Chromium 源碼實現的 XSS 檢測工具,該工具採用動態污染追蹤(Taint Tracking)技術,可以監測 source 與 sink 之間的數據流動過程,為人工驗證提供詳實可靠的依據。

2 工具演示視頻

(1)我的工具如何檢測 XSS?Burp Suite 靶場實踐 https://www.zhihu.com/zvideo/1505471657166282752(2)我的工具如何檢測 XSS?Burp Suite 靶場實踐 https://www.zhihu.com/zvideo/1505847898797969409視頻還在更新中… …

3 原理介紹

污點分析技術(taint analysis, 又被稱作信息流跟蹤技術)是自動檢測 XSS 的理論基礎,它是信息流分析技術的一種實踐方法, 該技術通過標記系統中的敏感數據, 進而跟蹤『標記數據』在程序中的傳播過程, 以檢測系統安全問題。

4 敏感數據

在污點分析技術中,最重要的兩個概念分別是敏感數據和傳播記錄。首先引入敏感數據的定義:由 source 開始,經過傳播後進入 sink 並引發「數據與指令的錯用」的數據被定義為敏感數據。其中 source 為污染源點,也就是數據的生產者。sink 為污染終點,也就是數據的消費者。攻擊者可以控制的輸入被稱作污染源點,常規的污染源點如下://Source 代表 document、location、elementSource.baseURISource.cookieSource.documentURISource.domainSource.URLSource.referrerSource.textContentSource.titleSource.hashSource.hostnameSource.hrefSource.pathnameSource.searchSource.classNameSource.innerHTMLSource.namespaceURI

漏洞的本質是數據與指令的錯用,所以能消費敏感數據的方法(函數或屬性)都是污染終點,常規的污染終點如下://以下是全局方法setTimeout()setInterval()Function()alert()eval()window.postMessage()//Sink 代表 document、location、elementSink.write()Sink.writeln()Sink.createComment()Sink.createTextNode()Sink.createElement()Sink.innerHTMLSink.classNameSink.innerTextSink.textContentSink.titleSink.href

5 傳播記錄

接下來引入傳播記錄的定義:被 sink 消費的數據的來源以及變化過程稱為傳播記錄。傳播記錄描述了數據從 source 到 sink 的變化過程,傳播記錄的完整性直接影響 XSS 的檢測結果。衡量傳播記錄的指標主要有:(1)傳播記錄是否全面、完整地描述了數據的變化過程;(2)傳播記錄是否可以做到字符級別的描述。

眾所周知,觸發 XSS 漏洞的字符串往往是來自於不同 source 的字符的組合,如果不能完整記錄數據變化的過程或做不到字符級別的描述,那將會產生大量的漏報。通過分析 ES 和 HTML 規範可以得知:以下的 API 可以修改字符串。做好以下這些 API 的記錄就可以最大程度保證傳播記錄的完整性。

String.prototype.anchor 用於創建 a 標籤,樣例代碼如下:

var myString = "Table of Contents";document.body.innerHTML = myString.anchor("contents_anchor");//輸出.............<a name="contents_anchor">Table of Contents</a>

1. String.prototype.big 創建帶有 big 標籤的字符串,樣例代碼如下:

var worldString = 'Hello, world';console.log(worldString.big()); // <big>Hello, world</big>

3. String.prototype.blink 創建帶有 blink 標籤的字符串,樣例代碼如下:

var worldString = 'Hello, world';console.log(worldString.blink()); // <blink>Hello, world</blink>

4. String.prototype.charAt

5. String.prototype.charCodeAt,charCodeAt() 方法返回指定位置的字符的 Unicode 編碼。返回值是 0 – 65535 之間的整數。

6. String.prototype.codePointAt()

7. String.prototype.concat,concat() 方法拼接兩個或多個字符串並返回一個新的字符串

8. String.prototype.fixed,樣例代碼如下:

var worldString = 'Hello, world';console.log(worldString.fixed()); // "<tt>Hello, world</tt>"

9. String.prototype.fontcolor,樣例代碼如下:

var worldString = 'Hello, world';console.log(worldString.fontcolor('red') + ' is red in this line');// '<font color="red">Hello, world</font> is red in this line'

10. String.prototype.fontsize

11. String.prototype.link,樣例代碼如下:

var hotText = 'MDN';var url = 'https://developer.mozilla.org/';console.log('Click to return to ' + hotText.link(url));// Click to return to <a href="https://developer.mozilla.org/">MDN</a>

12. String.prototype.italics,樣例代碼如下:

var worldString = 'Hello, world'; console.log(worldString.blink());//"<i>str</i>"

13. String.prototype.match

14. String.prototype.search

15. String.prototype.matchAll

16. String.prototype.normalize

17. String.prototype.padEnd,樣例代碼如下:

const str1 = 'Breaded Mushrooms';console.log(str1.padEnd(25, '.'));// expected output: "Breaded Mushrooms........"

18. String.prototype.padStart

19. String.prototype.repeat

20. String.prototype.replace

21. String.prototype.slice

22. String.prototype.small,樣例代碼如下:

var worldString = 'Hello, world';console.log(worldString.small()); // <small>Hello, world</small>

22. String.prototype.split

23. String.prototype.strike

24. String.prototype.sub,樣例代碼如下:

var worldString = 'Hello, world';console.log(worldString.sub()); // <sub>Hello, world</sub>

25. String.prototype.substr

26. String.prototype.substring

27. String.prototype.sup

28. String.prototype.toLocaleLowerCase

29. String.prototype.toLocaleUpperCase

30. String.prototype.toLowerCase

31. String.prototype.toUpperCase

32. String.prototype.toString

33. String.prototype.trim The trim() method removes whitespace from both ends of a string and returns a new string, without modifying the original string.

34. String.prototype.trimEnd

35. String.prototype.trimStart

36. String.prototype.valueOf

37. RegExp.prototype.exec

38. document.write

39. document.writeln

40. decodeURI encodeURI decodeURIComponent encodeURIComponent unescape escape

41. postMessage

42. 『+』 加法

總結,檢測 XSS就是記錄數據從生產者到消費者的傳播過程,這正污點分析技術的應有之義。

個人能力有限,有不足與紕漏,歡迎批評指正

原文鏈接:https://www.freebuf.com/sectool/332442.html

侵權請私聊公眾號刪文

熱文推薦

藍隊應急響應姿勢之Linux
通過DNSLOG回顯驗證漏洞
記一次服務器被種挖礦溯源
內網滲透初探 | 小白簡單學習內網滲透
實戰|通過惡意 pdf 執行 xss 漏洞
免殺技術有一套(免殺方法大集結)(Anti-AntiVirus)
內網滲透之內網信息查看常用命令
關於漏洞的基礎知識
任意賬號密碼重置的6種方法
乾貨 | 橫向移動與域控權限維持方法總匯
手把手教你Linux提權

歡迎關注LemonSec

覺得不錯點個「贊」、「在看」
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 鑽石舞台 的頭像
    鑽石舞台

    鑽石舞台

    鑽石舞台 發表在 痞客邦 留言(0) 人氣()