Results 1 to 1 of 1
  1. #1
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Thanked 2,224 Times in 289 Posts
    Rep Power

    Simple Packet Sniffer Source

    This is old, but maybe useful example of packet sniffer application written on C#

    Author defines a structure using struct to store IP header in it.

    public struct IpHeader
    [FieldOffset(0)] public byte ip_verlen; // IP version and IP Header length
    [FieldOffset(1)] public byte ip_tos; // Type of service
    [FieldOffset(2)] public ushort ip_totallength; // total length of the packet
    [FieldOffset(4)] public ushort ip_id; // unique identifier
    [FieldOffset(6)] public ushort ip_offset; // flags and offset
    [FieldOffset(8)] public byte ip_ttl; // Time To Live
    [FieldOffset(9)] public byte ip_protocol; // protocol (TCP, UDP etc)
    [FieldOffset(10)] public ushort ip_checksum; //IP Header checksum
    [FieldOffset(12)] public long ip_srcaddr; //Source address
    [FieldOffset(16)] public long ip_destaddr;//Destination Address
    StructLayoutAttribute attribute has been used to arrange the members of this structure in the necessary positions.

    After that a socket using the Socket class has been created:

    socket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
    It should be Raw socket and bind socket to defined IP And called function IOControl(it must be called after you call Bind) IOControl it's analogue of WSAIoctl API function.

    Author put first parameter of IOControl to SIO_RCVALL(0x98000001). After packets have been received, they should be analyzed.

    Author calculates length of the data in packets as follows: "protocol header length (TCP, UDP, ICMP etc)" + "data" without length "ip header length". Total length is "ip header length" + "protocol header length(TCP, UDP, ICMP etc)" + "data"

    Please register or login to download attachments.

    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

  2. The Following User Says Thank You to Dwar For This Useful Post:

Similar Threads

  1. [C++] How to make a simple bot
    By Dwar in forum Programming Tutorials
    Replies: 3
    Last Post: 2014-10-04, 12:53 PM
  2. [C#] WinPCap Packet Sniffer Source
    By Dwar in forum VB, .NET Framework
    Replies: 2
    Last Post: 2014-08-24, 07:47 PM
  3. [Tool] Perfect World Packet Sniffer Cheat Engine plugin
    By Grooguz in forum Perfect World Bots, Cheats
    Replies: 9
    Last Post: 2013-11-05, 04:26 AM
  4. [Release] Simple ASM Injector
    By pohkak in forum Files & Tools
    Replies: 1
    Last Post: 2012-01-07, 05:22 PM
  5. [C++] Simple Proxy Reference
    By Dwar in forum Programming Tutorials
    Replies: 1
    Last Post: 2011-11-18, 10:52 AM
Visitors found this page by searching for:


url sniffer c#vbnet url sniffervb net packet capturehow to save the sniffed packet using packet sniffer attach packet sniffer source packet snifferudp packet sniffer source network sniffer header with url view tcp packet headerhttp:www.progamercity.netvb-code5368-c-simple-packet-sniffer-source.htmlc# header udp packetpacket analyzer source code in c#vb sample snifferget ip header packet c# udp packet analyzer in .net program sniffer headerWinPCap Packet Sniffer Source c#udp packet sniffer c#wow packet structurevisual basic packet network packethttp packet sniffing

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts