zoukankan      html  css  js  c++  java
  • python-生成动态路由轨迹图(scapy模块)

    scapy是一个强大的交互式数据包处理程序,可以用在网络扫描、包嗅探、路由跟踪、单元测试和服务探测

    在linux系统上安装

    yum -y install tcpdump graphviz ImageMagick  (scapy 需要用到 tcpdump graphviz ImageMagick)

    pip3 install scapy -i https://pypi.tuna.tsinghua.edu.cn/simple

    创建simple.py

    #!/usr/bin/env python3
    # -*- 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 = input('Please input one or more IP/domain:') #接收输入的域名或ip地址
    target = domains.split(' ')
    dport = [80,7080] #扫描的端口列表
    
    if len(target) >=1 and target[0]!= '':
        print('长度:%s' % len(target))
        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 errots,exit!')
  • 相关阅读:
    ADB 多设备中指定设备的启动
    vuex 绑定表单,多个输入框的解决办法
    vue 自动触发点击事件
    js 打印dom的所有属性
    邮件分享
    table表格 td设置固定宽度
    Echarts--Y坐标标题显示不全
    ExtJS5.0 菜鸟的第一天
    字体设置
    短信验证码+倒计时
  • 原文地址:https://www.cnblogs.com/fuyuteng/p/12587599.html
Copyright © 2011-2022 走看看