This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.
Traceroute is a network diagnostic tool used to trace the path that packets take from the source to a destination across an IP network. It provides information about the intermediate routers (or hops) between the source and the destination, as well as the response times for each hop.
How Traceroute Works
TTL Field in IP Header:
- Traceroute exploits the Time to Live (TTL) field in the IP header.
- TTL starts as a set value and decreases by 1 at each hop. When TTL reaches 0, the packet is discarded, and an ICMP "Time Exceeded" message is sent back to the source.
Process:
- Traceroute sends packets with incrementing TTL values:
- Packet 1: TTL = 1 (records the first hop).
- Packet 2: TTL = 2 (records the second hop).
- Continues until the destination is reached or the TTL limit is exceeded.
- Each router along the path decrements the TTL and sends an ICMP error message when TTL = 0.
- Traceroute sends packets with incrementing TTL values:
Protocol Used:
- ICMP: Commonly used on Windows (
tracertcommand). - UDP/TCP: Many traceroute implementations (e.g., Linux) send UDP or TCP packets to avoid being blocked by firewalls that filter ICMP.
- ICMP: Commonly used on Windows (
Result:
- For each TTL value, traceroute records:
- The IP address or hostname of the router.
- The round-trip time (RTT) for each probe.
- For each TTL value, traceroute records:
Running Traceroute
Linux/Unix/macOS:
- Command:
traceroute <destination> - Example:
traceroute example.com
- Command:
Windows:
- Command:
tracert <destination> - Example:
tracert example.com
- Command:
Using Nmap:
- Nmap can include traceroute as part of its scan.
- Command:
nmap --traceroute <destination>
Output of Traceroute
Traceroute displays:
- Hop Number: The position of the router in the path.
- Router's IP Address or Hostname: Information about the intermediate router.
- Round-Trip Times (RTT): Time taken for the probe packets to reach the hop and return.
Example Output:
1 192.168.1.1 (192.168.1.1) 1.123 ms 0.987 ms 1.045 ms
2 10.0.0.1 (10.0.0.1) 2.345 ms 2.456 ms 2.567 ms
3 isp.gateway.net (203.0.113.1) 12.345 ms 12.456 ms 12.567 ms
4 example.com (93.184.216.34) 20.123 ms 20.234 ms 20.345 ms
Key Options for Traceroute (Linux)
-n: Do not resolve hostnames; display only IP addresses.traceroute -n example.com-I: Use ICMP instead of UDP.traceroute -I example.com-T: Use TCP instead of UDP.traceroute -T example.com-p <port>: Specify the port to send packets.traceroute -p 80 example.com-m <hops>: Set the maximum number of hops.traceroute -m 20 example.com
Use Cases of Traceroute
Troubleshooting Network Issues:
- Identify slow or unreachable hops in the network path.
- Detect bottlenecks and problematic routers.
Mapping Network Paths:
- Understand the path packets take through a network.
- Visualize network topology.
Firewall and Security Checks:
- Test which protocols are allowed by intermediate routers.
- Identify hops where traffic might be filtered or blocked.
Limitations of Traceroute
Firewall Restrictions:
- Firewalls may block ICMP or UDP packets, leading to incomplete results.
- Some routers may silently drop packets or limit TTL-exceeded responses.
Asymmetric Routing:
- Traceroute shows only the forward path, not the reverse path. The route back to the source may be different.
Performance Impact:
- Repeated probes can temporarily stress intermediate routers, causing inaccurate RTT measurements.
Hidden Hops:
- Some routers are configured to suppress ICMP TTL-exceeded responses, causing gaps in traceroute output (e.g.,
* * *).
- Some routers are configured to suppress ICMP TTL-exceeded responses, causing gaps in traceroute output (e.g.,
Traceroute remains a vital tool for network diagnostics, offering insights into routing and connectivity issues in diverse environments.