Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
Available now!
Buy at Amazon US or
Buy at Amazon UK


» Windows API reference
» Webcam streaming in VB.NET
» Remoting with firewalls
» RSA from first principles
» Key & MouseLogger in .NET
» Networking Resource Kit for .NET
» Migrating VB6 Winsock to VB.NET
» Migrating C++ sockets to C#
» RFC Reference guide
» COM Reference guide
» WMI Reference guide
» SQL stored procedures
» TCP & UDP port reference
» NET Framework reference
» Ethernet Type codes
» MAC address assignments
» DLL entry point reference
» Boost SQL performance
» Free SMS UK
» Free SMS Ireland
» Free SMS South Africa
» Internet Explorer

Contact us

10. Packet sniffing, in C# and VB.NET

Packet sniffing has got a bad rap over the past few years, since it makes it possible to read anything sent over the wire, whether it was destined for your PC or not. This makes plain text username/password pair protection laughably insecure. However, packet sniffing isn’t just a hacker’s tool, it is an excellent non-invasive means of monitoring network traffic, to scan for bandwidth usage, worms, DOS attacks etc.

Whilst it is possible to use native raw sockets in .NET to capture packets at IP level, using a technique first published by Lance Olson at Microsoft. This has some limitations, as it cannot drill down below IP level, into the frame stack, nor can it capture in ‘promiscuous’ mode – that is, packets destined for other machines.

However, by using an open-source packet driver, and a C++ DLL (available for download separately), it is possible to drill down into the frame stack, below IP level, and capture packets promiscuously, as this example shows.

To test this application, install the packet driver and DLL as detailed in the book Network programming in .NET (Buy at Amazon UK) (Buy at Amazon US), and start the application, then open a browser, and connect to any site you wish (excluding localhost!), and you will see all the raw data travelling between client and server.

(Source code availabile in the book Network Programming in .NET (Buy at Amazon UK) (Buy at Amazon US), Chapter 13, Example 2)

Page 2  Page 3  Page 4  Page 5  Page 6  Page 7  Page 8  Page 9  Page 10  Page 11  Page 12  Page 13 


Copyright 2017 Infinite Loop Ltd.