1#!/usr/bin/perl 2# 3# $Id: d3-syn-send.pl 1640 2009-11-09 17:58:27Z gomor $ 4# 5use strict; 6use warnings; 7 8use Getopt::Std; 9my %opts; 10getopts('i:I:p:d:v', \%opts); 11 12die "Usage: $0 -i dstIp -p dstPort [-I srcIp] [-d device] [-v]\n" 13 unless $opts{i} && $opts{p}; 14 15use Net::Packet; 16 17$Env->dev($opts{d}) if $opts{d}; 18$Env->ip ($opts{I}) if $opts{I}; 19$Env->debug(3) if $opts{v}; 20 21my $d4 = Net::Packet::DescL3->new( 22 target => $opts{i}, 23); 24 25my $frame = Net::Packet::Frame->new( 26 l3 => Net::Packet::IPv4->new( 27 dst => $opts{i}, 28 ), 29 l4 => Net::Packet::TCP->new( 30 dst => $opts{p}, 31 ), 32); 33 34$frame->send; 35 36until ($Env->dump->timeout) { 37 if ($frame->recv) { 38 print "Reply:\n"; 39 print $frame->reply->l3->print, "\n"; 40 print $frame->reply->l4->print, "\n"; 41 last; 42 } 43} 44 45$Env->dump->stop; 46$Env->dump->clean; 47