Articles

Metasploit Framework Windows Tutorial
Remote Desktop Connection
Windows Processes That May Be Dangerous
How-To use NetCat a Tutorial
Common Linux Commands
Common Ports
Netcat Commands
HTTP Response Codes
War-Google Hack Terms
Wardriving
Avoiding Social Engineering and Phishing Attacks
Intrusion Detection on Linux
Linux Intrusion Detection
Penetration Testing Guide
Penetration Testing Tools
Social Engineering Fundamentals, Part I: Hacker Tactics
Social engineering (computer security)
The Psychology of Social Engineering

The Archives

General GSO
GovernmentSecurity.org News & Suggestions
In The News
Open Topic
General Security Information
Trash Can
Exploit & Vulnerability Mailing List Archives
Trial Member Forum
Product and Program Reviews GSO Tutorials
System Security
Windows Systems
Beginners Section
Linux & Unix Systems
File Downloads
Exploit Research & Discussion Trojan & Virus Errata
Networking Security / Firewall / IDS / VPN / Routers
System Hardening
E-Mail Security
Wifi Security
Trial Member Uploads
Upload discovered Trojans & Mal ware
GSO Programming Section
C , C++ , VC++
Visual Basic.NET
Perl /CGI
Java/Javascript
PHP/XML/ASP/HTML
Assembly + Other
The Cork Board
Network Security Consultant Directory
Network Security Jobs
The Archives
Encryption Information
General Network Security
Internet Anonymity
HTTP Protocol Security
Linux Security
MS IIS Information
Exploit Articles
Programming / Tool Design
GSO Software Projects
Public Downloads
Microsoft Security Questions and Papers

Full Version: [c] Sniffer
[thebadskull]
hello !!
i'm programming a packets sniffer with pcap librairies.
But i've made my own struct (for ip/ether header)

i'm looking for a better solution for this structure because it's repetitive, I must do it for (UDP packet , TCP packets etc...) :

CODE

struct in_addr{
u_long s_addr;
};


struct ether_header{
u_char ether_dhost[6]; //destination host (adresse de destination)
u_char ether_shost[6]; //source host (adresse source)
u_short ether_type;    //type de trame
u_short ether_Htype;
u_short ether_protocol;
u_char ether_HLen;
u_char ether_PLen;
u_short ether_op;
u_char ether_Hsender[6];
struct in_addr ip_src;
u_char ether_Htarget[6];
struct in_addr ip_dst;
};

/* IP header */
struct ip_header{
   #if BYTE_ORDER == LITTLE_ENDIAN
   u_int ip_hl:4, /* header length */
   ip_v:4; /* version */
   #if BYTE_ORDER == BIG_ENDIAN
   u_int ip_v:4, /* version */
   ip_hl:4; /* header length */
   #endif
   #endif /* not _IP_VHL */
   u_char ip_tos; /* type of service */
   u_short ip_len; /* total length */
   u_short ip_id; /* identification */
   u_short ip_off; /* fragment offset field */
   #define IP_RF 0x8000 /* reserved fragment flag */
   #define IP_DF 0x4000 /* dont fragment flag */
   #define IP_MF 0x2000 /* more fragments flag */
   #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
   u_char ip_ttl; /* time to live */
   u_char ip_p; /* protocol */
   u_short ip_sum; /* checksum */
   struct in_addr ip_src,ip_dst; /* source and dest address */
};



THX
jead99
Interesting project, i'm also making a sniffer in c#.

Btw. did you take a look here http://www.tcpdump.org/pcap.htm
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2005 Invision Power Services, Inc.