准备文件:

  • linux系统
  • 安装:apt-get  install  tcpdump  graphviz   ImageMagick
  • 安装:pip  install  scapy


过程:(要正确配置etc/resolv.config里面的DNS服务器)

  • 通过scapy的traceroute方法以SYN方式对目标进行TCP服务扫描
  • 同时启动tcpdump抓包, 捕获所经过的路由点
  • 通过graph()方法, 生成svg图形文件
  • 最后用ImageMagick工具讲svg转换成png文件

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"


检测百度的路由轨迹:



 

GitHub 加速计划 / li / linux-dash
13
2
下载
A beautiful web dashboard for Linux
最近提交(Master分支:3 个月前 )
186a802e added ecosystem file for PM2 5 年前
5def40a3 Add host customization support for the NodeJS version 5 年前
Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