2
votes

Introduction: This question is about packet sniffing/sending using SharpPcap.

  • Well actually the main ideea is:

There is a client application which communicates with a server side. I have made a sniffer which logs all the (specified by my filter) packets. Now I just want to RE-Send those packets back to the server side.. not from the client side...but through my own application. Kind of simulating an action ( lets say a button click 100x faster)

The questions are :

1. What kind of packets should I send:

  • Raw packets?
  • SharpPcap interpreted packets?(ipPacket)eg:
    var rawPacket = Packet.ParsePacket(packet.Packet.LinkLayerType, packet.Packet.Data);
    var ipPacket = IpPacket.GetEncapsulated(rawPacket);

  • The payLoadData only?If yes.. whose payloadData?From the raw or from the ipPacket?

2. Could somebody provide a really good and working piece of code.

3. How to distinguish if it is an incoming or outgoing packet??

Thank u for collaboration!

1

1 Answers

0
votes

you can try this:

var ipPacket = IpPacket.GetEncapsulated(rawPacket);
IPAddress localIPs = Dns.GetHostAddresses(Dns.GetHostName())[0];
if(localIPs.ToString()== ipPacket.SourceAddress.ToString())
{
//outgoing packet
}