i m writing a code for port scanner so i need to send a raw packet. i searched and found out that using dpkt library would be better but i didnt find any documentation that would help. So please anyone could help may explaining how to create a packet with customized TCP header i.e set the flags of tcp header as required.
Thank You
Well, this is a bit old but I'll answer anyway since I've been looking to do the same. The dpkt documentation is basically non-existant. The only thing they give you is some samples and Jon Oberheide, the co-developer, wrote some tutorials for it. So if you want to use dpkt it isn't difficult you can figure it out from one of these tutorials:
If you want an easier API, I've used both of these:
The same guy that wrote dpkt wrote libdnet, which is used by the beastly security scanner Nmap and has python wrappings: http://libdnet.sourceforge.net/. It's got some pretty basic TCP and IP creation functions but the documentation is much better.
Or use this python wrapper for libnet, http://pylibnet.sourceforge.net/. This is very robust and the documentation is great but I couldn't get injection working on OS X. Also every release so far is still beta.