准备文件:

  • 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
11
2
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 5 年前
5def40a3 Add host customization support for the NodeJS version 5 年前
Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