I managed to capture the content of the file trafficked across the network, however I am unable to capture the 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).
}
}
How can i get the file name with Sharpcap when intercepting file access protocols (NFS | SMB | AFP) ?