Hacker News new | past | comments | ask | show | jobs | submit login
Traceroute in 15 lines of code using Scapy (jvns.ca)
34 points by jvns on Nov 1, 2013 | hide | past | favorite | 2 comments



Pretty nifty. One of the things traceroute also does is to deal with broken routers that don't send the proper replies, as well as a number of other edge cases, but this is a cool toy and will probably work in most average cases.

see also:

http://cluepon.net/ras/traceroute.pdf and http://blog.cachefly.com/2012/02/15/understanding-traceroute...


I've just started using scapy recently. The syntax is a little inconsistent, but it's really powerful. It defines a domain-specific language (DSL) that piggybacks on python syntax. You can make a traceroute-like object in one line:

  pkt = IP(dst=target, ttl=(4,25),id=RandShort())/TCP(flags=0x2)
This single pkt object describes 22 IP packets, each with a TTL from 4 to 24 inclusive. Each IP packet encapsulates a TCP packet with the SYN flag set.

http://www.secdev.org/projects/scapy/doc/usage.html#tcp-trac...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: