通过traceroute追踪并打印成图片
#!/usr/bin/evn python #-*-coding:utf-8 -*- import time import logging,warnings import subprocess import socket # eclipse的pydev提示unresolve,但运行正常 #import traceroute # @UnresolvedImport warnings.filterwarnings("ignore",category=DeprecationWarning) logging.getLogger("scapy.runtime").setLevel(logging.ERROR) domains = raw_input('Please input domains or IPs: ') # 利用socket 解析域名的方法 # try: # ip = socket.gethostbyname(domains) # except socket.error,e: # print "you should run by root"''' try: domain = domains.split(' ') res,unans = traceroute(domains,dport=[80,443],retry=-2) res.graph(target=">test.svg") time.sleep(1) #输出转换为png为可选,chrome,ie等可以打开.svg文件 subprocess.Popen("/usr/bin/convert test.svg test.png",shell=True) except: print "you shoud run by root or domain error"
如对您有帮助,支持下呗!
微信
支付宝