#
# SARA XML Tree
#
$tag_scan         = "SARA_SCAN";
$tag_scan_info    = "xmlns=\"www-arc.com/xml/sarascan\"";
$tag_info         = "SCAN_INFO";
$tag_id           = "SCAN_ID";
$tag_date         = "SCAN_DATE";
$tag_version      = "SCAN_VERSION";
$tag_level        = "ATTACK_LEVEL";
$tag_level_option = "ATTACK_OPTION";
$tag_vul_sum      = "VULNERABILITY_SUMMARY";
$tag_vul_cnt      = "VULNERABILITY_COUNT";
$tag_details      = "DETAILS";
$tag_subnet       = "SUBNET";
$tag_sub_info     = "SUBNET_INFO";
$tag_host         = "HOST";
$tag_host_IP      = "HOST_IP_ADDRESS";
$tag_host_mac     = "HOST_MAC_ADDRESS";
$tag_host_desc    = "HOST_DESCRIPTION";
$tag_host_name    = "HOST_NAME";
$tag_host_nb      = "HOST_NETBIOS_NAME";
$tag_host_domain  = "HOST_NETBIOS_DOMAIN";
$tag_host_os      = "HOST_TYPE";
$tag_host_fw      = "HOST_FIREWALL";
$tag_host_green   = "HOST_GREEN_SVC";
$tag_host_red     = "HOST_RED_VULNERABILITIES";
$tag_host_yellow  = "HOST_YELLOW_VULNERABILITIES";
$tag_host_brown   = "HOST_BROWN_VULNERABILITIES";
$tag_host_gray    = "HOST_GRAY_VULNERABILITIES";
$tag_vuls         = "VULNERABILITIES";
$tag_vul          = "VULNERABILITY";
$tag_severity     = "SEVERITY";
$tag_service      = "SERVICE";
$tag_svc_name     = "NAME";
$tag_svc_port     = "PORT";
$tag_class        = "CLASS";
$tag_data         = "DATA";
$tag_nvd          = "NVD";
$tag_cve          = "CVE";
$tag_nvd_desc     = "NVD_DESC";
$tag_nvd_cvss     = "NVD_CVSS";
$tag_nvd_severity = "NVD_SEVERITY";
$tag_nvd_sys      = "NVD_NVD_SYS";
$tag_nvd_publish  = "NVD_PUBLISH";
$tag_nvd_refs     = "NVD_REFS";
$tag_nvd_ref      = "NVD_REF";
$tag_nvd_range    = "NVD_RANGE";
$tag_nvd_loss     = "NVD_LOSS_TYPES";
$tag_nvd_vuln     = "NVD_VULN_TYPES";
$tag_sans         = "SANS";
$tag_fp           = "FALSE_POSITIVE";
#
# SARA CVE Tree
#
@csv_def  = ("$tag_host_name","$tag_host_IP","$tag_host_nb","$tag_host_os",
              "$tag_host_mac","$tag_host_fw","$tag_svc_name","$tag_svc_port",
              "$tag_severity","$tag_class","$tag_data","$tag_id","$tag_date",
              "$tag_fp","$tag_cve","$tag_sans", "$tag_nvd_cvss");
#
#
# SARA HTML Tree
#
# Functions
# &table($a, $b,$c,$d,$e)
# &chart($a, $b,$c,$d,$e)
# &sum($a, "string"):     Sums occurrences per host

sub print_host_details {
  for $_host (keys %host_data) {
    $fw_note = $host_data{$_host}{$tag_host_fw};
    if ($fw_note !~ /none/) {
      $fw_note = "Note: Host may be protected by a firewall ($fw_note)";
      $fw_star = '*';
    } else {
      $fw_note = "";
      $fw_star = "";
    }
  print HTM<<EOF;
     <UL>
     IP:      $_host $fw_star<BR> 
     Subnet:  $host_data{$_host}{$tag_sub_info}<BR>
     Name:    $host_data{$_host}{$tag_host_name} ($_host)<BR>
     Netbios: $host_data{$_host}{$tag_host_nb}<BR>
     OS:      $host_data{$_host}{$tag_host_os}<BR>
     <P>  
     Non Vulnerable services
     <P>
     <UL>
EOF
      for $_service (keys %green_data) {
       if ( "$green_data{$_service}{$tag_host_IP}" =~ /x $_host x/) {
        print HTM<<EOF;
        $_service ($green_data{$_service}{$tag_svc_port})<BR>
EOF
       }
      }

      print HTM <<EOF;
      <P>
      </UL>
      Vulnerabilities
      <P>;
      <UL>
EOF
      for $_data (keys %vuln_data) {
       if ( "$vuln_data{$_data}{$tag_host_IP}" =~ /x $_host x/) {
         print HTM<<EOF;
         $vuln_data{$_data}{$tag_class} ($vuln_data{$_data}{$tag_severity})$guess_star<BR>
         $_data<BR>
EOF
       }
      }
      print HTM <<EOF;
      <P>
      <B>$fw_star $fw_note</B>
      <B>$guess_star $guess_note</B> 
      </UL>
      ----------------------------------------------------<BR>
EOF
      }
  print HTM <<EOF;
  </UL>
EOF
}
1;
