Originally posted to GSO by: dillinja

Packet Crafting via HPing
By alt_don
http://www.security-forums.com/

The author of this program is Salvatore Sanfilippo. He is a hacker from Agrigento, Italy. So all kudos go to him for crafting such an excellent tool. He is presently working on v3, and hopefully will be releasing it soon. There are several tutorials on the web regarding this tool. A couple are by the author himself. However I found them to be confusing, and often difficult to follow. This is no fault of the author as his mother tongue is not English.

The reason I chose to learn this tool is very simple. I was curious as to how the people who were attempting to gain access to our networks were going about it. One of the ways is packet crafting. Crafting packets will allow you to probe firewall rule-sets and find entry points into the targeted system or network.

The sheer versatility of this tool though is what makes it stand out from the crowd. It is not only the king of the hill when it comes to crafting packets. This will also show you how to interpret the various conventions of TCP/IP. You will learn how the guts of the stack works by crafting packets. As mentioned below you will need to run a packet sniffer to see your output. This will show you exactly what it is that you are sending out. More importantly though it will show you how various firewalls, open services, and closed ports react to certain stimulus. This side benefit of HPing and packet crafting in general is highly underrated. To understand how the web lives and breathes is integral to your computer studies. It stand to reason that you would want to understand its basic form of communication ie: the packet. The packet is the foundation upon which C2C (computer to computer) communications are built upon.

The following paper will show you how to use this tool. It will not however teach you how to hack or to help secure your network. You can do both with HPing. To do both successfully you will need a lot more knowledge in regards toTCP/IP, routers, access control lists, OSI chart, andother areas.

What I hope to accomplish by this brief is to show you just how easy it is to craft packets, and perhaps give you a glimpse into the world of the black-hat hacker. Not to mention hopefully stimulate your curiousity, and encourage you to further explore the murky world of the hacker. The one constant with hackers of all stripes, whether they be black/white/grey hat is that they have a burning curiosity about computers.

One last note on HPing before we start to look at it. HPing will run on any Linux distro, as well as Net/Free/OpenBSD systems, and lastly it will run on Solaris as well. I highly advise you to run tcpdump at the same time. This will allow you to monitor your crafted packets as well as look at your return packets.

I have included tcpdump snippets to highlight what the outgoing and incoming packets look like on the wire. I believe this to be important as it allows you to visualize the packets. Be aware that HPing "does not" run under Windows. You can however still have tcpdump for Windows. It is called windump and can be found here.

The two packets you see below are just one ip addy sending a Syn packet to another ip addy. To do this using Hping is a very simple task. Just type in "exactly" the below noted command syntax, and voila a syn packet is sent!