Exemple #1
0
    ?>
  </a>
    </p>
<?php 
    exit;
}
require_once 'ossim_db.inc';
require_once 'classes/Host.inc';
require_once 'classes/Host_scan.inc';
$db = new ossim_db();
$conn = $db->connect();
if (Host::can_delete($conn, $ip)) {
    if (Host_scan::in_host_scan($conn, $ip, 2007)) {
        Host_scan::delete($conn, $ip, 2007);
    }
    Host_scan::delete($conn, $ip, 3001);
    Host::delete($conn, $ip);
} else {
    echo "ERROR_CANNOT";
}
$db->close($conn);
?>

    <p> <?php 
echo gettext("Host deleted");
?>
 </p>
    <p><a href="host.php"><?php 
echo gettext("Back");
?>
 </a></p>
Exemple #2
0
$plugin_id = GET('plugin_id');
ossim_valid($host_ip, OSS_IP_ADDR, 'illegal:' . _("IP Address"));
ossim_valid($plugin_id, OSS_DIGIT, 'illegal:' . _("Plugin id"));
if (ossim_error()) {
    die(ossim_error());
}
if (GET('confirm')) {
    echo "<p> " . gettext("Are you sure") . " ?</p>";
    echo "<p><a href=\"" . $_SERVER["SCRIPT_NAME"] . "?host_ip={$host_ip}&plugin_id={$plugin_id}&confirm=yes\">Yes</a>" . "&nbsp;&nbsp;&nbsp;<a href=\"hostscan.php\">No</a></p>";
    exit;
}
require_once 'ossim_db.inc';
require_once 'classes/Host_scan.inc';
$db = new ossim_db();
$conn = $db->connect();
Host_scan::delete($conn, $host_ip, $plugin_id);
$db->close($conn);
?>
    <p> <?php 
echo gettext("Host scan configuration deleted");
?>
 </p>
    <p><a href="hostscan.php"> <?php 
echo gettext("Back");
?>
 </a></p>
    <?php 
exit;
?>

