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
https://forums.phpfreaks.com/topic/115940-need-help-with-generating-packets/
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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.