0

因此,我正在尝试使用 Sharppcap 嗅探数据包,并密切关注 codeproject 上Sharppcap的开发人员教程,我尝试extract()CaptureEventArgs.Packet. 似乎,该extract()方法没有实现。代码:

using PacketDotNet;
using SharpPcap;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace SnifferGUI
{
    class ProjectBehaviour
    {
        public void Initsniff()
        {
            CaptureDeviceList captureDeviceList = CaptureDeviceList.Instance;

            if(captureDeviceList.Count < 1)
            {
                throw new InsufficientExecutionStackException();
            }
            ICaptureDevice device = captureDeviceList[1]; //todo
            device.OnPacketArrival += new SharpPcap.PacketArrivalEventHandler(device_OnPacketArrival);

            device.Open(DeviceMode.Promiscuous, 0);

            device.StartCapture();
        }

        private void device_OnPacketArrival(object sender, CaptureEventArgs e)
        {
            var tcp = (TcpPacket)e.Packet.Extract(typeof(TcpPacket)); //According to the tutorial, this is a valid expression.
        }
    }

}

我的目标是将收到的数据包解析为 TcpPacket 以进一步进行。我想存储和显示源/目标 ip 和端口、时间戳等。那么,我错过了什么吗?

4

1 回答 1

0

所以,是的......在通过官方 github 存储库上的问题与开发人员联系后,我们得出的结论是该教程已过时。此处提供了最新示例:单击!

于 2017-12-31T12:59:03.270 回答