From: GomoR (sfml@gomor.org)
Date: Mon Jan 17 2005 - 05:46:22 EST
On Mon, Jan 03, 2005 at 09:25:02AM -0700, Chris Kuethe
wrote:
[..]
> * perl
[..]
In the Perl modules category, I can add my own one.
Net::Packet is a packet construction framework, you can
build packets from Layer 2 to Layer 7. It really made easy
to match requests with replies, and hides many trivial
tasks that you must do by hand using
Net::Pcap/Net::RawIP/NetPacket.
Actually on CPAN, the 1.28 version. I'm finalising the
2.00, which features IPv6 headers as well, and full
documentation (not terminated).
You can get the 2.00-RC1 here:
http://www.gomor.org/netpkt/Net-Packet-2.00-RC1.tar.gz
Example SYN send with 2.00-RC1 version (not compatible
with 1.28):
--8<--
#!/usr/bin/perl
use Getopt::Std;
my %opts;
getopts('i:I:p:d:v', \%opts);
die "Usage: send-syn.pl -i dstIp -p dstPort [-v]\n"
unless $opts{i} && $opts{p};
use Net::Pkt;
$Env->debug(3) if $opts{v};
my $ip = Net::Packet::IPv4->new(dst => $opts{i});
my $tcp = Net::Packet::TCP->new(
flags => NP_TCP_FLAG_SYN,
dst => $opts{p},
);
my $frame = Net::Packet::Frame->new(l3 => $ip, l4 => $tcp);
print "Request:\n";
print $frame->ipPrint, "\n";
print $frame->tcpPrint, "\n";
$frame->send;
until ($Env->timeout) {
if ($frame->recv) {
print "\nReply:\n";
print $frame->reply->ipPrint, "\n";
print $frame->reply->tcpPrint, "\n";
last;
}
}
--8<--
-- ^ ___ ___ FreeBSD Network - http://www.GomoR.org/ <-+ | / __ |__/ Security Engineer, searching for work | | \__/ | \ ---[ zsh$ alias psed='perl -pe ' ]--- | +--> Net::Packet <=> http://search.cpan.org/~gomor/ <--+
This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:54:14 EDT