0
votes

I am developing an application in which users will use my tool, but every time the tool encounters some packets it will upload the packet class in c# as a .pcap file up to my site so that I can personally inspect it and make the necessary changes. I was wondering if anyone knew of a way for me to accomplish this goal of mine.

    public XXXXXCapturer(LivePacketDevice globalDevice) {
        PacketCommunicator globalCommunicator = globalDevice.Open(512, PacketDeviceOpenAttributes.Promiscuous, 1000);

        using (BerkeleyPacketFilter filter = globalCommunicator.CreateFilter("ether host XX:XX:XX:XX:XX:XX"))
        {
            globalCommunicator.SetFilter(filter);
        }
        globalCommunicator.NonBlocking = false;
        globalCommunicator.ReceivePackets(1, HandlePackets);
    }

    private void HandlePackets(Packet packet)
    {
        XXXXXDecoder Decoder = new XXXXXDecoder(packet);
        // Get Packet & Upload
        Info = new XXXXXInfo(Decoder.Data);
    }
1

1 Answers

0
votes

I have looked for hours prior to posting this question and found no results, so while I waited for someone to hopefully reply to this question I decided I would dive in and start viewing some of the code of Pcap.Net. That is when I found the static class called PcapDumpFile with a method called Dump(). That method with a few arguments accomplished what I asked of in this question. I will leave this question up because I am hoping someone else with a similar question may be helped by this.

My Dump() method usage:

 PacketDumpFile.Dump(System.IO.Directory.GetLogicalDrives()[0] + @"Program Files (x86)\XXXXX\" + "temp.pcap", packet.DataLink.Kind, packet.Length, new List<Packet> { packet });