addr = socket.gethostbyname('dalitstan.org')
target = [addr]
result, unans = traceroute(target,maxttl=32)
我正在这样做,并获得下面的输出。在这里有什么方法可以获得变量中特定跳转的IP。还有为什么traceroute结果中缺少一些跳数?我怎样才能得到一个特定的跳转IP地址为python的traceroute
Begin emission:
Finished to 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
在试图result.get_trace()['185.53.178.6'][7]
我得到下面的错误。可能是什么问题。
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 for 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 for x, y in k.itervalues() if y[1])
TypeError: 'bool' object has no attribute '__getitem__'
scapy的traceroute()'返回一个对象,它显然包含了所有这些信息。 scapy的文档没有关于它的细节,但是你可以很漂亮地打印对象来查看它的结构。啤酒花应该在那里以及关于失踪啤酒花的一些线索。 – mechalynx