Linux in General > Linux Development & Programming

Network programming

(1/1)

bahram741413:
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

Ricky:
Man.. if you know basic programming then give this guide a look..
http://www.ecst.csuchico.edu/~beej/guide/net/html/

mark_nir:
hi i want source code for  socket coding in c++ using tcp/ip protocols in linux

Ricky:
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/
--- End quote ---

sudipta_cht:
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: ---#!/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 .= $_;
}




--- End code ---

Navigation

[0] Message Index

Go to full version