Exemplo n.º 1
0
             $sensor_string .= "," . $sensor_index[$name];
         }
     }
     $nets_string = "";
     $nets = Net_group::get_networks($conn, $group_scan->get_net_group_name(), NESSUS);
     foreach ($nets as $net) {
         $name = $net->get_net_name();
         if ($nets_string == "") {
             $nets_string .= $nets_index[$name];
         } else {
             $nets_string .= "," . $nets_index[$name];
         }
     }
     print "<li><a href=\"#\" onClick=\"return selectSomeNets('" . $group_scan->get_net_group_name() . "','" . $sensor_string . "','" . $nets_string . "');\">" . $group_scan->get_net_group_name() . "</a>";
 }
 $group_scan_list = Host_group_scan::get_list($conn, "WHERE plugin_id = " . NESSUS);
 foreach ($group_scan_list as $group_scan) {
     $host_group_sensors = Host_group::get_sensors($conn, $group_scan->get_host_group_name());
     echo "\n<script>\n";
     echo "var " . $group_scan->get_host_group_name() . " = true;\n";
     echo "</script>\n";
     $sensor_string = "";
     foreach ($host_group_sensors as $hg_sensor) {
         $name = $hg_sensor->get_sensor_name();
         if ($sensor_string == "") {
             $sensor_string .= $sensor_index[$name];
         } else {
             $sensor_string .= "," . $sensor_index[$name];
         }
     }
     $hosts_string = "";
Exemplo n.º 2
0
function show_form()
{
    global $sensor_list;
    global $net_group_list;
    global $host_group_list;
    global $hosts_list;
    global $nets_list;
    global $conn;
    global $sensor_index;
    global $net_group_index;
    global $host_group_index;
    global $hosts_index;
    global $nets_index;
    $global_i = 0;
    $num = count($sensor_list);
    if ($num > 20) {
        $cols = 5;
    } else {
        $cols = 3;
    }
    $rows = intval($num / $cols) + 1;
    $num_ng = count($net_group_list);
    if ($num_ng > 20) {
        $cols = 5;
    } else {
        $cols = 3;
    }
    $rows_ng = intval($num_ng / $cols) + 1;
    $num_hg = count($host_group_list);
    if ($num_hg > 20) {
        $cols = 5;
    } else {
        $cols = 3;
    }
    $rows_hg = intval($num_hg / $cols) + 1;
    $num_hs = count($hosts_list);
    if ($num_hs > 20) {
        $cols = 5;
    } else {
        $cols = 3;
    }
    $rows_hs = intval($num_hs / $cols) + 1;
    $num_ns = count($nets_list);
    if ($num_ns > 20) {
        $cols = 5;
    } else {
        $cols = 3;
    }
    $rows_ns = intval($num_ns / $cols) + 1;
    if ($num_ns + $num_hs + $num_hg + $num_ng > 20) {
        $cols_full = 5;
    } else {
        $cols_full = 3;
    }
    ?>
	<h3><center> <?php 
    echo _("Select sensors for this scan");
    ?>
 </center></h3>
<ul>
<?php 
    $group_scan_list = Net_group_scan::get_list($conn, "WHERE plugin_id = " . NESSUS);
    foreach ($group_scan_list as $group_scan) {
        $net_group_sensors = Net_group::get_sensors($conn, $group_scan->get_net_group_name());
        echo "\n<script>\n";
        echo "var " . $group_scan->get_net_group_name() . " = true;\n";
        echo "</script>\n";
        $sensor_string = "";
        foreach ($net_group_sensors as $ng_sensor => $name) {
            if ($sensor_string == "") {
                $sensor_string .= $sensor_index[$name];
            } else {
                $sensor_string .= "," . $sensor_index[$name];
            }
        }
        $nets_string = "";
        $nets = Net_group::get_networks($conn, $group_scan->get_net_group_name(), NESSUS);
        foreach ($nets as $net) {
            $name = $net->get_net_name();
            if ($nets_string == "") {
                $nets_string .= $nets_index[$name];
            } else {
                $nets_string .= "," . $nets_index[$name];
            }
        }
        print "<li><a href=\"#\" onClick=\"return selectSomeNets('" . $group_scan->get_net_group_name() . "','" . $sensor_string . "','" . $nets_string . "');\">" . $group_scan->get_net_group_name() . "</a>";
    }
    $group_scan_list = Host_group_scan::get_list($conn, "WHERE plugin_id = " . NESSUS);
    foreach ($group_scan_list as $group_scan) {
        $host_group_sensors = Host_group::get_sensors($conn, $group_scan->get_host_group_name());
        echo "\n<script>\n";
        echo "var " . $group_scan->get_host_group_name() . " = true;\n";
        echo "</script>\n";
        $sensor_string = "";
        foreach ($host_group_sensors as $hg_sensor) {
            $name = $hg_sensor->get_sensor_name();
            if ($sensor_string == "") {
                $sensor_string .= $sensor_index[$name];
            } else {
                $sensor_string .= "," . $sensor_index[$name];
            }
        }
        $hosts_string = "";
        $hosts = Host_group::get_hosts($conn, $group_scan->get_host_group_name(), NESSUS);
        foreach ($hosts as $host) {
            $name = $host->get_host_name($conn);
            if ($hosts_string == "") {
                $hosts_string .= $hosts_index[$name];
            } else {
                $hosts_string .= "," . $hosts_index[$name];
            }
        }
        print "<li><a href=\"#\" onClick=\"return selectSomeHosts('" . $group_scan->get_host_group_name() . "','" . $sensor_string . "','" . $hosts_string . "');\">" . $group_scan->get_host_group_name() . "</a>";
    }
    ?>
</ul>
	<form action="<?php 
    echo $_SERVER["SCRIPT_NAME"];
    ?>
" method="POST">
<p>
<?php 
    echo _("Please adjust incident creation threshold, incidents will only be created for vulnerabilities whose risk level exceeds the threshold.");
    ?>
<br/>
<?php 
    echo _("It is recommended to set a high level at the beginning in order to concentrate on more critical vulnerabilities first, lowering it after having solved/tagged them as false positivies.");
    ?>
<br/>
<?php 
    echo _("Threshold configuration can be found at Configuration->Main, \"vulnerability_incident_threshold\".");
    ?>
&nbsp;
<?php 
    echo _("Current risk threshold is:");
    ?>
<b>
<?php 
    require_once 'ossim_conf.inc';
    $conf = $GLOBALS["CONF"];
    print $conf->get_conf("vulnerability_incident_threshold");
    ?>
</b>
</p>
	<h4><center> (<?php 
    echo _("Empty means all");
    ?>
) </center></h4>
	<center><a href="#" onClick="return selectAll();"><?php 
    echo _("Select / Unselect all");
    ?>
</a></center>
<br/>

<table width="100%" border="0" align="center"><tr><td>
	<input type="radio" name="groupType" value="sensor" checked onClick="selectGroup('sensor');"> Sensor &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="radio" name="groupType" value="host" onClick="selectGroup('host');"> NetGroup / Nets / HostGroup / Hosts
</td></tr>
<tr><td>
        <div id="rowSensor">
        <table width="100%" align="left" border="0"><tr>
	<?php 
    for ($i = 1; $i <= $rows; $i++) {
        ?>
	<?php 
        for ($a = 0; $a < $cols && $global_i < $num; $a++) {
            $sensor = $sensor_list[$global_i];
            echo "<td width=\"" . intval(100 / $cols) . "%\">";
            $all['sensors'][] = "sensor" . $global_i;
            ?>
		<div align="left">
	        <input align="left" type="checkbox" id="<?php 
            echo "sensor" . $global_i;
            ?>
" name="<?php 
            echo "sensor" . $global_i;
            ?>
"
		               value="<?php 
            echo $sensor->get_ip();
            ?>
" /><?php 
            echo $sensor->get_name();
            ?>
</div></td>
	        <?php 
            $global_i++;
        }
        echo "</tr>\n";
        ?>
	    <?php 
    }
    echo "</table>\n";
    ?>
        </div>

	<div id="rowHost" style="display: none">
        <table width="100%" align="left" border="0">
        <tr>
	<th colspan="3">NetGroups</th></tr><tr>
	<?php 
    $global_ng = 0;
    for ($i = 1; $i <= $rows_ng; $i++) {
        ?>
        <?php 
        for ($a = 0; $a < $cols_full && $global_ng < $num_ng; $a++) {
            $netgroup = $net_group_list[$global_ng];
            echo "<td width=\"" . intval(100 / $cols_full) . "%\">";
            $all['netgroups'][] = "netgroup" . $global_ng;
            ?>
            <div align="left">
            <input align="left" type="checkbox" id="<?php 
            echo "netgroup" . $global_ng;
            ?>
" name="netgroupList[]"
                   value="<?php 
            echo $netgroup->get_name();
            ?>
" /><?php 
            echo $netgroup->get_name($conn);
            ?>
</div></td>
		 <?php 
            $global_ng++;
        }
        echo "</tr>\n";
        ?>
            <tr>
    <?php 
    }
    ?>

	<th colspan="3">HostGroups</th></tr><tr>

        <?php 
    $global_hg = 0;
    for ($i = 1; $i <= $rows_hg; $i++) {
        for ($a = 0; $a < $cols_full && $global_hg < $num_hg; $a++) {
            $hostgroup = $host_group_list[$global_hg];
            echo "<td width=\"" . intval(100 / $cols_full) . "%\">";
            $all['hostgroups'][] = "hostgroup" . $global_hg;
            ?>
                <div align="left">
                <input align="left" type="checkbox" id="<?php 
            echo "hostgroup" . $global_hg;
            ?>
" name="hostgroupList[]"
                               value="<?php 
            echo $hostgroup->get_name();
            ?>
" /><?php 
            echo $hostgroup->get_name($conn);
            ?>
</div></td>
                 <?php 
            $global_hg++;
        }
        echo "</tr>\n";
        ?>
           <tr>
	   <?php 
    }
    ?>

	<th colspan="3">Nets</th></tr><tr>
        
        <?php 
    $global_ns = 0;
    for ($i = 1; $i <= $rows_ns; $i++) {
        ?>
        <?php 
        for ($a = 0; $a < $cols_full && $global_ns < $num_ns; $a++) {
            $nets = $nets_list[$global_ns];
            echo "<td width=\"" . intval(100 / $cols_full) . "%\">";
            $all['nets'][] = "net" . $global_ns;
            ?>
                <div align="left">
                <input align="left" type="checkbox" id="<?php 
            echo "net" . $global_ns;
            ?>
" name="netList[]"
                               value="<?php 
            echo $nets->get_name();
            ?>
" /><?php 
            echo $nets->get_name($conn);
            ?>
</div></td>
                 <?php 
            $global_ns++;
        }
        echo "</tr>\n";
        ?>
           <tr>
	     <?php 
    }
    ?>

	<th colspan="3">Hosts</th></tr><tr>

        <?php 
    $global_hs = 0;
    for ($i = 1; $i <= $rows_hs; $i++) {
        ?>
        <?php 
        for ($a = 0; $a < $cols_full && $global_hs < $num_hs; $a++) {
            $hosts = $hosts_list[$global_hs];
            echo "<td width=\"" . intval(100 / $cols_full) . "%\">";
            $all['hosts'][] = "host" . $global_hs;
            ?>
                <div align="left">
                <input align="left" type="checkbox" id="<?php 
            echo "host" . $global_hs;
            ?>
" name="hostList[]"
                               value="<?php 
            echo $hosts->get_host_ip();
            ?>
" /><?php 
            echo $hosts->get_name($conn);
            ?>
</div></td>
                 <?php 
            $global_hs++;
        }
        echo "</tr>\n";
        ?>
            <?php 
    }
    echo "</table>\n";
    ?>
        </div>	

</td></tr></table>
<br>
<center>
<input type="hidden" name="nsensors" value="<?php 
    echo $global_i;
    ?>
" />
<input type="Submit" class="button" value="<?php 
    echo _("Submit");
    ?>
">
</center>
</form>
<center><a href="index.php"> <?php 
    echo gettext("Back");
    ?>
 </a></center>
<script>
var check_sensors = true;
var check_nethost = true;
var scanType = 'sensor';

function selectAll()
{

if (scanType  == 'sensor') {
    <?php 
    if (count($all['sensors']) != 0) {
        foreach ($all['sensors'] as $id) {
            ?>
        document.getElementById('<?php 
            echo $id;
            ?>
').checked = check_sensors;
    <?php 
        }
    }
    ?>
        check_sensors = check_sensors == false ? true : false;
    }
else {
    <?php 
    if (count($all['netgroups']) != 0) {
        foreach ($all['netgroups'] as $id) {
            ?>
        document.getElementById('<?php 
            echo $id;
            ?>
').checked = check_nethost;
    <?php 
        }
    }
    ?>
    <?php 
    if (count($all['hostgroups']) != 0) {
        foreach ($all['hostgroups'] as $id) {
            ?>
        document.getElementById('<?php 
            echo $id;
            ?>
').checked = check_nethost;
    <?php 
        }
    }
    ?>
    <?php 
    if (count($all['nets']) != 0) {
        foreach ($all['nets'] as $id) {
            ?>
        document.getElementById('<?php 
            echo $id;
            ?>
').checked = check_nethost;
    <?php 
        }
    }
    ?>
    <?php 
    if (count($all['hosts']) != 0) {
        foreach ($all['hosts'] as $id) {
            ?>
        document.getElementById('<?php 
            echo $id;
            ?>
').checked = check_nethost;
    <?php 
        }
    }
    ?>
        check_nethost = check_nethost == false ? true : false;
     }
return false;
}

function selectSomeNets(name, identifiersSensors, identifiersNets)
{

if (identifiersSensors.length != 0) {
	arrayOfStringsSensor = identifiersSensors.split(",");
	for (var i=0; i < arrayOfStringsSensor.length; i++) {
	document.getElementById("sensor" + arrayOfStringsSensor[i]).checked = window[name];
	}
}

if (identifiersNets.length != 0) {
	arrayOfStringsNets = identifiersNets.split(",");
	for (var i=0; i < arrayOfStringsNets.length; i++) {
	document.getElementById("net" + arrayOfStringsNets[i]).checked = window[name];
	}
}

window[name] = window[name] == false ? true : false;
return false;

} 

function selectSomeHosts(name, identifiersSensors, identifiersHosts)
{

if (identifiersSensors.length != 0) {
	arrayOfStringsSensor = identifiersSensors.split(",");
	for (var i=0; i < arrayOfStringsSensor.length; i++) {
	document.getElementById("sensor" + arrayOfStringsSensor[i]).checked = window[name];
	}	
}

if (identifiersHosts.length != 0) {
	arrayOfStringsHosts = identifiersHosts.split(",");
	for (var i=0; i < arrayOfStringsHosts.length; i++) {
	document.getElementById("host" + arrayOfStringsHosts[i]).checked = window[name];
	}
}

window[name] = window[name] == false ? true : false;
return false;

}

function selectGroup(category)

{
    if (category == 'sensor') {
	document.getElementById("rowHost").style.display = 'none';
        document.getElementById("rowSensor").style.display = 'block';
    } else {
        document.getElementById("rowHost").style.display = 'block';
        document.getElementById("rowSensor").style.display = 'none';
    }

scanType = category;
}
 
</script>
</body>
</html>
<?php 
}
Exemplo n.º 3
0
    $xml .= "<cell><![CDATA[" . $host_group->get_threshold_c() . "]]></cell>";
    $xml .= "<cell><![CDATA[" . $host_group->get_threshold_a() . "]]></cell>";
    /* Nessus
       if ($scan_list = Host_group_scan::get_list($conn, "WHERE host_group_name = '$name' AND plugin_id = 3001")) {
           $scan_types = "<img src='../pixmaps/tables/tick.png'>";
       } else {
           $scan_types = "<img src='../pixmaps/tables/cross.png'>";
       }
       $xml.= "<cell><![CDATA[" . $scan_types . "]]></cell>"; */
    // Nagios
    $rep = "";
    if ($linkedocs = Repository::have_linked_documents($conn, $host_group->get_name(), 'host_group')) {
        $rep .= "<a href=\"javascript:;\" onclick=\"GB_edit('../repository/repository_list.php?keyname=" . urlencode($name) . "&type=host_group')\" class=\"blue\">[" . $linkedocs . "]</a>&nbsp;";
    }
    $rep .= "<a href=\"../repository/index.php?hmenu=Repository&smenu=Repository\" target='main'><img src=\"../pixmaps/tables/table_edit.png\" title=\"Edit KDB\" alt=\"Edit KDB\" border=0 align=\"absmiddle\"></a>";
    $xml .= "<cell><![CDATA[" . $rep . "]]></cell>";
    if ($scan_list = Host_group_scan::get_list($conn, "WHERE host_group_name = '{$name}' AND plugin_id = 2007")) {
        $scan_types = "<img src='../pixmaps/tables/tick.png'>";
    } else {
        $scan_types = "<img src='../pixmaps/tables/cross.png'>";
    }
    $xml .= "<cell><![CDATA[" . $scan_types . "]]></cell>";
    $xml .= "</row>\n";
}
$xml .= "</rows>\n";
echo $xml;
$db->close($conn);
?>