</body>
Exemple #3
0
 $xml .= "<row id='{$ip}'>";
 $name = "<a href=\"../report/index.php?host={$ip}\">" . $host->get_hostname() . "</a>";
 $xml .= "<cell><![CDATA[" . $name . "]]></cell>";
 $xml .= "<cell><![CDATA[" . $ip . "]]></cell>";
 $xml .= "<cell><![CDATA[" . $host->get_asset() . "]]></cell>";
 $xml .= "<cell><![CDATA[" . $host->get_threshold_c() . "]]></cell>";
 $xml .= "<cell><![CDATA[" . $host->get_threshold_a() . "]]></cell>";
 $sensors = "";
 if ($sensor_list = $host->get_sensors($conn)) {
     foreach ($sensor_list as $sensor) {
         $sensors .= $sensor->get_sensor_name() . '<br/>';
     }
 }
 $xml .= "<cell><![CDATA[" . utf8_encode($sensors) . "]]></cell>";
 $scantype = gettext("None");
 if ($scan_list = Host_scan::get_list($conn, "WHERE host_ip = inet_aton('{$ip}')")) {
     $scantype = "";
     foreach ($scan_list as $scan) {
         $id = $scan->get_plugin_id();
         $plugin_name = "";
         if ($plugin_list = Plugin::get_list($conn, "WHERE id = {$id}")) {
             $plugin_name .= $plugin_list[0]->get_name();
             $scantype .= ucfirst($plugin_name) . "<br>";
         } else {
             $scantype .= "{$id}<BR>";
         }
     }
 }
 $xml .= "<cell><![CDATA[" . $scantype . "]]></cell>";
 if ($os_data = Host_os::get_ip_data($conn, $host->get_ip())) {
     $os = $os_data["os"];
Exemple #4
0
    unset($_SESSION['_host']);
} else {
    if ($host_list = Host::get_list($conn, "WHERE ip = '{$ip}'")) {
        $host = $host_list[0];
    }
    if (!empty($host)) {
        $hostname = $old_hostname = $host->get_hostname();
        $fqdns = $host->get_fqdns();
        $descr = $host->get_descr();
        $asset = $host->get_asset();
        $nat = $host->get_nat();
        $tmp_sensors = $host->get_sensors($conn);
        foreach ($tmp_sensors as $sensor) {
            $sensors[] = $sensor->get_sensor_name();
        }
        $nagios = Host_scan::in_host_scan($conn, $ip, 2007) ? "1" : '';
        $rrd_profile = $host->get_rrd_profile();
        if (!$rrd_profile) {
            $rrd_profile = "None";
        }
        $threshold_a = $host->get_threshold_a();
        $threshold_c = $host->get_threshold_c();
        $os = $host->get_os($conn);
        $mac = $host->get_mac_address($conn);
        $mac_vendor = $host->get_mac_vendor($conn);
        $coordinates = $host->get_coordinates();
        $latitude = $coordinates['lat'];
        $longitude = $coordinates['lon'];
        $num_sensors = count($sensors);
    }
}
Exemple #5
0
require_once 'classes/Host_group_scan.inc';
require_once 'classes/Host_group.inc';
require_once 'classes/Host_scan.inc';
$db = new ossim_db();
$conn = $db->connect();
define("NESSUS", 3001);
$sensor_list = array();
// Quick & dirty sensor index array for "sensor#" further below
$sensor_index = array();
$tmp_index = 0;
//$tmp_sensors = Sensor::get_all($conn, "ORDER BY name ASC");
$tmp_sensors = Sensor::get_list($conn, "ORDER BY name ASC");
// For filtering user perms
$tmp_group_hosts = Host_group_scan::get_list($conn, "WHERE plugin_id = 3001 ORDER BY host_group_name ASC");
$tmp_group_nets = Net_group_scan::get_list($conn, "WHERE plugin_id = 3001 ORDER BY net_group_name ASC");
$tmp_host = Host_scan::get_list($conn, "WHERE plugin_id = 3001 ORDER BY host_ip ASC");
$tmp_nets = Net_scan::get_list($conn, "WHERE plugin_id = 3001 ORDER BY net_name ASC");
$net_group_index = array();
$host_group_index = array();
$hosts_index = array();
$nets_index = array();
$net_group_list = array();
$host_group_list = array();
$hosts_list = array();
$nets_list = array();
foreach ($tmp_sensors as $sensor) {
    if (Sensor::check_plugin_rel($conn, $sensor->get_ip(), NESSUS)) {
        $sensor_index[$sensor->get_name()] = $tmp_index;
        $tmp_index++;
        array_push($sensor_list, $sensor);
    }
Exemple #6
0
<div id="sched_form">

        <h3><center> <?php 
    echo _("Select sensors for this scan");
    ?>
 </center></h3>
<ul>
<?php 
    $tmp_sensors = Sensor::get_all($conn, "ORDER BY name ASC");
    $sensor_list = array();
    // Quick & dirty sensor index array for "sensor#" further below
    $sensor_index = array();
    $tmp_index = 0;
    $tmp_group_hosts = Host_group_scan::get_list($conn, "ORDER BY host_group_name ASC");
    $tmp_group_nets = Net_group_scan::get_list($conn, "ORDER BY net_group_name ASC");
    $tmp_host = Host_scan::get_list($conn, "ORDER BY host_ip ASC");
    $tmp_nets = Net_scan::get_list($conn, "ORDER BY net_name ASC");
    $global_i = 0;
    define("NESSUS", 3001);
    $net_group_index = array();
    $host_group_index = array();
    $hosts_index = array();
    $nets_index = array();
    $net_group_list = array();
    $host_group_list = array();
    $hosts_list = array();
    $nets_list = array();
    foreach ($tmp_sensors as $sensor) {
        if (Sensor::check_plugin_rel($conn, $sensor->get_ip(), NESSUS)) {
            $sensor_index[$sensor->get_name()] = $tmp_index;
            $tmp_index++;
Exemple #7
0
<?php 
require_once 'classes/Security.inc';
$insert = POST('insert');
$host_ip = POST('host_ip');
$plugin_id = POST('plugin_id');
ossim_valid($insert, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("insert"));
ossim_valid($host_ip, OSS_IP_ADDR, 'illegal:' . _("host IP"));
ossim_valid($plugin_id, OSS_DIGIT, 'illegal:' . _("Plugin Id"));
if (ossim_error()) {
    die(ossim_error());
}
require_once 'ossim_db.inc';
require_once 'classes/Host_scan.inc';
$db = new ossim_db();
$conn = $db->connect();
Host_scan::insert($conn, $host_ip, $plugin_id, 0);
$db->close($conn);
?>
    <p> <?php 
echo gettext("Host scan configuration succesfully inserted");
?>
 </p>
    <p><a href="hostscan.php"> <?php 
echo gettext("Back");
?>
 </a></p>

</body>
</html>

Exemple #8
0
function update_db($global_info, $scan)
{
    $db = new ossim_db();
    $conn = $db->connect();
    $array_os = array("win" => "1", "linux" => "2", "cisco" => "3", "freebsd" => "5", "netbsd" => "6", "openbsd" => "7", "hp-ux" => "8", "solaris" => "9", "macos" => "10", "plan9" => "11", "sco" => "12", "aix" => "13", "unix" => "14");
    $ips = $global_info["ips"];
    $sensors = $global_info["sboxs"];
    $nagios = $global_info['nagios'];
    // load protocol ids
    $protocol_ids = array();
    if ($protocol_list = Protocol::get_list($conn)) {
        foreach ($protocol_list as $protocol_data) {
            $protocol_ids[$protocol_data->get_name()] = $protocol_data->get_id();
        }
    }
    for ($i = 0; $i < $ips; $i++) {
        $ip = $global_info["ip_{$i}"];
        if (!empty($ip)) {
            $hosts[] = $ip;
            //gethostbyaddr($ip);
            $os = $scan[$ip]["os"];
            $os_id = 0;
            foreach ($array_os as $k => $v) {
                if (preg_match("/{$k}/i", $os)) {
                    $os_id = $v;
                    break;
                }
            }
            if (Host::in_host($conn, $ip)) {
                echo "* " . gettext("Updating") . " {$ip}..<br/>";
                Host::update($conn, $ip, gethostbyaddr($ip), $global_info["asset"], $global_info["threshold_c"], $global_info["threshold_a"], $global_info["rrd_profile"], 0, 0, $global_info["nat"], $sensors, $global_info["descr"], $scan["{$ip}"]["os"], $scan["{$ip}"]["mac"], $scan["{$ip}"]["mac_vendor"]);
                Host_scan::delete($conn, $ip, 3001);
                //if (isset($global_info["nessus"])) { Host_scan::insert($conn, $ip, 3001, 0); }
            } else {
                echo "<span style='color='blue'>\n";
                echo "* " . gettext("Inserting") . " {$ip}..<br/>\n";
                echo "</span>\n";
                Host::insert($conn, $ip, gethostbyaddr($ip), $global_info["asset"], $global_info["threshold_c"], $global_info["threshold_a"], $global_info["rrd_profile"], 0, 0, $global_info["nat"], $sensors, $global_info["descr"], $scan[$ip]["os"], $scan[$ip]["mac"], $scan[$ip]["mac_vendor"]);
                // if (isset($global_info["nessus"])) { Host_scan::insert($conn, $ip, 3001, 0); }
            }
            if ($os_id != 0) {
                Host_plugin_sid::delete($conn, $ip, 5001);
                Host_plugin_sid::insert($conn, $ip, 5001, $os_id);
            }
            if (!empty($nagios)) {
                if (!Host_scan::in_host_scan($conn, $ip, 2007)) {
                    Host_scan::insert($conn, $ip, 2007, "", $ip, $sensors, "");
                }
            } else {
                if (Host_scan::in_host_scan($conn, $ip, 2007)) {
                    Host_scan::delete($conn, $ip, 2007);
                }
            }
            /* Services */
            Host_plugin_sid::delete($conn, $ip, 5002);
            foreach ($scan[$ip]["services"] as $port_proto => $service) {
                $service["proto"] = $protocol_ids[strtolower(trim($service["proto"]))];
                Host_services::insert($conn, $ip, $service["port"], strftime("%Y-%m-%d %H:%M:%S"), $_SERVER["SERVER_ADDR"], $service["proto"], $service["service"], $service["service"], $service["version"], 1);
                Host_plugin_sid::insert($conn, $ip, 5002, $service["port"]);
            }
            flush();
        }
    }
    // Insert group name
    $groupname = $global_info["groupname"];
    if (!empty($groupname) && !empty($hosts)) {
        $exists_hosts = count(Host_group::get_list($conn, " AND g.name='{$groupname}'")) > 0;
        if ($exists_hosts) {
            echo "<br/>" . _("The group name already exists") . "<br/>";
        } else {
            Host_group::insert($conn, $groupname, $global_info["threshold_c"], $global_info["threshold_a"], $global_info["rrd_profile"], $sensors, $hosts, $global_info["descr"]);
        }
        //if (isset($global_info["nessus"])) { Host_group_scan::insert($conn, $groupname, 3001, 0); }
        if (!empty($nagios)) {
            Host_group_scan::insert($conn, $groupname, 2007, 0);
        }
    }
    $db->close($conn);
}
Exemple #9
0
    if ($hostname != $old_hostname) {
        $query = "UPDATE risk_indicators SET type_name=? WHERE type='host' AND type_name=?";
        $params = array($hostname, $hostname_old);
        $conn->Execute($query, $params);
    }
    Host_scan::delete($conn, $ip, 3001);
    Host_scan::delete($conn, $ip, 2007);
    //if (!empty($nessus)) Host_scan::insert($conn, $ip, 3001);
    Host_scan::delete($conn, $ip, 3001);
    if (!empty($nagios)) {
        if (!Host_scan::in_host_scan($conn, $ip, 2007)) {
            Host_scan::insert($conn, $ip, 2007, "", $hostname, $sensors, $sensors);
        }
    } else {
        if (Host_scan::in_host_scan($conn, $ip, 2007)) {
            Host_scan::delete($conn, $ip, 2007);
        }
    }
    $db->close($conn);
    Util::clean_json_cache_files("(policy|vulnmeter|hostgroup)");
}
if (isset($_SESSION['_host'])) {
    unset($_SESSION['_host']);
}
if (($_SESSION["menu_sopc"] == "Hosts" || $_SESSION["menu_sopc"] == "Assets") && POST('withoutmenu') != "1") {
    ?>
		<p><?php 
    echo _("Host succesfully updated");
    ?>
</p>    
		<script type='text/javascript'>document.location.href="host.php"</script>
Exemple #10
0
?>
">
	<?php 
echo gettext("Plugin sid");
?>
 </a></th>
      <th> <?php 
echo gettext("Action");
?>
 </th>
    </tr>
    
<?php 
require_once 'classes/Host_scan.inc';
require_once 'classes/Plugin.inc';
if ($host_list = Host_scan::get_list($conn, "ORDER BY {$order}")) {
    foreach ($host_list as $host) {
        $ip = $host->get_host_ip();
        $id = $host->get_plugin_id();
        if ($plugin_list = Plugin::get_list($conn, "WHERE id = {$id}")) {
            $plugin_name = $plugin_list[0]->get_name();
        }
        ?>
    <tr>
      <td><?php 
        echo $ip;
        ?>
</td>
      <td><?php 
        echo $plugin_name . " (" . $id . ")";
        ?>