Packet Manipulation/Crafting
What is the best way of manipulating/crafting packets? I want to have full control, including source IP, destination... is that possible? I have no malicious intent, just think it would be pretty interesting to mess around with.
I'm aware that software exists for this, but I want to code it myself.
I'm aware that software exists for this, but I want to code it myself.
Comments
-
SteveO86 Member Posts: 1,423+1 for scapy, it's a nice tool for testing ACLs and Firewalls.
Slight learning curve as you want to understand the packet format you are crafting. It also works over WLANs to.My Networking blog
Latest blog post: Let's review EIGRP Named Mode
Currently Studying: CCNP: Wireless - IUWMS -
Eildor Member Posts: 444+1 for scapy, it's a nice tool for testing ACLs and Firewalls.
Slight learning curve as you want to understand the packet format you are crafting. It also works over WLANs to.
How does one learn the packet format? If I were to capture packets on Wireshark would that give me what I need?
Also, what would stop me from crafting thousands of CDP packets to do some sort of DoS attack on a local switch? Apart from turning CDP off, of course... -
Eildor Member Posts: 444
Yeah you're right, in fact it's the first thing that comes up! Sorry. Cheers mate. -
the_hutch Banned Posts: 827Scapy--
Scapy
Or if you're good with Python you can script it yourself.
I know the_hutch has some experience with this.
Also obviously use a sniffer like Wireshark to confirm what goes across the wire.
Haha...yep. Scapy is pretty much the coolest scripting library ever. Complete control over ever aspect of the TCP/IP stack when handling raw packets. I've tried to find equivalents in other scripting languages...but there is nothing comparable (at least from what I've found). The only set back is that there is a lack of documentation, so learning it is a lot of trial and error. I'm thinking about producing a video series on using Scapy. -
dover Member Posts: 184 ■■■■□□□□□□Mike Poor and Judy Novak have a good scapy example for crafting overlapping packets at packetstan.com.
Site hasn't been updated in a long time, unfortunately. Still a good example though.
Packetstan -
Eildor Member Posts: 444Mike Poor and Judy Novak have a good scapy example for crafting overlapping packets at packetstan.com.
Site hasn't been updated in a long time, unfortunately. Still a good example though.
Packetstan
Thank you.
How much Python would I need to learn? Never done anything in Python before, looks quite a bit different to Java. -
CodeBlox Member Posts: 1,363 ■■■■□□□□□□If you want true control over crafting everything in your packets in C, look up raw sockets. This will do what you want. See below:
The RAW socket C programming tutorial with working program examples tested on Linux OSCurrently reading: Network Warrior, Unix Network Programming by Richard Stevens -
Eildor Member Posts: 444If you want true control over crafting everything in your packets in C, look up raw sockets. This will do what you want. See below:
The RAW socket C programming tutorial with working program examples tested on Linux OS
Would love to learn C, just don't have the time at the moment. From what I remember it's a rather small language though. I was going through Brian Kernighan's book a few years ago, the exercises are pretty tough. I never got to finish it, or even get halfway (and it's not even a big book!).