mg.83 Posted July 22, 2008 Share Posted July 22, 2008 Hi All, This may be a stupid question, but I need someone to point me in the right direction when it comes to creating TCP packets in php I'm not sure where to start and cannot find anything useful with browser searches. Any help would be greatly appreciated. Thanks in advance Quote Link to comment Share on other sites More sharing options...
btherl Posted July 22, 2008 Share Posted July 22, 2008 Is it the interface with the OS or the actualy generation of packet data you need help with? There's a good example for how to interface with the OS here[/code], as well as generation of a simple UDP packet. If it's generation of the packet, then pack is a useful function. It'll translate your integers into bytes. PHP strings can contain arbitrary binary data, so you can put everything into a simple string. Quote Link to comment Share on other sites More sharing options...
mg.83 Posted July 22, 2008 Author Share Posted July 22, 2008 The interface is no problem - im using scokets to get that done. the generation of packet data is where i need help. I understand the theory behind it but dont know where to start to actually generate a packet. Thanks for the links - i'll check them out. Quote Link to comment Share on other sites More sharing options...
btherl Posted July 22, 2008 Share Posted July 22, 2008 You could do worse than wikipedia. That article explains just about everything you need - the SYN, SYN/ACK, ACK sequence for establishing a session, how to calculate the checksum, and the header structure. As for how to do the generation in php, I would start with an empty string and add the fields in order. The checksum calculation is where you're most likely to slip up I would imagine. The wikipedia article links to the RFC which explains the checksum in detail. If you're not sure on what goes into particular spots in the header, you really should read more about how TCP works until it's clear. I can answer specific questions. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.