Linux Forums - Linux Help,Advice & support community:LinuxSolved.com

Linux in General => Linux Development & Programming => Topic started by: bahram741413 on January 25, 2004, 09:14:44 AM

Title: Network programming
Post by: bahram741413 on January 25, 2004, 09:14:44 AM
Hi 2 all
i am a network administerator and want to write a packet sniffer for monitoring my network. i know that there is some program, but i want to do myself, to have complete information.
please give me a start point.
thanks
Title: Network programming
Post by: Ricky on January 26, 2004, 05:13:40 AM
Man.. if you know basic programming then give this guide a look..
http://www.ecst.csuchico.edu/~beej/guide/net/html/
Title: tcp/ip code i want it
Post by: mark_nir on April 17, 2004, 07:25:56 AM
hi i want source code for  socket coding in c++ using tcp/ip protocols in linux
Title: Network programming
Post by: Ricky on April 17, 2004, 01:23:05 PM
Mark if you look the link below you will find that it has all what you want..


Quote from: "Ricky"
Man.. if you know basic programming then give this guide a look..
http://www.ecst.csuchico.edu/~beej/guide/net/html/
Title: Packet sniffer
Post by: sudipta_cht on April 17, 2004, 04:05:12 PM
Hi you can try this script:
It is a bit of a modified version of tcpdump
You may need to run it as root

Code: [Select]
#!/usr/bin/perl

$LIMIT = shift || 5000;

$|=1;
open (STDIN,"/usr/sbin/tcpdump -lnx -s 1024 dst port 80 |");
while (<>) {
    if (/^\S/) {
last unless $LIMIT--;
while ($packet=~/(GET|POST|WWW-Authenticate|Authorization).+/g)  {
   print "$client -> $host\t$&\n";
}
undef $client; undef $host; undef $packet;
($client,$host) = /(\d+\.\d+\.\d+\.\d+).+ > (\d+\.\d+\.\d+\.\d+)/
   if /P \d+:\d+\((\d+)\)/ && $1 > 0;
    }
    next unless $client && $host;
    s/\s+//;
    s/([0-9a-f]{2})\s?/chr(hex($1))/eg;
    tr/\x1F-\x7E\r\n//cd;
    $packet .= $_;
}