标签:scapy
scapy模块安装yum install tcpdump graphviz ImageMagick
打开 https://pypi.org/project/scapy/2.3.3/#files
下载scapy-2.3.3.tar.gz
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 = [80] if len(target) >= 1 and target[0]!='': 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
[root@zabbix-agent home]# 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
1 192.168.1.1 11
2 100.64.0.1 11
3 59.38.106.57 11
5 113.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版本正好
标签:scapy
原文地址:http://blog.51cto.com/superleedo/2118187