Home ........ Blog ........ Travels ........ Software ........ Web 3D ........ LinkedIn

Thursday, December 22, 2011

IPv6 Packet Crafting in Perl

I refuse to learn a new programming language just so I can use a tool developed in it. Scapy - a packet crafting tool written in Python - seems like a pretty cool utility when doing testing, as I have been with IPv6 recently. On a Windows machine, options are severely limited when it comes to crafting packets unless you use the WinPcap libraries, and Scapy does this.

However, I don't know Python and have no desire to learn or install it just to get the use of Scapy for the limited testing I'm doing. I do however know Perl and when I found Scaperl I was delighted. It's a port of Scapy from Python to Perl but with very limited feature set and a release date of 2006. At least enough for what I wanted - until I read:

  • there is no support for IPv6.

in the "Known limitations" section of the site. A little more searching lead me to a revived Scaperl site so I grabbed that copy and started testing.

The first step was the install of a few required modules that I didn't yet have - no problems. You will need Net::Pcap installed and there were some issues with the latest version for Windows (cleared up with available patches) back when I installed this long ago. I got Scaperl running and sent a test packet.

The code is a little 'buggy' that is to say not so much incorrect, but it doesn't quite perform the way one would expect. Checksum calculation is one such example. If I don't set the checksum (say in an IP header) I expect Scaperl to calculate for me - which it does. However, if I make some modifications to the packet and then resend, the checksum is incorrect. Scaperl uses the previously calculated checksum. This could be fixed by checking for a "calcualte_checksum" flag versus testing if the checksum value is 0 (which it is originally, but not so much after a first calculation). Minor annoyances which have their workarounds.

More importantly, this Scaperl version has some IPv6 support. I was quickly able to complete the code needed and was sending IPv6 test packets soon after. There isn't yet support for IPv6 Extension Headers, but I was able to cobble together some code that lets me send the routing extension header (IPv6 loose source routing). More work on this when time allows.

No comments :


Copyright © VinsWorld. All Rights Reserved.