scapy - How can I get IP of a specific hop for traceroute in python -
addr = socket.gethostbyname('dalitstan.org') target = [addr] result, unans = traceroute(target,maxttl=32)
i doing , getting below output. there way here ip of specific hop in variable. , why hop number missing in traceroute result?
begin emission: finished send 32 packets. ************************* received 25 packets, got 25 answers, remaining 7 packets 185.53.178.6:tcp80 1 192.168.43.1 11 3 10.71.83.18 11 4 172.16.26.245 11 5 172.26.31.242 11 11 49.44.18.38 11 13 103.198.140.164 11 14 103.198.140.27 11 15 80.81.194.27 11 16 217.64.161.25 11 17 217.64.170.214 11 18 185.53.178.6 sa 19 185.53.178.6 sa 20 185.53.178.6 sa 21 185.53.178.6 sa 22 185.53.178.6 sa 23 185.53.178.6 sa 24 185.53.178.6 sa 25 185.53.178.6 sa 26 185.53.178.6 sa 27 185.53.178.6 sa 28 185.53.178.6 sa 29 185.53.178.6 sa 30 185.53.178.6 sa 31 185.53.178.6 sa 32 185.53.178.6 sa
on trying result.get_trace()['185.53.178.6'][7]
getting below error. may issue.
traceback (most recent call last): file "cens2.py", line 16, in <module> print result.get_trace()['185.53.178.6'][7] file "/usr/local/lib/python2.7/dist-packages/scapy/layers/inet.py", line 1040, in get_trace m = min(x x, y in k.itervalues() if y[1]) file "/usr/local/lib/python2.7/dist-packages/scapy/layers/inet.py", line 1040, in <genexpr> m = min(x x, y in k.itervalues() if y[1]) typeerror: 'bool' object has no attribute '__getitem__'
you can extract value hop using result.get_trace() hop 7 use result.get_trace()['185.53.178.6'][7]
>>> result.get_trace()['185.53.178.6'][7] ('203.50.6.93', false) or >>> result.get_trace()['185.53.178.6'][7][0] '203.50.6.93' >>> = result.get_trace()['185.53.178.6'][7][0] >>> '203.50.6.93'
some index checking different trace shown as.
>>> result.get_trace()['161.0.97.141'].keys() dict_keys([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20]) ^^^^ missing hop 13 ^^^^ (same hop 7) >>> item in result.get_trace()['161.0.97.141'].keys(): >>> print('row number ' + str(item) + ' hop ip : ' + result.get_trace()['161.0.97.141'][item][0]) row number 1 hop ip : 10.0.0.138 row number 2 hop ip : 10.218.192.1 row number 3 hop ip : 58.160.250.129 row number 4 hop ip : 203.50.44.36 row number 5 hop ip : 203.50.11.136 row number 6 hop ip : 203.50.11.180 row number 7 hop ip : 203.50.6.93 row number 8 hop ip : 203.50.13.98 row number 9 hop ip : 202.84.222.62 row number 10 hop ip : 202.84.136.209 row number 11 hop ip : 202.84.253.86 row number 12 hop ip : 134.159.61.46 <<< no hop 13 shown >>> row number 14 hop ip : 4.59.90.110 row number 15 hop ip : 63.245.106.96 row number 16 hop ip : 63.245.5.100 row number 17 hop ip : 63.245.79.85 row number 18 hop ip : 190.242.166.37 row number 19 hop ip : 190.112.224.132 row number 20 hop ip : 161.0.97.141
Comments
Post a Comment