delete_Target($delete_tgt); header("Location: index.php"); } elseif ($delete_findings) { $db->delete_Target_Findings($delete_tgt_findings); $findings_deleted = true; } elseif ($sec_tgt > 0) { $tgt_id = filter_input(INPUT_POST, 'tgt', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE); $db->merge_Target($ste_id, $tgt_id, $sec_tgt); } $required = ""; $task_status = $db->get_Task_Statuses(); $gen_os = $db->get_Software("cpe:/o:generic:generic:-"); if (is_array($gen_os) && count($gen_os) && isset($gen_os[0]) && is_a($gen_os[0], 'software')) { $gen_os = $gen_os[0]; } // Update or insert new target if ($action == 'insert') { $params = array( 'cat' => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1)), 'ste' => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1)), "Classification" => array('filter' => FILTER_VALIDATE_REGEXP, 'options' => array('regexp' => "/U|FOUO|S/")), "DeviceName" => FILTER_SANITIZE_STRING, "osSoftware" => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1)), "location" => FILTER_SANITIZE_STRING, "automated_taskStatus" => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1, 'max_range' => 5)), "manual_taskStatus" => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1, 'max_range' => 5)), "dataGathering_taskStatus" => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1, 'max_range' => 5)), "fp_CAT1_taskStatus" => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1, 'max_range' => 5)), "applicableChecklists" => array('filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_ARRAY), "suspend_pp" => array('filter' => FILTER_VALIDATE_BOOLEAN, 'flags' => FILTER_NULL_ON_FAILURE), "targetNotes" => FILTER_SANITIZE_STRING ); $vals = filter_input_array(INPUT_POST, $params); $tgt = new target($vals['DeviceName']); $tgt->set_STE_ID($vals['ste']); $tgt->set_Auto_Status_ID($vals['automated_taskStatus']); $tgt->set_Man_Status_ID($vals['manual_taskStatus']); $tgt->set_Data_Status_ID($vals['dataGathering_taskStatus']); $tgt->set_FP_Cat1_Status_ID($vals['fp_CAT1_taskStatus']); $tgt->set_Location($vals['location']); $tgt->classification = $vals['Classification']; $tgt->set_Notes(trim($vals['targetNotes'])); $tgt->set_PP_Suspended((boolean) $vals['suspend_pp']); if ($vals['cat'] && is_numeric($vals['cat'])) { $tgt->set_Cat_ID($vals['cat']); } if (is_array($vals['applicableChecklists']) && count($vals['applicableChecklists'])) { foreach ($vals['applicableChecklists'] as $chk_id) { $chk = $db->get_Checklist($chk_id); if (is_array($chk) && count($chk) && isset($chk[0]) && is_a($chk[0], 'checklist')) { $tgt->checklists[$chk_id] = $chk[0]; } } } else { foreach ($tgt->checklists as $key => $chk) { unset($tgt->checklists[$key]); } } if ($vals['osSoftware'] > 0) { $os = $db->get_Software($vals['osSoftware']); if (is_array($os) && count($os) && isset($os[0]) && is_a($os[0], 'software')) { $tgt->set_OS_ID($os[0]->get_ID()); $tgt->set_OS_String($os[0]->get_Shortened_SW_String()); } } $ret = $db->save_Target($tgt); if (!$ret) { print 'Error Saving Target'; } header('Location: /ste/index.php'); } elseif ($action == 'update') { $params = array( "Classification" => array('filter' => FILTER_VALIDATE_REGEXP, 'options' => array('regexp' => "/U|FOUO|S/")), "DeviceName" => FILTER_SANITIZE_STRING, 'ste' => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1)), "tgt" => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1)), "osSoftware" => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1)), "location" => FILTER_SANITIZE_STRING, "automated_taskStatus" => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1, 'max_range' => 5)), "manual_taskStatus" => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1, 'max_range' => 5)), "dataGathering_taskStatus" => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1, 'max_range' => 5)), "fp_CAT1_taskStatus" => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1, 'max_range' => 5)), "applicableChecklists" => array('filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_ARRAY), "installedSoftware" => array('filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_ARRAY), "suspend_pp" => array('filter' => FILTER_VALIDATE_BOOLEAN, 'flags' => FILTER_NULL_ON_FAILURE), "targetNotes" => FILTER_SANITIZE_STRING, "missingPatches" => FILTER_SANITIZE_STRING, "netstatConnections" => FILTER_SANITIZE_STRING, "login" => FILTER_SANITIZE_STRING, "new" => array('filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_ARRAY), "ip" => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_REQUIRE_ARRAY), "hostname" => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_REQUIRE_ARRAY), "name" => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_REQUIRE_ARRAY), "fqdn" => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_REQUIRE_ARRAY), "description" => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_REQUIRE_ARRAY) ); $vals = filter_input_array(INPUT_POST, $params); $tgt = $db->get_Target_Details($vals['ste'], $vals['tgt']); if (is_array($tgt) && count($tgt) && isset($tgt[0]) && is_a($tgt[0], 'target')) { $tgt = $tgt[0]; } else { die(nl2br(print_r($tgt, true))); } $tgt->set_ID($vals['tgt']); $tgt->set_Name($vals['DeviceName']); $tgt->set_STE_ID($vals['ste']); $tgt->set_Auto_Status_ID($vals['automated_taskStatus']); $tgt->set_Man_Status_ID($vals['manual_taskStatus']); $tgt->set_Data_Status_ID($vals['dataGathering_taskStatus']); $tgt->set_FP_Cat1_Status_ID($vals['fp_CAT1_taskStatus']); $tgt->set_Location($vals['location']); $tgt->classification = $vals['Classification']; $tgt->set_Notes(trim($vals['targetNotes'])); $tgt->set_Netstat_Connections(trim($vals['netstatConnections'])); $tgt->set_Missing_Patches(trim($vals['missingPatches'])); $tgt->set_Login($vals['login']); $tgt->set_PP_Suspended((boolean) $vals['suspend_pp']); if ($vals['osSoftware'] > 0) { $os = $db->get_Software($vals['osSoftware']); if (is_array($os) && count($os) && isset($os[0]) && is_a($os[0], 'software')) { $tgt->set_OS_ID($os[0]->get_ID()); $tgt->set_OS_String($os[0]->get_Shortened_SW_String()); } } if (is_array($vals['applicableChecklists']) && count($vals['applicableChecklists'])) { $tgt->checklists = array(); foreach ($vals['applicableChecklists'] as $chk_id) { $chk = $db->get_Checklist($chk_id); if (is_array($chk) && count($chk) && isset($chk[0]) && is_a($chk[0], 'checklist')) { $tgt->checklists[$chk_id] = $chk[0]; } } } else { foreach ($tgt->checklists as $key => $chk) { unset($tgt->checklists[$key]); } } if (is_array($vals['installedSoftware']) && count($vals['installedSoftware'])) { $tgt->software = array(); foreach ($vals['installedSoftware'] as $sw_id) { $sw = $db->get_Software($sw_id); if (is_array($sw) && count($sw) && isset($sw[0]) && is_a($sw[0], 'software')) { $tgt->software[$sw_id] = $sw[0]; } } } else { foreach ($tgt->software as $key => $chk) { unset($tgt->software[$key]); } } if (is_array($vals['ip']) && count($vals['ip'])) { foreach ($vals['ip'] as $id => $ip) { $ipv4 = null; $ipv6 = null; if (preg_match("/:/", $ip)) { $ipv6 = $ip; } else { $ipv4 = $ip; } if (strtolower($ip) == 'delete') { foreach ($tgt->interfaces as $idx => $int) { if ($int->get_ID() == $id) { Sagacity_Error::err_handler("Deleting target ({$tgt->get_ID()}) interface (ID: {$int->get_ID()} IP: $ip)"); unset($tgt->interfaces["{$idx}"]); break; } } $db->delete_Interface($id); } else { if (isset($tgt->interfaces["$ip"])) { $int = $tgt->interfaces["$ip"]; $int->set_Name($vals['name'][$id]); $int->set_IPv4($ipv4); $int->set_IPv6($ipv6); $int->set_Description($vals['description'][$id]); $int->set_Hostname($vals['hostname'][$id]); $int->set_FQDN($vals['fqdn'][$id]); } else { $int = new interfaces(null, $tgt->get_ID(), $vals['name'][$id], $ipv4, $ipv6, $vals['hostname'][$id], $vals['fqdn'][$id], $vals['description'][$id]); } $tgt->interfaces["$ip"] = $int; } } } $ret = $db->save_Target($tgt); header("Location: /ste/"); } elseif ($action == 'data_collection') { include_once 'import.inc'; $import = new import(); $import->import_Host_Data_Collection(); } // If there is 'tgt' in the querystring if ($tgt_id && $ste_id) { $tgt = $db->get_Target_Details($ste_id, $tgt_id)[0]; $ste = $db->get_STE($tgt->get_STE_ID())[0]; } else { $tgt = null; $checklists = array(); } $title_prefix = ($tgt_id ? "Edit " . $tgt->get_Name() : "Add Target"); include_once 'header.inc'; ?>
" : ''); ?> " /> get_ID() : '1'); ?>' />
Findings Deleted
"; } ?>
Basic Information
ST&E Name: {$ste->get_System()->get_Name()}, {$ste->get_Site()->get_Name()}, {$ste->get_Eval_Start_Date()->format("d M Y")}"; print ""; } else { ?>
Class
Name:
OS: get_OS_String()}"; } else { print ""; } ?>
Location:
Automated: Manual:
Data: FP/CAT I:
Available Checklists:
Add One
Remove One
Remove All
Applicable Checklists:
is_PP_Suspended() ? 'checked' : ''; ?> />
Notes:
Target Details
Available Software:
Remove One
Installed Software:
Missing
Patches:
Netstat
Connections:
Login:

Ports / Protocols & Services

interfaces as $intface) { if ($intface->get_IPv4() != '0.0.0.0' && $intface->get_IPv6() != '::') { print $intface->get_Table_Data($odd); // This flips the bool everytime it loops // This is for odd and even row colors $odd = !$odd; } } } ?>
IP Host Name Interface FQDN Description
Port / Protocol Listening IANA Name Notes
interfaces as $intface) { try { $tcp_ports = $intface->get_TCP_Ports(); $udp_ports = $intface->get_UDP_Ports(); } catch (Exception $e) { } if ($tcp_ports != null) { foreach ($tcp_ports as $key => $tcp) { $port_num = str_pad($tcp->get_Port(), 5, '0', STR_PAD_LEFT); $ports[$port_num . '/tcp/' . $intface->get_ID()] = array( 'intid' => $intface->get_ID(), 'ip' => ($intface->get_IPv4() ? $intface->get_IPv4() : $intface->get_IPv6()), 'port' => $tcp ); } } if ($udp_ports != null) { foreach ($udp_ports as $key => $udp) { $port_num = str_pad($udp->get_Port(), 5, '0', STR_PAD_LEFT); $ports[$port_num . '/udp/' . $intface->get_ID()] = array( 'intid' => $intface->get_ID(), 'ip' => ($intface->get_IPv4() ? $intface->get_IPv4() : $intface->get_IPv6()), 'port' => $udp ); } } } ksort($ports, SORT_STRING); foreach ($ports as $key => $port) { print $port['port']->get_Table_Data($port['ip'], $port['intid'], $odd); $odd = !$odd; } } ?>
Primary target: get_Name() : null); ?>
Secondary target:
get_Name()}"); $answer_file = glob(realpath(TMP . "/data_collection/{$tgt->get_Name()}") . "/*-answers.txt"); if (count($answer_file) > 1) { print "
WARNING: More than one answer file is present, please reconcile before proceeding

"; } if (count($answer_file)) { print "
Answer file is already present ({$answer_file[0]})

"; $answers = file($answer_file[0]); foreach ($answers as $answer) { print "$answer
"; } } ?>