Linux/모의해킹

IP 헤더에서 TTL 값 변경하기

GGkeeper 2021. 12. 30. 15:46

실습> IP 헤더에서 TTL 값 변경하기

o mangle table 의 TTL값 변경하기

Attacker ~# iptables -t mangle -nL

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         


Attacker ~# ping -c 5 192.168.108.2
PING 192.168.108.2 (192.168.108.2) 56(84) bytes of data.
64 bytes from 192.168.108.2: icmp_seq=1 ttl=128 time=0.289 ms
64 bytes from 192.168.108.2: icmp_seq=2 ttl=128 time=0.260 ms
64 bytes from 192.168.108.2: icmp_seq=3 ttl=128 time=0.201 ms
64 bytes from 192.168.108.2: icmp_seq=4 ttl=128 time=0.183 ms
64 bytes from 192.168.108.2: icmp_seq=5 ttl=128 time=0.232 ms

--- 192.168.108.2 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4184ms
rtt min/avg/max/mdev = 0.183/0.233/0.289/0.038 ms

Attacker ~# iptables -t mangle -A PREROUTING -j TTL --ttl-set 10

Attacker ~# ping -c 5 192.168.108.2
PING 192.168.108.2 (192.168.108.2) 56(84) bytes of data.
64 bytes from 192.168.108.2: icmp_seq=1 ttl=10 time=0.478 ms
64 bytes from 192.168.108.2: icmp_seq=2 ttl=10 time=0.210 ms
64 bytes from 192.168.108.2: icmp_seq=3 ttl=10 time=0.232 ms
64 bytes from 192.168.108.2: icmp_seq=4 ttl=10 time=0.251 ms
64 bytes from 192.168.108.2: icmp_seq=5 ttl=10 time=0.252 ms

--- 192.168.108.2 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4142ms
rtt min/avg/max/mdev = 0.210/0.284/0.478/0.097 ms

Attacker ~# 

Attacker ~# iptables -t mangle -nL

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
TTL        all  --  0.0.0.0/0            0.0.0.0/0            TTL set to 10

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination


Attacker ~# iptables -t mangle -nvL

Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
   43  2668 TTL        all  --  *      *       0.0.0.0/0            0.0.0.0/0            TTL set to 10

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Attacker ~# iptables -t mangle -A POSTROUTING -j TTL --ttl-set 3

Attacker ~# iptables -t mangle -nL

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
TTL        all  --  0.0.0.0/0            0.0.0.0/0            TTL set to 10

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
TTL        all  --  0.0.0.0/0            0.0.0.0/0            TTL set to 3


TTL을 3으로 변경했기 때문에 8.8.8.8까지 갈 수 없다.
Attacker ~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
^C
--- 8.8.8.8 ping statistics ---
25 packets transmitted, 0 received, 100% packet loss, time 25119ms

Attacker ~# iptables -t mangle -F

Attacker ~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=46.7 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=46.8 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1019ms
rtt min/avg/max/mdev = 46.703/46.731/46.759/0.028 ms