zoukankan      html  css  js  c++  java
  • python脚本之traceroute生成路由跟踪图片

    脚本 route.py

    #!/usr/bin/python

    #conding=utf-8

    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

    domain = raw_input('Please input on or more IP/domains:')     #输入域名
    target = domain.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"

    运行命令:python route.py

    运行提示:
    Please input on or more IP/domains:www.hao123.com
    .Begin emission:
    ******Finished to send 30 packets.
    ********************Begin emission:
    Finished to send 4 packets.
    Begin emission:
    Finished to send 4 packets.

    Received 27 packets, got 26 answers, remaining 4 packets
    115.239.217.167:tcp80
    1 192.168.1.1 11
    2 121.15.7.25 11
    3 113.106.39.225 11
    5 183.56.65.42 11
    7 202.97.84.77 11
    9 115.239.209.10 11
    10 115.239.209.22 11
    12 115.239.217.167 SA
    13 115.239.217.167 SA
    14 115.239.217.167 SA
    15 115.239.217.167 SA
    16 115.239.217.167 SA
    17 115.239.217.167 SA
    18 115.239.217.167 SA
    19 115.239.217.167 SA
    20 115.239.217.167 SA
    21 115.239.217.167 SA
    22 115.239.217.167 SA
    23 115.239.217.167 SA
    24 115.239.217.167 SA
    25 115.239.217.167 SA
    26 115.239.217.167 SA
    27 115.239.217.167 SA
    28 115.239.217.167 SA
    29 115.239.217.167 SA
    30 115.239.217.167 SA

    生成的图片效果:

  • 相关阅读:
    Understanding FiddlerScript
    RPG游戏地牢设计的29个要点
    《皇室战争》中关于兰彻斯特方程的应用及数值设计
    写给想做主策的策划师们
    AI设计的若干规则阐述
    Unreal引擎术语表
    UDK编辑器 49条小提示
    UE3代码阅读需知
    Framework配置错误
    迅雷的笔试题
  • 原文地址:https://www.cnblogs.com/to-be-rich/p/7262182.html
Copyright © 2011-2022 走看看