Jump to content

need help with generating packets


mg.83

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.