| IntroductionThe first idea of writing a packet sniffer 
                      program came from a reply to my comments on one of the projects 
                      named "NetSend ( Sending popup messenger messages between 
                      computers )" by Marc Clifton. Marc asked me "What 
                      about receiving message". To say the truth, I didn't 
                      know how I could do that. I knew a program which I had downloaded 
                      and tested years ago. But I didn't know the way of it. So 
                      I made a search on net about programs that can receive messages 
                      created by NetSend. And I noticed that many of them were 
                      using packet sniffer libraries. And then decided to learn 
                      how it is done. My search attempts gave a result and I found 
                      a free library named WinPCap. After previewing the WinPCap source code 
                      , my first trial was to write a wrapper class for it. But 
                      what I did was not what I expected. And I had no control 
                      over the code. So I decided to port the base library of 
                      WinPCap named PacketNt.dll to C#. After many weeks 
                      and debug trials, I finished it. And then I wrote a new 
                      class to make capture process easy. And all these happen, 
                      a new class was created, Function. 
                      Yes, now I could catch packets from the network card but 
                      I wasn't able to display them. Because I had no idea what 
                      they meant. My next search was to find a program with free 
                      source code that can display packets. Yes, yes, as you guess, 
                      I found it. Its name is Etheral. It is really a great program 
                      and free. First I traced the packets captured by 
                      Etheral and built some protocols and was able to display 
                      them in my test program. And then (after getting the source 
                      code of it ), I used the source code to learn the protocol 
                      structures. Now my program supports over 15 protocols. My 
                      aim is to add all protocols supported by Etheral to my program 
                      and to make it available to all of you. At this point, I 
                      will be very happy if some of you are interested in this 
                      kind of projects, to finish it. I am alone, and to port 
                      all protocols to C# is absolutely time consuming and tiring. 
 Project contentsPacanal name comes from PACket ANALyzer. 
                      It is the main project file which enables to communicate 
                      with other classes and to display captured packets. Other 
                      classes are shown below: 
                      ColumnSorterThis class enables to sort list view 
                          items. The class has the following members: 
                           
                            public int CurrentColumn = 0; // Column index to be sorted 
                            public int Direction = 0; // 0 : Ascending, 1 : Descending 
                            public int ColumnType = 0; 
// 0 : Integer , 1 : Double , 2 : String 
                            public bool CaseSensitivity = true; 
                            public bool Enabled = true; CurrentColumndefines which column will be used to sort theListView.Directionenables to sort data 
                          from lower to higher or higher to lower.ColumnTypedefines what format the desired column is.CaseSenitivityenables to sort string data in case order andEnabledhelps enabling or disabling the sort method to run.
