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
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 #3
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 #4
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>