yum -y install tcpdump graphviz ImageMagick
pip install scapy
#!/usr/bin/env python
#coding:utf-8
import os,sys,time,subprocess
import warnings,logging
warnings.filterwarnings("ignore",category=DeprecationWarning)  #屏蔽scapy无用告警信息
logging.getLogger("scapy.runtime").setLevel (logging.ERROR) #屏蔽模块IPv6多余告警

from scapy.all import traceroute
domains = raw_input('Please input one or more IP/domain: ') #接受输入的域名或IP
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")    #生成svg矢量图形
     time.sleep(1)
     subprocess.Popen("/usr/bin/convert test.svg test.png", shell=True) #svg转png格式
else:
     print "IP/domain number of errors, exit"
代码运行结果见图3-15,“-”表示路由节点无回应或超时;“11”表示扫描的指定服务无回应;“SA”表示扫描的指定服务有回应,
一般是最后一个主机IP。生成的路由轨迹图见图3-16(仅局部),“-”将使用unk*单元代替,重点路由节点将通过ASN获取所处的
运营商或IDC位置,如IP“202.102.69.210”为“CHINANET-JS-AS-AP ASNumber for CHINANET jiangsu province backbone,
CN”意思为该IP所处中国电信江苏省骨干网。

results matching ""

    No results matching ""