#  This software was derived from SATAN 1.1.1 by Dan Farmer and Wietse Venema
#  (http://www.porcupine.org/satan).
#
#
#
#

print CLIENT <<EOF;
<HTML>
<HEAD>
<SCRIPT language="JavaScript">
  function movepic(img_name,img_src) {
  document[img_name].src=img_src;
}
</SCRIPT>
<TITLE>Vulnerabilities - Danger Levels</TITLE>
<LINK REV="made" HREF="mailto:satan\@fish.com">
<LINK REV="made" HREF="mailto:sara\@arc.com">
</HEAD>
<BODY>
EOF
if ($pi_menu) {
  $screen = &$pi_menu;
} else {
  $screen = print_menu();
}
$screen =~ s/\\n/\n/g;
print CLIENT $screen;
print CLIENT <<EOF;
</TD><TD valign=top>
<H1><Center> Vulnerabilities - Danger Levels</Center></H1>
<HR>
EOF
;
# Critical Problems
$_rs = $_us = $_ns = $_uw = $_ur = $_nw = $_nr = $_nfs = $_ht = $_bo = "";

# Areas of Concern
$_yus = $_ycio = "";

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

# make some indices...
if (sizeof(*severity_levels) > 0) {
	for $_type (sort keys %severity_levels) {
	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 "yus") {
		$_yus  = "<img src=\"$HTML_ROOT/dots/yellowdot.gif\" ALT=\"YELLOW\"><A HREF=\"#X access\">Unlimited X Server Access</A><BR>"; }
        elsif ($_type eq "ycio") {
                $_ycio  = "<img src=\"$HTML_ROOT/dots/yellowdot.gif\" ALT=\"YELLOW\"><A HREF=\"#abuse\">Target for Abuse</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
<h4>Areas of Concern</h4>
$_yus
$_ycio
<h4>Potential Problems</h4>
$_zcio
$_zwoi
</ul>
Note: hosts may appear in multiple categories. 
EOF
	}

&make_severity_info();

if (sizeof(*severity_levels) > 0) {
	for $_type (sort keys %severity_levels) {

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

	 	elsif ($_type eq "ht") {
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="hacker track"><H3><FONT COLOR=RED>Evidence of Penetration</FONT></H3></A>
                        <HL>
                        <UL>
EOF
                        }
                elsif ($_type eq "yus") {
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="X access"><H3><FONT COLOR=YELLOW>Unlimited Access</FONT></H3></A>
                        <HL>
                        <UL>
EOF
                        }

                elsif ($_type eq "ycio") {
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="abuse"><H3><FONT COLOR=YELLOW>Target for Abuse</FONT></H3></A>
                        <HL>
                        <UL>
EOF
                        }
                if ($_type eq "zcio") {
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="checkitout"><H3><FONT COLOR=BROWN>Possible Vulnerabilities</FONT></H3></A>
                        <HL>
                        <UL>
EOF
			}
                if ($_type eq "zwoi") {
                        print CLIENT <<EOF;
                        <HR>
                        <A NAME="wantaccess"><H3><FONT COLOR=BROWN>Limit Internet Access ?</FONT> </H3></A>
                        <HL>
                        <UL>
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})) {
				&sara_split($_);
				($_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 CLIENT <<EOF;
			<li> 
EOF
                        $cve = &get_cve($service_output, $text);
                        $TUT = "nvd/$cve.html";
                        $TUT = "nvd/NOCVE.html" if (!$cve);
                        print CLIENT <<EOF;
			<a href="sara_info_host.pl,$_tmp,">$_tmp</a> 
			<a href="$HTML_ROOT/$TUT">($text)</a>
EOF
				}
			}
		print CLIENT <<EOF;
			</UL>
EOF
		}
	}
else {
	print CLIENT <<EOF;
	<P> No vulnerability information found.
EOF
	}

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