ConstThis class contains protocol related 
                          constants and function.DeviceIoCtlhThis class contains device specific 
                          constants and structures.FunctionThis class contains all utility functions. 
                          It contains variable reading functions, bit decode function, 
                          node display function, Win32 API functions, format functions, 
                          etc.NtddNDishThis class contains device specific 
                          constants.Packet32Wrapper class for Packet32hclass. It contains functions for starting and stopping 
                          a capture session, loading and saving functions of captured 
                          packets, reading and writing function of capture parameters, 
                          etc.Packet32hThis class contains all ported functions 
                          of PacketNt.dll of WinPCap library. I also added 
                          some functions both to add support for different OS 
                          and to extend the use of ported functions.PacketAARPThis class contains Apple Talk Address 
                          Resolution Protocol parser functionsPacketARPThis class contains Address Resolution 
                          Protocol parser functionsPacketCDPThis class contains Cisco Discovery 
                          Protocol parser functionsPacketDCERPCThis class contains DCE/RPC Protocol 
                          parser functions. This class isn't over yet.PacketDLSWThis class contains Data Link Switching 
                          Protocol parser functionsPacketDNSThis class contains Domain Name Service 
                          Protocol parser functionsPacketEIGRPThis class contains Extended Interior 
                          Gateway Routing Protocol parser functionsPacketETHERNETThis class contains Ethernet Protocol 
                          parser functionsPacketHTTPThis class contains Hyper Text Transfer 
                          Protocol parser functionsPacketICMPThis class contains Internet Control 
                          Message Protocol parser functionsPacketINTERNETThis class contains Internet Protocol 
                          parser functionsPacketIPXThis class contains Internet Packet 
                          Exchange Protocol parser functionsPacketLLCThis class contains Logical Link Control 
                          Protocol parser functionsPacketLOOPBACKThis class contains Loopback Protocol 
                          parser functionsPacketMSWBROWSERThis class contains Microsoft Windows 
                          Browser Protocol parser functions. This class isn't 
                          over yet.PacketMSWLOGONThis class contains Microsoft Windows 
                          Logon Protocol parser functions. This class isn't over 
                          yet.PacketNBDSThis class contains NetBIOS Datagram 
                          Service Protocol parser functionsPacketNBNSThis class contains NetBIOS Name Service 
                          Protocol parser functionsPacketNBSSThis class contains NetBIOS Session 
                          Service Protocol parser functionsPacketNETBIOSThis class contains NetBIOS Protocol 
                          parser functionsPacketParserThis class contains main parser functionsPacketSMBThis class contains Server Message 
                          Block Protocol parser functions. This class hasn't finished 
                          yetPacketSMBMAILSLOTThis class contains SMB Mail Slot Protocol 
                          parser functionsPacketSTPThis class contains Spanning Tree Protocol 
                          parser functionsPacketTBThis class contains Trans Bridging 
                          Protocol parser functions. This class hasn't finished 
                          yetPacketTCPThis class contains Transmission Control 
                          Protocol parser functionsPacketTFTPThis class contains Trivial File Transfer 
                          Protocol parser functionsPacketUDPThis class contains Unary Datagram 
                          Protocol parser functionsWinServiceThis class contains Windows service 
                          related functions and Win32 APIs.PacketSQL by Keith 
                        WestleyThis class contains SQL Server/Sybase 
                          TDS packet parser functions I tried to make my program like Etheral. 
                          So many features are like Etheral's features. Those 
                          are as follows: 
                          You can limit captured packet to 
                            a specified size 
                          You can stop capturing when a specified 
                            count of packets is reached 
                          You can stop capturing when a specified 
                            time is reached 
                          You can stop capturing when specified 
                            bytes is reached 
                          You can stop capturing regardless 
                            those above 
                          You can capture packets in real 
                            time mode 
                          You can scroll packets list in real 
                            time mode 
                          You can resolve MAC names 
                          You can see the statistic of the 
                            captured packets , their percentages in all packets, 
                            the running time of the capture process and the total 
                            bytes captured 
                          You can change the hardware filter 
                            as your needs 
                          You can change the capture mode 
                          You can highlight the protocol data 
                            by clicking protocol node in TreeViewnodeYou can highlight the protocol data 
                            by clicking Hex data display area and then the protocol 
                            node will be highlighted 
                          You can save all or a selected or 
                            all selected packets in the format that Etheral understands 
                          You can load a packet file for reviewing 
                          You can sort the captured packets 
                            as your will 
                          You can highlight a node and its 
                            corresponding value in the hex data display by clicking 
                            the hex data display control 
                          You can copy data from hex 
                            data. There are two ways to do this  
                            
                          You can delete a packet by selecting 
                            it in the ListViewcontrol 
                            and then clicking the "Delete selected packet" 
                            button on the toolbarYou can capture messages sent by 
                            NetSend. Use Capture->Capture Net Send 
                          You can manually install or remove 
                            the npf.sys driver by using "Driver" 
                            menu items. Use Driver->Install driver, Driver->Uninstall 
                            driver 
                          You can enable or disable displaying 
                            list view columns. Use Options->Columns options 
                          You can change the view of the program 
                            by adding transparency to it. Use Options->Transparency 
                            options 
                          You can view capture statistics 
                            whenever you want. Use View->Show statistics, View->Hide 
                            statistics RequirementsTo run the code you need to have those 
                      below: 
                      Windows NT / 2K / XP 
                      A PC with an Ethernet card (LOL) 
                      NDIS packet capture driver (npf.sys) 
                        installed npf.sys can be downloaded from the 
                      site http://winpcap.polito.it/ which is the one I used. 
                      But the project zip file contains necessary npf.sys 
                      files for both Win NT and Win 2K/XP. If npf.sys hasn't 
                      been installed yet, the program will install it for you. |