#
#
#
$myurl="saint_results_danger.pl";

&recalc_host_severity_count;

print CLIENT <<EOF;
<HTML>
<HEAD>
<TITLE>Vulnerabilities - Danger Levels</TITLE>
<LINK REV="made" HREF="mailto:saint\@saintcorporation.com">
</HEAD>
<BODY BGCOLOR="white" vlink="#000000" link="#04289D">

<P></P>

<P>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
	<TR>
		<TD COLSPAN="2"><IMG SRC="$HTML_ROOT/images/data_analysis_banner.gif" WIDTH="621" HEIGHT="106" ALIGN="BOTTOM" ALT="Data Analysis" BORDER="0"></TD>
	</TR>
	<TR>
	  <TD WIDTH="86" VALIGN="TOP">
	    <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
		<TR>
		    <TD WIDTH="86"><A HREF="http://www.saintcorporation.com"><IMG SRC="$HTML_ROOT/images/home.gif" WIDTH="86" HEIGHT="55" ALIGN="BOTTOM" ALT="SAINT Corporation"
			BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_ROOT/saint.html"><IMG SRC="$HTML_ROOT/images/home_button.gif" WIDTH="86" HEIGHT="46"
			ALIGN="BOTTOM" ALT="SAINT Home" BORDER="0" STYLE="Background-Image : none"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/data/saint_data_form.pl"><IMG SRC="$HTML_ROOT/images/data_mgmt_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Data Management" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/running/saint_run_form.pl"><IMG SRC="$HTML_ROOT/images/target_selection_button.gif"
			WIDTH="86" HEIGHT="46" ALIGN="BOTTOM" ALT="Target Selection" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/reporting/analysis.pl"><IMG SRC="$HTML_ROOT/images/data_analysis_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Data Analysis" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_SERVER/admin/saint_cf_form.pl"><IMG SRC="$HTML_ROOT/images/config_mgmt_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Configuration Management" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86"><A HREF="$HTML_ROOT/saint_documentation.html"><IMG SRC="$HTML_ROOT/images/documentation_button.gif"
			WIDTH="86" HEIGHT="46" ALIGN="BOTTOM" ALT="SAINT Documentation" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86" HEIGHT="46"><A HREF="$HTML_ROOT/docs/FAQ.html#trouble"><IMG SRC="$HTML_ROOT/images/troubleshooting_button.gif" WIDTH="86"
			HEIGHT="46" ALIGN="BOTTOM" ALT="Troubleshooting" BORDER="0"></A></TD>
		</TR>
		<TR>
		    <TD WIDTH="86" HEIGHT="65"><IMG SRC="$HTML_ROOT/images/bottom_border.gif" WIDTH="86" HEIGHT="75" ALIGN="BOTTOM" ALT="--------" BORDER="0"></TD>
		</TR>
	    </TABLE>
	  </TD>
	  <TD VALIGN="TOP">
		<DL>
			<P>
		</DL>
<H1><Center> Vulnerabilities - Danger Levels</Center></H1>
<HR>
<UL><UL>
EOF
;
# Critical Problems
$_rs = $_us = $_ns = $_uw = $_ur = $_nw = $_nr = $_nfs = $_ht = $_bo = "";
$_dos = "";

# Areas of Concern
$_yus = $_yi = $_ype = $_ycs = "";

# Potential Problems
$_zcio = $_zwoi = "";

# make some indices...
if (sizeof(*severity_levels) > 0) {
    for $_type (sort keys %severity_levels) {
      #If not display excluded severities, check that has a non-excluded
      #severity
      if ( ! $Exclusions::display_ignored )
      {       if ( ! any_nonexcluded_facts_by_severity($_type) ) {next;}
      }
	if ($_type eq "rs") {
		$_rs  = "<img src=\"$HTML_ROOT/dots/reddot.gif\" ALT=\"RED\"><A HREF=\"#root\">Root shell</A><BR>"; }
	elsif ($_type eq "us") {
		$_us  = "<img src=\"$HTML_ROOT/dots/reddot.gif\" ALT=\"RED\"><A HREF=\"#user\">User shell</A><BR>"; }
	elsif ($_type eq "ns") {
		$_ns  = "<img src=\"$HTML_ROOT/dots/reddot.gif\" ALT=\"RED\"><A HREF=\"#unprivileged\">Unprivileged shell</A><BR>";}
	elsif ($_type eq "uw") {
		$_uw =  "<img src=\"$HTML_ROOT/dots/reddot.gif\" ALT=\"RED\"><A HREF=\"#user file write\">User file write</A><BR>"; }
	elsif ($_type eq "uw") {
		$_ur =  "<img src=\"$HTML_ROOT/dots/reddot.gif\" ALT=\"RED\"><A HREF=\"#user file read\">User file read</A><BR>"; }
	elsif ($_type eq "nr") {
		$_nr  = "<img src=\"$HTML_ROOT/dots/reddot.gif\" ALT=\"RED\"><A HREF=\"#unpriv file read\">Unprivileged file read</A><BR>"; }
	elsif ($_type eq "nw") {
		$_nw  = "<img src=\"$HTML_ROOT/dots/reddot.gif\" ALT=\"RED\"><A HREF=\"#unpriv file write\">Unprivileged file write</A><BR>"; }
	elsif ($_type eq "x") {
		$_nfs  = "<img src=\"$HTML_ROOT/dots/reddot.gif\" ALT=\"RED\"><A HREF=\"#NFS\">NFS</A><BR>"; }
	elsif ($_type eq "bo") {
		$_bo   = "<img src=\"$HTML_ROOT/dots/reddot.gif\" ALT=\"RED\"><A HREF=\"#buffer overflow\">Root Access via Buffer Overflow</A><BR>"; }
	elsif ($_type eq "ht") {
		$_ht   = "<img src=\"$HTML_ROOT/dots/reddot.gif\" ALT=\"RED\"><A HREF=\"#hacker track\">Evidence of Penetration</A><BR>"; }
	elsif ($_type eq "dos") {
		$_dos  = "<img src=\"$HTML_ROOT/dots/reddot.gif\" ALT=\"RED\"><A HREF=\"#dos\">Denial of Service</A><BR>"; }
	elsif ($_type eq "yus") {
		$_yus  = "<img src=\"$HTML_ROOT/dots/yellowdot.gif\" ALT=\"YELLOW\"><A HREF=\"#X access\">Unlimited X Server Access</A><BR>"; }
	elsif ($_type eq "yi") {
		$_yi  = "<img src=\"$HTML_ROOT/dots/yellowdot.gif\" ALT=\"YELLOW\"><A HREF=\"#info gather\">Information Gathering</A><BR>"; }
	elsif ($_type eq "ype") {
		$_ype  = "<img src=\"$HTML_ROOT/dots/yellowdot.gif\" ALT=\"YELLOW\"><A HREF=\"#priv elevation\">Privilege Elevation</A><BR>"; }
	elsif ($_type eq "ycs") {
		$_ycs  = "<img src=\"$HTML_ROOT/dots/yellowdot.gif\" ALT=\"YELLOW\"><A HREF=\"#cross site\">Use as an Intermediary</A><BR>"; }
	elsif ($_type eq "zcio") {
		$_zcio = "<img src=\"$HTML_ROOT/dots/browndot.gif\" ALT=\"BROWN\"><A HREF=\"#checkitout\">Possible vulnerabilities</A><BR>";}
	elsif ($_type eq "zwoi") {
		$_zwoi = "<img src=\"$HTML_ROOT/dots/browndot.gif\" ALT=\"BROWN\"><A HREF=\"#wantaccess\">Limit Internet Access ? </A><BR>";}
		}

print CLIENT <<EOF;
<h3>Table of contents</h3>
<ul>
<h4>Critical Problems</h4>
$_rs
$_us
$_ns
$_uw
$_ur
$_nr
$_nw
$_nfs
$_bo
$_ht
$_dos
<h4>Areas of Concern</h4>
$_yus
$_yi
$_ype
$_ycs
<h4>Potential Problems</h4>
$_zcio
$_zwoi
</ul>
Note: hosts may appear in multiple categories. 
EOF
	}

