#!/usr/bin/perl -w # # A simple program to open a TCP port. Useful for # testing SYN packet issues on state-like firewalls. # # http://www.assdingos.com/grass/ # # Shout outs: Cat5, Rijendaly Llama, chix0r, alx0r, # exial, stormdragon, lucid_fox, # Deathstroke, Harkonen, daverb and # eXoDuS (YNBABWARL!) # # Some code used from snacktime.pl # http://www.planb-security.net/wp/snacktime.html # (C) Tod Beardsley # # Copyright (C) Gr@ve_Rose # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # use warnings; use strict; use Getopt::Std; use IO::Socket::INET; # IPv6 Support - README # To get IPv6 support you will need to install two # additional Perl modules: Socket6 and IO-Socket-INET6 # First, download each package from CPAN: # Socket6 -> http://search.cpan.org/CPAN/authors/id/U/UM/UMEMOTO/Socket6-0.17.tar.gz # INET6 -> http://search.cpan.org/CPAN/authors/id/M/MO/MONDEJAR/IO-Socket-INET6-2.51.tar.gz # Once downloaded, uncompress each file and go into # the new directories. Run the command (as r00t): # perl ./Makefile.PL && make && make install # in each directory to install the modules. You need to # install Socket6 first. # Finally, uncomment the line below and enjoy. # use IO::Socket::INET6; $| = 1 ; # Get rid of the buffer and dump to STDOUT my %options; getopts('m:t:p:s:x:',\%options) || usage(); # Are we asking for the man page? If so, stop here and go there. if ($options{m}) { man(); die; } # Do we have a Target IP? if (not $options{t}) { print "\r\n"; print " [*************ERROR**************]"; print "\n"; print " --==[You forgot the target IP Address]==--"; print "\n"; print " [*************ERROR**************]"; print "\r\n"; usage(); die; } # Do we have a Target Port? if (not $options{p}) { print "\r\n"; print " [**********ERROR***********]"; print "\n"; print " --==[You forgot the target Port]==-"; print "\n"; print " [**********ERROR***********]"; print "\r\n"; usage(); die; } # Do we have a Local Source Port? if (not $options{s}) { print "\r\n"; print " [**********ERROR***********]"; print "\n"; print " --==[You forgot the source Port]==-"; print "\n"; print " [**********ERROR***********]"; print "\r\n"; usage(); die; } # Default to IPv4 or if specified if (not $options{x} or $options{x} == "4") { my $socket = IO::Socket::INET -> new(PeerAddr => $options{t}, PeerPort => $options{p}, LocalPort => $options{s}, Proto => 'tcp'); my $gigo = "\r\n"; # A basic [ENTER] button to send if you want. # See the blurb below for usage of this variable # Go ahead and modify this for a specific protcol # like HELO (port 25), or an HTTP GET request. # If you would like to send a basic [ENTER] (Or whatever you've created) # to the socket once connected, replace: # print $socket # listed below with: # print $socket $gigo printf "\r\nAttempting to connect... (IPv4)\r\n^C sends a FIN packet whenever you are ready to close the connection.\r\n \r\n"; printf $socket || die "There was an error in the connection. Check the following:\r\n- Closed/filtered port?\r\n- If you are using the same source port, the TCP connection may not have ended. Send a FIN/RST or wait until your TCP End Timeout has been reached.\r\n \r\n"; while (<$socket>) { print $_; } } # If IPv6 is explicitly defined in the command variable... if ($options{x} == "6") { my $socket = IO::Socket::INET6 -> new(PeerAddr => $options{t}, PeerPort => $options{p}, LocalPort => $options{s}, Proto => 'tcp'); my $gigo = "\r\n"; # See note above for $gigo usage... printf "\r\nAttempting to connect... (IPv6)\r\n^C sends a FIN packet whenever you are ready to close the connection.\r\n \r\n"; printf $socket || die "There was an error in the connection. Check the following:\r\n- Closed/filtered port?\r\n- If you are using the same source port, the TCP connection may not have ended. Send a FIN/RST or wait until your TCP End Timeout has been reached.\r\n \r\n"; while (<$socket>) { print $_; } } sub usage { die <