November 22, 2024, 05:18:08 AM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: Network programming  (Read 11876 times)

Offline bahram741413

  • Linux Noob !
  • *
  • Posts: 5
Network programming
« 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

Offline Ricky

  • LST CareTaker
  • Specially Skilled
  • *****
  • Posts: 2381
Network programming
« Reply #1 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/

Offline mark_nir

  • New Member
  • Posts: 1
tcp/ip code i want it
« Reply #2 on: April 17, 2004, 07:25:56 AM »
hi i want source code for  socket coding in c++ using tcp/ip protocols in linux

Offline Ricky

  • LST CareTaker
  • Specially Skilled
  • *****
  • Posts: 2381
Network programming
« Reply #3 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/

Offline sudipta_cht

  • Linux Noob !
  • *
  • Posts: 14
Packet sniffer
« Reply #4 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 .= $_;
}