Python uses scapy to produce dynamic route maps

Source: Internet
Author: User

Scapy Module Installation

Yum Install tcpdump Graphviz ImageMagick

Open https://pypi.org/project/scapy/2.3.3/#files

Download scapy-2.3.3.tar.gz

wget https://files.pythonhosted.org/packages/ac/14/c792a14b9f8bc4bb9c74c0594c167a2da36e31964098d9e27202142cbd7d /scapy-2.3.3.tgz

Tar zxf scapy-2.3.3.tar.gz

CD scapy-2.3.3

Python setup.py Install


Explore Baidu's route map

#!/usr/bin/env python#-*-coding:utf-8-*-import os,sys,time,subprocessimport warnings, Loggingwarnings.filterwarnings ("Ignore", category=deprecationwarning) #logging. GetLogger ("Scapy.runtime"). SetLevel (logging.  ERROR) from scapy.all import traceroutedomains = 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.gra ph (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"

Execute Python png.py

Generate Test.png

[email protected] home]# python simple.py

Please input one or more ip/domain:www.baidu.com

Begin emission:

*finished to send packets.

Begin emission:

Finished to send 5 packets.

Begin emission:

Finished to send 5 packets.


Received packets, got answers, remaining 5 packets

14.215.177.38:tcp80

1 192.168.1.1 11

2 100.64.0.1 11

3 59.38.106.57 11

5 113.96.4.14 11

Ten 14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA

14.215.177.38 SA



Note Scapy version 2.4 will error

With the 2.3.3 version is exactly




Python uses scapy to produce dynamic route maps

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.