Python使用scapy生产动态路由图
scapy模块安装yum install tcpdumpgraphviz ImageMagick
打开 https://pypi.org/project/scapy/2.3.3/#files
下载scapy-2.3.3.tar.gz
wget https://files.pythonhosted.org/packages/ac/14/c792a14b9f8bc4bb9c74c0594c167a2da36e31964098d9e27202142cbd7d/scapy-2.3.3.tgz
tar zxf scapy-2.3.3.tar.gz
cd scapy-2.3.3
python setup.py install
探测百度的路由图
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os,sys,time,subprocess
import warnings,logging
warnings.filterwarnings("ignore", category=DeprecationWarning)
#logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import traceroute
domains = raw_input('Please input one or more IP/domain: ')
target =domains.split(' ')
dport =
if len(target) >= 1 and target!='':
res,unans = traceroute(target,dport=dport,retry=-2)
res.graph(target="> test.svg")
time.sleep(1)
subprocess.Popen("/usr/bin/convert test.svg test.png", shell=True)
else:
print "IP/domain number of errors,exit"
执行 Python png.py
生成test.png
# python simple.py
Please input one or more IP/domain: www.baidu.com
Begin emission:
*Finished to send 30 packets.
************************Begin emission:
Finished to send 5 packets.
Begin emission:
Finished to send 5 packets.
Received 25 packets, got 25 answers, remaining 5 packets
14.215.177.38:tcp80
1192.168.1.1 11
2100.64.0.1 11
359.38.106.57 11
5113.96.4.14 11
10 14.215.177.38 SA
11 14.215.177.38 SA
12 14.215.177.38 SA
13 14.215.177.38 SA
14 14.215.177.38 SA
15 14.215.177.38 SA
16 14.215.177.38 SA
17 14.215.177.38 SA
18 14.215.177.38 SA
19 14.215.177.38 SA
20 14.215.177.38 SA
21 14.215.177.38 SA
22 14.215.177.38 SA
23 14.215.177.38 SA
24 14.215.177.38 SA
25 14.215.177.38 SA
26 14.215.177.38 SA
27 14.215.177.38 SA
28 14.215.177.38 SA
29 14.215.177.38 SA
30 14.215.177.38 SA
注意scapy版本高版本2.4会报错
用2.3.3版本正好
页:
[1]