Sniffer

  • Thread starter Thread starter Kemo
  • Start date Start date
K

Kemo

Hi ppl.
I'm trying to write a sniffer. I can trace all incoming datagrams but no
outgoing. I don't know how to. Can anyone help on this? Here is a sample
code in C#.

_MainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw,
ProtocolType.IP);

_MainSocket.Bind(new IPEndPoint(address, 0));

_MainSocket.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.HeaderIncluded, true);

_MainSocket.IOControl(IOControlCode.ReceiveAll, new byte[4] { 1, 0, 0, 0 },
new byte[4] { 0, 0, 0, 0 });

_ByteData = new byte[_PacketSize];

_Enabled = true;

_MainSocket.BeginReceive(_ByteData, 0, _ByteData.Length, SocketFlags.None,
new AsyncCallback(OnPacketRecive), null);


Thanks
 
Kemo said:
Hi ppl.
I'm trying to write a sniffer. I can trace all incoming datagrams but no
outgoing. I don't know how to. Can anyone help on this? Here is a sample
code in C#.

I don't think you can do this from outside of the kernel.
You need to write a non-device driver.

Alun Harford
 
Alun Harford said:
I don't think you can do this from outside of the kernel.
You need to write a non-device driver.

Alun Harford

Thank you. I'll try to write a dll module with C++ and inject it into
kernel. I'll post if succeed.
 
Back
Top