Python scapy OSPF

2.5k Views Asked by At

I have a requirement of testing OSPF v2 and OSPF v3 routing protocols against their respective RFCs. Scapy module for python seems interesting solution to craft OSPF packets, but are there any open source OSPF libraries over scapy that one could use to create the test cases. Would appreciate any pointers in this direction.

2

There are 2 best solutions below

0
the4960 On

I love using Scapy any change I get. Being in Python, it has a pretty low learning curve. You can modify any portion of the packet (Eth, IP, TCP/UDP, Payload). Any layer below the payload Scapy comes with an option to fuzz any fields. You have the option to recalculate the checksum/len fields. You can load traffic from a PCAP and utilize packets from there. Scapy won't complain if you make a really odd packet; e.g.

from scapy.all import *
packet = IP()/ICMP()/ICMP()
packet.show()

I've used it to produce a MITM attack on virtual routers utilizing RIP. It bypasses the rules of the iptables, so pairing it with rules can do a lot of stuff. It can be used as a server if you drop RST packets. It can even be used to modify incoming and outgoing traffic utilizing nfqueue.

In general, Scapy gives you a ton of flexibility with ease of use.

0
Cukic0d On

Have a look at this page: https://github.com/secdev/scapy/wiki/Contrib:-Code:-OSPF It hasn't been updated in a while, so it's probably not Python 3 compatible. Feel free to debug it and submit your changes :-)