#!/usr/bin/perl5.8.4
#  This software was derived from SATAN 1.1.1 by Dan Farmer and Wietse Venema
#  (http://www.porcupine.org/satan).
#
#
# version 1, Mon Apr 29 23:30:00 2001, last mod by todd
#

require 'config/sara.cf';
require 'config/paths.pl';
require 'perl/misc.pl';
require 'perllib/getopts.pl';

$usage = "usage $0 [-v]  target";
 
&Getopts("v") || die $usage;
die $usage unless ($#ARGV >= 0);

$target = $ARGV[0];
$status = "a";

$| = 1; 

open(SERVICES, $SERVICES) || die "$0: cannot open $SERVICES: $!\n";
while (<SERVICES>) {
	$service_name{$2} = $1 if /(\S+)\s+([0-9]+)\/tcp/;
}
close(SERVICES);

$command = "$TCP_SCAN -b $target netstat";
print "$command\n" if $opt_v;

open(TCP_SCAN, "$command|")
	|| die "$0: cannot run $TCP_SCAN";

while(<TCP_SCAN>) {
	if (defined($opt_v)) {
	    print "DEBUG $_\n";
	}
	chomp;
        if (/option/) {
          $sid = 'MISC-005';
          ($severity,$service_output,$text, $cve) = &get_sid($sid);
          $status  = "a";
          $service = "netstat";
          $text =~ s/\;/$service/;
          $severity = "zwoi";
          $trustee = "ANY\@$target";
          $trusted = "ANY\@$target";
	  &sara_print();
        }
}
