I want a traceroute for the above output in Python.
I want the code with the number of hops between the source IP and the destination IP.
The objective of this task is to use Scapy to estimate the distance, in terms of the number of routers, between your VM and a selected destination. This is basically what is implemented by the traceroute tool. In this task, we will write our own tool. The idea is quite straightforward: just send a packet (any type) to the destination, with its Time-To-Live (TTL) field set to 1 first. This packet will be dropped by the first router, which will send us an ICMP error message, telling us that the time-to-live has exceeded. That is how we get the IP address of the first router. We then increase our TTL field to 2, send out another packet, and get the IP address of the second router. We will repeat this procedure until our packet finally reaches the destination.
It should be noted that this experiment only gets an estimated result because, in theory, not all these packets take the same route (but in practice, they may within a short period of time).
Press Es
Lab Attacker (Snapshot 1) [Running]
uetmnator
Iae
0 [bin/bash
[02/03/21]seed@Mi:~/Labls sudo python spoof.py SENDING SPOOFED ICMP PACKET ###[ IP ]# version ihl None tos Oxo len None
routepy
flags frag ttl proto icmp chksum None Src 10.0.2 dst 10.0.2.7 loptions ###[ ICMP 1## type echo-request code chksum None 0x0 seq 0x0
[02/03/21]seed@M:~/Labls sudo python traceroute.py 8.8.8.8 Traceroute 8.8.8.8 hops away: 10.0.2 hops away: 10.40.0 hops away: 140.158.26 hops away: 140.158.255 hops away= 74.200.176 hops away: 200.180.194 hops away: 200.180.78 hops away: 74.200.144.60 hops away: 108.170.252.161 hops away: 108.170.226.109 hops away: 8.8.8.8 Done 8 [02/03/21]seed@M:-/Labls
Left