Listing 2, banner.pl:

#!/usr/bin/env perl

use Nmap::Parser;
use Net::Telnet;

my $NMAP_EXE = "/usr/local/bin/nmap ";
 
my $NMAP_ARGS = "-sT -p1-1024";

my $target_net = $ARGV[0];

my $np = new Nmap::Parser;

$np -> parse_filters({only_active => 1});
$np -> register_host_callback(\&new_host);
$np -> parsescan($NMAP_EXE, $NMAP_ARGS, $target_net);

sub new_host {
	my $self = shift;
	
	$ip = $self -> ipv4_addr();
	
	foreach $port ($self -> tcp_ports('open')) {
		# connect to each port with Net::Telnet
		print "Attempting to connect to $ip:$port\n";
		my $nt = new Net::Telnet (
					BinMode => 0,
					Host => $ip,
					Port => $port,
					Errmode => 'return',
					Telnetmode => 0,
					Timeout => 5
					);

		if ($nt) {
			$nt -> put("\n\n");
			$lines = 0;
			while ($lines < 5 && $nt) {
				$line = $nt -> getline();
				print "$line";
				$lines++;
			}
			$nt -> close();
		} else {
			print "Unable to connect to $ip:$port\n";
		}
	}

	return;
}


