@conf.commands.register
def traceroute(target, dport=80, minttl=1, maxttl=30, sport=RandShort(), l4=None, filter=None, timeout=2, verbose=None, **kargs):
 if (verbose is None):
  verbose = conf.verb
 if (filter is None):
  filter = '(icmp and (icmp[0]=3 or icmp[0]=4 or icmp[0]=5 or icmp[0]=11 or icmp[0]=12)) or (tcp and (tcp[13] & 0x16 > 0x10))'
 if (l4 is None):
  (a, b) = sr((IP(dst=target, id=RandShort(), ttl=(minttl, maxttl)) / TCP(seq=RandInt(), sport=sport, dport=dport)), timeout=timeout, filter=filter, verbose=verbose, **kargs)
 else:
  filter = 'ip'
  (a, b) = sr((IP(dst=target, id=RandShort(), ttl=(minttl, maxttl)) / l4), timeout=timeout, filter=filter, verbose=verbose, **kargs)
 a = TracerouteResult(a.res)
 if verbose:
  a.show()
 return (a, b)

@ conf . commands . register def traceroute ( target , dport = 80 , minttl = 1 , maxttl = 30 , sport = RandShort ( ) , l4 = None , filter = None , timeout = 2 , verbose = None , ** kargs ) : if ( verbose is None ) : verbose = conf . verb if ( filter is None ) : filter = '(icmp and (icmp[0]=3 or icmp[0]=4 or icmp[0]=5 or icmp[0]=11 or icmp[0]=12)) or (tcp and (tcp[13] & 0x16 > 0x10))' if ( l4 is None ) : ( a , b ) = sr ( ( IP ( dst = target , id = RandShort ( ) , ttl = ( minttl , maxttl ) ) / TCP ( seq = RandInt ( ) , sport = sport , dport = dport ) ) , timeout = timeout , filter = filter , verbose = verbose , ** kargs ) else : filter = 'ip' ( a , b ) = sr ( ( IP ( dst = target , id = RandShort ( ) , ttl = ( minttl , maxttl ) ) / l4 ) , timeout = timeout , filter = filter , verbose = verbose , ** kargs ) a = TracerouteResult ( a . res ) if verbose : a . show ( ) return ( a , b )
performs a traceroute to a 3rd party host cli example: .