溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

通過iptables 修改數(shù)據(jù)包TTL,來隱藏traceroute 時的路由跳數(shù)

發(fā)布時間:2020-07-05 02:18:38 來源:網(wǎng)絡(luò) 閱讀:7181 作者:lihongweibj 欄目:網(wǎng)絡(luò)安全

原理

程序利用增加存活時間(TTL)值來實現(xiàn)其功能的。每當數(shù)據(jù)包經(jīng)過一個路由器,其存活時間就會減1。當其存活時間是0時,主機便取消數(shù)據(jù)包,并發(fā)送一個ICMP TTL數(shù)據(jù)包給原數(shù)據(jù)包的發(fā)出者。

程序發(fā)出的首3個數(shù)據(jù)包TTL值是1,之后3個是2,如此類推,它便得到一連串數(shù)據(jù)包路徑。注意IP不保證每個數(shù)據(jù)包走的路徑都一樣。

?

實現(xiàn)

主叫方首先發(fā)出 TTL=1 UDP 數(shù)據(jù)包,第一個路由器將 TTL 10后就不再繼續(xù)轉(zhuǎn)發(fā)此數(shù)據(jù)包,而是返回一個 ICMP 超時報文,主叫方從超時報文中即可提取出數(shù)據(jù)包所經(jīng)過的第一個網(wǎng)關(guān)地址。然后又發(fā)出一個 TTL=2 UDP 數(shù)據(jù)包,可獲得第二個網(wǎng)關(guān)地址,依次遞增 TTL 便獲取了沿途所有網(wǎng)關(guān)地址。

需要注意的是,并不是所有網(wǎng)關(guān)都會如實返回 ICMP 超時報文。出于安全性考慮,大多數(shù)防火墻以及啟用了防火墻功能的路由器缺省配置為不返回各種 ICMP 報文,其余路由器或交換機也可被管理員主動修改配置變?yōu)椴环祷?/span> ICMP 報文。因此 Traceroute 程序不一定能拿全所有的沿途網(wǎng)關(guān)地址。所以,當某個 TTL 值的數(shù)據(jù)包得不到響應(yīng)時,并不能停止這一追蹤過程,程序仍然會把 TTL 遞增而發(fā)出下一個數(shù)據(jù)包。一直達到默認或用參數(shù)指定的追蹤限制(maximum_hops)才請勿追蹤。

依據(jù)上述原理,利用了 UDP 數(shù)據(jù)包的 Traceroute 程序在數(shù)據(jù)包到達真正的目的主機時,就可能因為該主機沒有提供 UDP 服務(wù)而簡單將數(shù)據(jù)包拋棄,并不返回任何信息。為了解決這個問題,程序設(shè)計者使用了一個技巧,因 UDP 協(xié)議規(guī)定端口號必須小于 30000 ,他故意違反協(xié)議設(shè)置了一個大于 30000 的端口號,所以目標主機收到數(shù)據(jù)包后唯一能做的事就是返回一個“端口不可達”的 ICMP 報文,于是主叫方就將端口不可達報文當作跟蹤退出的標志。

?

?

隱藏此后的4跳路由

Iptables -t mangle -A PREROUTING -m ttl --ttl-gt 1 -j TTL --ttl-inc 4

在PREROUTING鏈上抓數(shù)據(jù)包只要是TTL大于1的 ?將TTL加4.

?

驗證配置

iptables -t mangle -nvL

Chain PREROUTING (policy ACCEPT 684G packets, 41T bytes)

?pkts bytes target???? prot opt in???? out???? source?????????????? destination????????

?684G?? 41T TTL??????? all? --? *????? *?????? 0.0.0.0/0??????????? 0.0.0.0/0?????????? TTL match TTL > 1 TTL increment by 4

?

?

Ttl? (match TTL value)

?????? This module matches the time to live field in the IP header.

?

?????? --ttl-eq ttl

????????????? Matches the given TTL value.

?

?????? --ttl-gt ttl

????????????? Matches if TTL is greater than the given TTL value.

?

?????? --ttl-lt ttl

????????????? Matches if TTL is less than the given TTL value.

?

?TTL? (change TTL value)

?????? This? is? used? to modify the IPv4 TTL header field.? The TTL field determines how many hops (routers) a packet can traverse

?????? until it’s time to live is exceeded.

?

?????? Setting or incrementing the TTL field can potentially be very dangerous, so it should be avoided at any cost.

?

?????? Don’t ever set or increment the value on packets that leave your local network!? mangle table.

?

?????? --ttl-set value

????????????? Set the TTL value to ‘value’.

?

?????? --ttl-dec value

????????????? Decrement the TTL value ‘value’ times.

?

?????? --ttl-inc value

????????????? Increment the TTL value ‘value’ times.

禁止PC機上tracert

?iptables -A FORWARD? -p icmp -m length --length 92 -j DROP

length

?????? This? module? matches? the? length of the layer-3 payload (e.g. layer-4

?????? packet) of a packet against a specific value or range of values.

?

?????? [!] --length length[:length]


向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI