#  This software was derived from SATAN 1.1.1 by Dan Farmer and Wietse Venema
#  (http://www.porcupine.org/satan).
#
#
# Display a FORM to select the primary target and to give the user a chance to
# override some defaults.
#
($_host) = split(/,/, $html_script_args);

#
# First figure out what radio buttons etc. should be "on". Note: the
# variables below are global. Perhaps we should hide in our own package
# name space.
#
 foreach (keys %ENV) {
   $firewall_flag=$ENV{SARA_FW};
}
$fwf = 0;
$fwf = 1 if $firewall_flag;

@check_subnets = ();	$check_subnets[$attack_proximate_subnets] = "checked";
@check_level = ();	$check_level[$attack_level] = "checked";
@check_firewall = ();	$check_firewall [$fwf] = "checked";

#
# In case the primary target has not yet been set.
#
$primary_target = $THIS_HOST unless $primary_target;
$_host = $primary_target unless $_host;
print CLIENT <<EOF;
<HTML>
<HEAD>
<META HTTP-EQUIV="Expires" CONTENT="Tue, 04 Dec 1993 21:29:02 GMT">
<SCRIPT language="JavaScript">
  function movepic(img_name,img_src) {
  document[img_name].src=img_src;
}
</SCRIPT>
</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>
EOF
if ($pi_target) {
  $screen = &$pi_target;
  $screen =~ s/\\n/\n/g;
  print CLIENT "$screen";
} else {
print CLIENT <<EOF;
<TABLE BORDER="0" WIDTH="650"
<TR><TD BGCOLOR="#000000">
<Font Color="#FFFFFF">
<Center> <H2> SARA Target Selection</H2></Center>
</FONT>
</TD></TR></TABLE>
<UL>
EOF
if ($daemon && $allow_scan == 0) {
  print CLIENT <<EOF;
  <H3>Target Selection Prohibited</H3>
  SARA does not allow remote target selection
  <HR>
EOF
} else {

print CLIENT<<EOF;

<FORM METHOD=POST ACTION="sara_run_action.pl">

<h3> Primary target selection </h3>

Primary target host, network, or range.<BR>
<Font size=1>
<PRE>
   Host example     myhost.local.com
   Hosts example    myhost1.local.com myhost2.local.com ...
   Network example  192.168.0.0/23 (two class C subnets)
   Range example    192.168.0.55-192.168.0.98
</PRE>
</Font>
<INPUT SIZE="48" NAME="primary_target" Value="$_host">
<input Type=hidden Name=sequence Value="$seq">
<P>
<DL compact>
<DT><DD><input color=white type=radio name="attack_proximate_subnets" value="0" $check_subnets[0]>
	Scan the referenced target(s), network(s), or range.

<DT><DD><input type=radio name="attack_proximate_subnets" value="1" $check_subnets[1]>
	Scan hosts in the primary subnet (defined by a single target only).
</DL>

<HR>

<h3> Scanning level selection </h3>

Should SARA do a light scan, a normal scan, or should it hit the
(primary) target(s) at full blast?

<P>

<DL compact>
<DT><DD><input type=radio name="attack_level" value="0" $check_level[0]>
	Light
<DT><DD><input type=radio name="attack_level" value="1" $check_level[1]>
	Normal (may be detected even with minimal logging)
<DT><DD><input type=radio name="attack_level" value="2" $check_level[2]> 
	Heavy (error messages may appear on systems consoles)
<DT><DD><input type=radio name="attack_level" value="3" $check_level[3]>
	Extreme (some unpatched services may fail)
EOF
if ( $custom0_string ) {
print CLIENT <<EOF;
<DT><DD><input type=radio name="attack_level" value="4" $check_level[4]>
       $custom0_string 
EOF
}
if ( $custom1_string ) {
print CLIENT <<EOF;
<DT><DD><input type=radio name="attack_level" value="5" $check_level[5]>
       $custom1_string
EOF
}
if ( $custom2_string ) {
print CLIENT <<EOF;
<DT><DD><input type=radio name="attack_level" value="6" $check_level[6]>
       $custom2_string
EOF
}
print CLIENT <<EOF;
</DL>

<CENTER><INPUT TYPE="submit" VALUE=" Start the scan "></CENTER>
<P>
EOF
if ($daemon) {
print CLIENT <<EOF;
<I>Note:  Once started, the scan cannot be interrupted. For
single host scans, the process should take less than 10
minutes.  For network scans, it may take several hours.
This screen will not change until the scan is complete.</I>
EOF
}
print CLIENT <<EOF;
</UL></UL>
</TD></TR></TABLE>
</FORM>
</BODY>
</HTML>
EOF
  }
}
