NTP反射型DDos攻擊FAQ/補遺

wyzsk發表於2020-08-19
作者: polestar · 2014/02/22 12:37

0x00 背景


前兩天,心傷的胖子發表了一篇《淺談基於 NTP 的反射和放大攻擊》

我之所以又寫一篇和NTP有關的文章,是因為前面有些東西沒提,或說的不夠清楚,淺陋之處,歡迎大家指正留言,我再求教改進。

名詞解釋:

ntp server :和原子鐘同步同步,或以自己為標準時間的ntp伺服器。

ntp relay server:在/etc/ntp.conf中配置頂級 伺服器,以它們為權威ntp server 的時間中繼伺服器,也向其它ntp 伺服器和終端使用者提供時間同步功能。大多數機構和個人自行搭建的ntp server均屬於這種。

ntp client :ntp 伺服器之間,ntp伺服器與終端使用者之間有多種關聯關係,其中一種為server /client 模式。所以,個人理解ntp client這個詞相對而言的。

即當一臺ntp 伺服器(代號ABC)向權威/頂級 ntp server 同步時,此時的ABC的角色就是ntp client,當其響應下層ntp server的同步請求或響應終端使用者的ntpdate請求時,ABC就是ntp server。

以上理解,如有謬誤,請指正。

ntp伺服器 關聯關係(Association Modes )參考:http://doc.ntp.org/4.2.2/assoc.html

0x01 FAQ


1. NTP Reply Flood Attack (NTP反射型DDos攻擊) 影響的範圍?

僅影響 ntp server 還是對 ntp client 也影響?

不論是ntp server 還是 ntp relay server 只要能響應monlist請求,其就應該能被利用發起NTP反射型DDos攻擊。

也就是說,只要是沒有加固的,低於 4.2.7p26 版本的 ntpd 服務(Linux平臺)應該受到此漏洞影響。Windwos平臺未測試。

個人為驗證此問題,搭建了一臺 ntp relay server做測試,其步驟也極為簡單。

環境:RHEL6.2;ntpd 4.2.4p8。

#!shell
1# yum install ntp -y 

2# vi /etc/ntp.conf 

server 0.rhel.pool.ntp.org //預設值**** 
restrict 10.10.20.0 mask 255.255.255.0 nomodify //允許同網段向此ntp relay server進行時間同步請求。 

3# service ntpd restart 

OK,搭建完成。

自己搭建的ntp relay server,測試結果如下。

#!shell
#nmap -sU -pU:123 -n --script=ntp-monlist 10.10.10.200 

Nmap scan report for 10.10.10.200 
Host is up (0.00013s latency). 
PORT STATE SERVICE 
123/udp open ntp 
| ntp-monlist: 
| Target is synchronised with 218.75.4.130 
| Public Servers (2) 
| 97.107.134.213 218.75.4.130 
| Private Clients (1) 
| 10.10.10.210 
| Other Associations (2) 
| 10.10.10.180 (You?) seen 5 times. last tx was unicast v2 mode 7 
|_ 0:0:0:0:0:0:0:1 seen 775 times. last tx was unicast v2 mode 6 

MAC Address: 00:0C:29:E1:28:65 (VMware) 
Nmap done: 1 IP address (1 host up) scanned in 2.02 seconds 

2. 一些掃描器好像是根據NTP服務版本來判斷此漏洞,且不分ntp server、ntp client端,可能誤報率會比較高,哪位高人有解決辦法?

個人理解,應該不必區分目標是 ntp server 還是 ntp client,因為所謂的 ntp server /client 應該均受影響。

國內某事業單位應急公告中的“未開啟NTP Server服務或者只開啟了NTP Client的情況不必進行任何處理;” 懷疑其對 ntp client 理解有誤,或其ntp client指的不是執行了ntpd的伺服器。理由請參考第一個回答。

3. monlist是什麼東東?跟NTP反射型DDos攻擊有何關係?

胖子的文章寫得很清楚了,我就直接引用了:

NTP 包含一個 monlist 功能,也被成為 MON_GETLIST,主要用於監控 NTP 伺服器,NTP 伺服器響應 monlist 後就會返回與 NTP 伺服器進行過時間同步的最後 600 個客戶端的 IP,響應包按照每 6 個 IP 進行分割,最多有 100 個響應包。

可執行如下指令測試:

#!shell
ntpdc -n -c monlist ntp_server-IP 

同 nmap 的指令碼掃描是一致的。

#!shell
nmap -sU -pU:123 -Pn -n --script=ntp-monlist NTP_Server_IP 

4. 相比加ACL防禦的方式,NTP官方有更簡單的緩解辦法,把monlist功能關掉就好了

http://support.ntp.org/bin/view/Main/SecurityNotice#DRDoS_Amplification_Attack_using

我倒是挺好奇升級是怎麼解決這個問題的,把這個功能預設關掉?UDP也沒法校驗源地址啊。

monlist(monitor list)是有缺陷版本的ntpd服務的一個特性,其原始碼為ntpdc.c,編譯後的檔案為/usr/sbin/ntpdc

#!shell
strings /usr/sbin/ntpdc 

可在第833行 看到這個函式(ntpd 4.2.4p8 )。

具體升級為什麼能解決,請參考第五個問題。

5. 防止ntp server被利用進行DDOS攻擊的方法?

緩解/防禦措施有以下幾種,詳見參考連結中的英文原文。

  1. 此漏洞在4.2.7以前版本均預設存在。所以將 NTP 伺服器升級到 4.2.7p26或更高版本,當前最新版本為4.2.7p430。個人在ntpd 4.2.7p422測試透過。
  2. 4.2.7以前版本,可在ntp.conf檔案中增加disable monitor選項來禁用 monlist 功能。

也可以使用restrict ... noquery 或 restrict ... ignore 來限制ntpd服務響應的源地址。個人在ntpd 4.2.4p8測試透過。

緩解措施參考:

https://www.us-cert.gov/ncas/alerts/TA14-013A

這個連結防禦部分內容如下:

Recommended Course of Action  //美國 CERT 的說明

As all versions of ntpd prior to 4.2.7 are vulnerable by default, the simplest recommended course of action is to upgrade all versions of ntpd that are publically accessible to at least 4.2.7.

However, in cases where it is not possible to upgrade the version of the service, it is possible to disable the monitor functionality in earlier versions of the software.

To disable “monlist” functionality on a public-facing NTP server that cannot be updated to 4.2.7, add the “noquery” directive to the “restrict default” line in the system’s ntp.conf, as shown below:

restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery

Secure NTP Template //多種裝置的此漏洞防禦方法

http://www.team-cymru.org/ReadingRoom/Templates/secure-ntp-template.html

0x02 綜合參考


Understanding and mitigating NTP-based DDoS attacks

NTP Reply Flood Attack (NTP反射型DDos攻擊)原載黑防2011-06》Linxinsnow[N.N.U]

《淺談基於 NTP 的反射和放大攻擊》

 

本文章來源於烏雲知識庫,此映象為了方便大家學習研究,文章版權歸烏雲知識庫!

相關文章