&print_show_hide_html_message(\*CLIENT,$myurl);
&make_severity_info();

if (sizeof(*severity_levels) > 0) {
	for $_type (sort keys %severity_levels) {
              if ( ! $Exclusions::display_ignored )
              {       if ( ! any_nonexcluded_facts_by_severity($_type) )
                      {       next;
                      }
              }

		# how serious is it?
		if ($_type eq "rs") {
			$color="RED";
			print CLIENT <<EOF;
			<HR>
			<A NAME="root"><H3><img src="$HTML_ROOT/dots/reddot.gif" ALT="RED">Root shell Problems</FONT></H3></A>
			<HL>
			<dl>
EOF
			}
		elsif ($_type eq "us") {
			$color="RED";
			print CLIENT <<EOF;
			<HR>
			<A NAME="user"><H3><img src="$HTML_ROOT/dots/reddot.gif" ALT="RED">User shell Problems</FONT></H3></A>
			<HL>
			<dl>
EOF
			}
		elsif ($_type eq "ns") {
			$color="RED";
			print CLIENT <<EOF;
			<HR>
			<A NAME="unprivileged"><H3><img src="$HTML_ROOT/dots/reddot.gif" ALT="RED">"nobody" shell Problems</FONT></H3></A>
			<HL>
			<dl>
EOF
			}
		elsif ($_type eq "ur") {
			$color="RED";
			print CLIENT <<EOF;
			<HR>
			<A NAME="user file read"><H3><img src="$HTML_ROOT/dots/reddot.gif" ALT="RED">User reading file problems</FONT></H3></A>
			<HL>
			<dl>
EOF
			}
		elsif ($_type eq "uw") {
			$color="RED";
			print CLIENT <<EOF;
			<HR>
			<A NAME="user file write"><H3><img src="$HTML_ROOT/dots/reddot.gif" ALT="RED">User writing file problems</FONT></H3></A>
			<HL>
			<dl>
EOF
			}
		elsif ($_type eq "nr") {
			$color="RED";
			print CLIENT <<EOF;
			<HR>
			<A NAME="unpriv file read"><H3><img src="$HTML_ROOT/dots/reddot.gif" ALT="RED">"nobody" reading file problems</FONT></H3></A>
			<HL>
			<dl>
EOF
			}
		elsif ($_type eq "nw") {
			$color="RED";
			print CLIENT <<EOF;
			<HR>
			<A NAME="unpriv file write"><H3><img src="$HTML_ROOT/dots/reddot.gif" ALT="RED">"nobody" writing file problems</FONT></H3></A>
			<HL>
			<dl>
EOF
			}
		elsif ($_type eq "nfs") {
			$color="RED";
			print CLIENT <<EOF;
			<HR>
			<A NAME="NFS"><H3><img src="$HTML_ROOT/dots/reddot.gif" ALT="RED">NFS Problems</FONT></H3></A>
			<HL>
			<dl>
EOF
			}
		elsif ($_type eq "bo") {
			$color="RED";
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="buffer overflow"><H3><img src="$HTML_ROOT/dots/reddot.gif" ALT="RED">Root Access via Buffer Overflow</FONT></H3></A>
                        <HL>
                        <dl>
EOF
                        }

	 	elsif ($_type eq "ht") {
			$color="RED";
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="hacker track"><H3><img src="$HTML_ROOT/dots/reddot.gif" ALT="RED">Evidence of Penetration</FONT></H3></A>
                        <HL>
                        <dl>
EOF
                        }
                elsif ($_type eq "dos") {
			$color="RED";
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="dos"><H3><img src="$HTML_ROOT/dots/reddot.gif" ALT="RED">Denial of Service</FONT></H3></A>
                        <HL>
                        <dl>
EOF
                        }
                elsif ($_type eq "yus") {
			$color="YELLOW";
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="X access"><H3><img src="$HTML_ROOT/dots/yellowdot.gif" ALT="YELLOW">Unlimited X Access</FONT></H3></A>
                        <HL>
                        <dl>
EOF
                        }
                elsif ($_type eq "yi") {
			$color="YELLOW";
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="info gather"><H3><img src="$HTML_ROOT/dots/yellowdot.gif" ALT="YELLOW">Information Gathering</FONT></H3></A>
                        <HL>
                        <dl>
EOF
                        }
                elsif ($_type eq "ype") {
			$color="YELLOW";
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="priv elevation"><H3><img src="$HTML_ROOT/dots/yellowdot.gif" ALT="YELLOW">Privilege Elevation</FONT></H3></A>
                        <HL>
                        <dl>
EOF
                        }
                elsif ($_type eq "ycs") {
			$color="YELLOW";
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="cross site"><H3><img src="$HTML_ROOT/dots/yellowdot.gif" ALT="YELLOW">Use as an Intermediary</FONT></H3></A>
                        <HL>
                        <dl>
EOF
                        }

                if ($_type eq "zcio") {
			$color="BROWN";
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="checkitout"><H3><img src="$HTML_ROOT/dots/browndot.gif" ALT="BROWN">Possible Vulnerabilities</FONT></H3></A>
                        <HL>
                        <dl>
EOF
			}
                if ($_type eq "zwoi") {
			$color="BROWN";
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="wantaccess"><H3><img src="$HTML_ROOT/dots/browndot.gif" ALT="BROWN">Limit Internet Access ?</FONT> </H3></A>
                        <HL>
                        <dl>
EOF
			}

		$_last_tmp = "";
		$_last_txt = "";
		# split all the targets into separate lines
		for $_tmp (sort keys %{$severity_levels{$_type}}) {
			for (sort split(/\n/, $severity_levels{$_type}{$_tmp})) {
				my @fact=split_fact_local($_);
				$service_output=$fact[$SERVICE_OUTPUT_FIELD];
				$text=$fact[$TEXT_FIELD];
				if ($cve{$text}) {
				    $cve_ref = "(<A HREF=\"http://cve.mitre.org\">CVE</A>";
				    for (split(/\s+/,$cve{$text})) {
					$cve_ref .= " <A HREF=\"http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-$_\">$_</A>";
				    }
				    $cve_ref .= ")";
				} else {
				    $cve_ref = "";
				}
				if ($top20{$text} =~ /yes/) {
				    $top20_ref = "<IMG SRC=\"$HTML_ROOT/images/top20.gif\" ALT=\"top-20\">";
				} else {
				    $top20_ref = "";
				}
				($_tutorial = $service_output) =~ tr / /_/;
				# just weed out the dups
				next if ($_last_tmp eq $_tmp && $text eq $_last_txt);
				$_last_tmp = $_tmp;
				$_last_txt = $text;
				print_host_vulnerability_by_danger_line(
					\*CLIENT,
					$_tmp, $color, $top20_ref, "<a href=\"$HTML_ROOT/tutorials/vulnerability/$_tutorial.html\">$text</a> $cve_ref",
					$_, $myurl,
					$Exclusions::display_ignored);
				}
			}
		print CLIENT <<EOF;
			</dl>
EOF
		}
	}
else {
	print CLIENT <<EOF;
	<P> No vulnerability information found.
EOF
	}

        print CLIENT <<EOF;
<hr> 
</UL></UL>
</TD></TR>
	  </TD>
	</TR>
</TABLE>
</BODY>
</HTML>
EOF
