我设法捕获了通过网络传输的文件的内容,但是我无法捕获file name
.
class Program
{
static void Main(string[] args)
{
// Retrieve the device list
CaptureDeviceList devices = CaptureDeviceList.Instance;
// Print out the available network devices
foreach (ICaptureDevice dev in devices)
{
// Extract a device from the list
ICaptureDevice device = dev;
// Register our handler function to the
// 'packet arrival' event
device.OnPacketArrival += device_OnPacketArrival;
// Open the device for capturing
const int readTimeoutMilliseconds = 1000;
device.Open(DeviceMode.Promiscuous, readTimeoutMilliseconds);
// Start the capturing process
device.StartCapture();
}
Console.ReadKey();
foreach (var dev in CaptureDeviceList.Instance)
{
dev.StopCapture();
dev.Close();
}
}
private static void device_OnPacketArrival(object sender, CaptureEventArgs e)
{
var data = Encoding.ASCII.GetString(e.Packet.Data);
//HERE! When it exists, I need get the file name that was trafficked (eg. FileName.docx).
}
}
拦截文件访问协议 (NFS | SMB | AFP) 时如何使用 Sharpcap 获取文件名?