【问题标题】:Missing extract method for CaptureEventArgs.Packet缺少 CaptureEventArgs.Packet 的提取方法
【发布时间】:2018-06-09 05:47:16
【问题描述】:

所以,我正在尝试使用 Sharppcap 嗅探数据包,并密切关注 codeproject 上的 Sharppcap 开发人员教程,我尝试在 CaptureEventArgs.Packet 上调用 extract() 方法。 似乎,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 和端口、时间戳等。 那么,我错过了什么吗?

【问题讨论】:

    标签: c# networking sniffing sharppcap


    【解决方案1】:

    所以,是的...在联系开发人员via issue on the official github repository 后,我们得出的结论是该教程已过时。 此处提供了最新示例:click!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-25
      • 2021-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多