#!/usr/bin/perl

use IO::Socket;


require "getopt.pl";

&Getopt('phstln')   ;

$port = $opt_p ;
$host =$opt_h ;
$sleeped = $opt_t ;
$localport = $opt_l ;


@strings=split('', $opt_s);

if (!$opt_h || !$opt_p)
{
        print "Cutter by (yjesus\@security-projects.com\)\n\n"; 
	print "Usage: cutter.pl -h host -p port -s string -t time between packets -l local source port -n num chars\n" ;
        print "Example: cutter.pl -h 192.168.70.2 -l 20 -p 80 -s \"GET /cgi-bin/phf HTTP/1.0\" -t 5 -n 2\n\n" ;
        exit ;

}

my $msg= $opt_s ; 
my $MAX_LENGTH=$opt_n;

my @a;  my $tmp=$msg;

while (length($tmp)) {

   $tmp =~ /^(.{1,$MAX_LENGTH})(.*)$/;

   @a=(@a,$1); $tmp=$2;
}


$remote = IO::Socket::INET->new(
                              Proto    => "tcp",
                              PeerAddr => "$host",
                              PeerPort => "$port",
			      LocalPort => $localport,
                          )
                        or die "cannot connect !!\n";
$remote->autoflush(1);

$i=0 ;
for ($i; $i <= $#a ; $i++)
{
        print $remote "$a[$i]";
        sleep $sleeped;
}
if ($port == 80) {print $remote "\n\n" ;}
while ( <$remote> ) { print }
exit ;
