所以,我正在尝试使用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和端口,时间戳等。 那么,我错过了什么吗?
答案 0 :(得分:0)
所以,是的......在联系开发人员via issue on the official github repository之后,我们得出的结论是教程已经过时了。 这里提供了最新的示例:click!