lost and found ( for me ? )

python scapy : how to load extension modules with load_contrib() on Ubuntu 12.04

Here’s an explanation of how to load scapy extension modules with load_contrib().

# lsb_release –a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.1 LTS
Release:        12.04
Codename:       precise

# uname -ri
3.2.0-33-virtual x86_64

# python --version
Python 2.7.3

# apt-cache policy python-scapy
python-scapy:
 Installed: 2.2.0-1
 Candidate: 2.2.0-1
 Version table:


after installing python-scapy with apt-get and trying to load modules with load_contrib() , I saw the following error.
# scapy
INFO: No IPv6 support in kernel
WARNING: No route found for IPv6 destination :: (no default route?)
Welcome to Scapy (2.2.0)

>>> load_contrib('ospf')
ERROR: No module named contrib.ospf

>>> list_contrib()
>>>


[ how to load extension modules with load_contrib() ]

download python file you want to use from http://trac.secdev.org/scapy/browser/scapy/contrib/
# head -5 ospf.py
#!/usr/bin/env python
# scapy.contrib.description = OSPF
# scapy.contrib.status = loads
"""
OSPF extension for Scapy <http://www.secdev.org/scapy>


make “contrib” directory.
# mkdir /usr/lib/python2.7/dist-packages/scapy/contrib


copy ospf.py into  /usr/lib/python2.7/dist-packages/scapy/contrib/ directory.
# cp ospf.py /usr/lib/python2.7/
dist-packages/scapy/contrib/

# ls /usr/lib/python2.7/dist-packages/scapy/contrib/
ospf.py


run scapy
# scapy
INFO: No IPv6 support in kernel
WARNING: No route found for IPv6 destination :: (no default route?)
Welcome to Scapy (2.2.0)
>>> list_contrib()
ospf                : OSPF                                     status=loads
>>>


load ospf . nn , error
>>> load_contrib('ospf')
ERROR: No module named contrib.ospf


Oops , I forgot making __init__.py file under /usr/lib/python2.7/dist-packages/scapy/contrib/ directory.
# touch /usr/lib/python2.7/dist-
packages/scapy/contrib/__init__.py


try again.
# scapy
INFO: No IPv6 support in kernel
WARNING: No route found for IPv6 destination :: (no default route?)
Welcome to Scapy (2.2.0)
>>> load_contrib('ospf')


capture OSPF packets.
>>> load_contrib('ospf')
>>> sniff(filter="ip dst 224.0.0.5",count=1)
<Sniffed: TCP:0 UDP:0 ICMP:0 Other:1>
>>> _[0].show()
###[ Ethernet ]###
 dst= 01:00:5e:00:00:05
 src= 52:54:00:d4:ab:3e
 type= 0x800
###[ IP ]###
    version= 4L
    ihl= 5L
    tos= 0xc0
    len= 68
    id= 56122
    flags=
    frag= 0L
    ttl= 1
    proto= ospf
    chksum= 0x3bbb
    src= 192.168.0.254
    dst= 224.0.0.5
    \options\
###[ OSPF Header ]###
       version= 2
       type= Hello
       len= 48
       src= 192.168.1.254
       area= 0.0.0.0
       chksum= 0xf300
       authtype= Null
       authdata= 0x0
###[ OSPF Hello ]###
          mask= 255.255.255.0
          hellointerval= 10
          options= E
          prio= 1
          deadinterval= 40
          router= 192.168.0.253
          backup= 192.168.0.254
          neighbors= ['192.168.2.254']
>>>

1 comment:

  1. hi,i have a problem, when i write load_contrib('ospf') i have an error message
    File "", line 1
    load_contrib('ospf')
    ^
    IndentationError: unexpected indent
    can you help me please?

    ReplyDelete

Note: Only a member of this blog may post a comment.