From ChekMate Security Group
#!/usr/bin/env perl
#
#
# Copyright (C) 2006 Joshua D. Abraham (jabra@ccs.neu.edu)
#
# This program is released under the terms of the GNU General Public License
# (GPL), which is distributed with this software in the file "COPYING".
# The GPL specifies the terms under which users may copy and use this software.
#
# Author: Joshua D. Abraham
# Date: July 30, 2006
#
use strict;
use warnings;
use IO::Socket::SSL;
use IO::Socket;
my $raw = 0;
my @ports = (22, 25, 631);
#my @ports = (80, 443);
my $target;
if ( @ARGV == 0 ) {
print "Usage $0 [ip]\n";
exit;
}
else {
$target = $ARGV[0];
}
print "target is $target\n";
foreach(@ports){
print "\nport is $_\n";
print "banner is: ";
if ($_ eq 22 or $_ eq 25 or $_ eq 80 or $_ eq 631){
my $out1;
my $remote2 = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => $target,
PeerPort => $_,
)
or die "cannot connect to port $_ port at $target";
print $remote2 "GET \n";
while ( <$remote2> ) {
if (defined($_)){
$out1 .= $_;
next;
}
last;
}
close $remote2;
print $out1;
}
elsif ($_ eq 443){
print "port is $_\n";
print "banner is: ";
my $out2;
my $client = IO::Socket::SSL->new("$target:https");
if ($client) {
print $client "GET / HTTP/1.0\r\n\r\n";
while ( <$client> ) {
if (defined($_)){
# chomp;
$out2 .= $_;
next;
}
last;
}
close $client;
print $out2;
} else {
warn "I encountered a problem: connecting to $_ on $target",
IO::Socket::SSL::errstr();
}
}
else {
print "port not supported\n";
}
}