#!/usr/bin/perl5.8.4

# bin/netapi.sara
#
# Last Mod 16 Aug 06, 12:00:00 by Bob Todd
#
require 'config/paths.pl';
require 'config/sara.cf';
require 'perl/misc.pl';
require 'perllib/getopts.pl';

$service_output = "";
$printed        = "";
$service        = "netapi";

&Getopts("v");
if ($#ARGV < 0) {
   die "Usage: bin/netapi.sara hostname\n";
}
$target = $ARGV[0];
$args = "$target"; 
  open (API, "perl/contrib/ms06-040.pl $args |");
  while(<API>) {
    chomp;
     if (/MS06-040 VULNERABLE/) {
         $sid = "MISC-010";
         ($severity,$service_output,$text,$cve) = &get_sid($sid);
         $text =~ s/\n//;
         $status = "a";
         $trustee = "ANY\@$target";
         $trusted = "ANY\@$target";
         $printed = "YES";
     } elsif (/2003/ && /VULNERABLE/) {
         $sid = "MISC-011";
         ($severity,$service_output,$text,$cve) = &get_sid($sid);
         $text =~ s/\n//;
         $status = "a";
         $trustee = "ANY\@$target";
         $trusted = "ANY\@$target";
         $printed = "YES";
     } elsif (/not VULNERABLE/) {
         $printed = "NO";
     }	 

  }
close (API);   
&sara_print() if $printed eq "YES";

