本文整理汇总了PHP中Asset_host::get_id_by_ips方法的典型用法代码示例。如果您正苦于以下问题:PHP Asset_host::get_id_by_ips方法的具体用法?PHP Asset_host::get_id_by_ips怎么用?PHP Asset_host::get_id_by_ips使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset_host
的用法示例。
在下文中一共展示了Asset_host::get_id_by_ips方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$arrResults = array();
while (list($hostIP, $hostctx, $service, $service_num, $service_proto, $app, $risk, $scriptid, $pname, $msg) = $result->fields) {
$arrResults[$hostIP . "#" . $hostctx][] = array('service' => $service, 'port' => $service_num, 'protocol' => $service_proto, 'application' => $app, 'risk' => $risk, 'scriptid' => $scriptid, 'exception' => $eid, 'msg' => preg_replace('/(<br\\s*?\\/??>)+/i', "\n", $msg), 'pname' => $pname);
$result->MoveNext();
}
//Vulnerability table configs
$vcols = array(_("Risk"), _("Details"));
//widths for columns
$vwidth_array = array(20, 170);
// 196 total
$count = 0;
$oldip = "";
// iterate through the IP is the results
foreach ($arrResults as $hostIP_ctx => $scanData) {
list($hostIP, $hostctx) = explode("#", $hostIP_ctx);
$host_id = key(Asset_host::get_id_by_ips($dbconn, $hostIP, $hostctx));
if (valid_hex32($host_id)) {
$hostname = Asset_host::get_name_by_id($dbconn, $host_id);
} else {
$hostname = _('unknown');
}
$hostIP = htmlspecialchars_decode($hostIP);
$hostname = htmlspecialchars_decode($hostname);
$pdf->SetLink(${"IP_" . $hostIP_ctx}, $pdf->GetY());
//print out the host cell
$pdf->SetFillColor(229, 229, 229);
$pdf->SetFont('', 'B', 10);
$pdf->Cell(95, 6, $hostIP, 1, 0, 'C', 1);
$pdf->Cell(95, 6, $hostname, 1, 0, 'C', 1);
//$pdf->Cell(105, 6, "",1,0,'C');
$pdf->SetFont('', '');
示例2: while
if (!$rs) {
?>
<script type="text/javascript">
parent.show_error("<?php
echo $conn_snort->ErrorMsg();
?>
");
</script>
<?php
exit;
}
while (!$rs->EOF) {
$ip = $rs->fields['ip'];
$ctx = $rs->fields['ctx'];
$ids = Asset_host::get_id_by_ips($conn_aux, $ip, $ctx);
if (empty($hosts_in_db[$ip][$ctx]) && empty($ids)) {
if ($mode == 'insert') {
try {
$id = Util::uuid();
$hostname = Asset_host::get_autodetected_name($ip);
$ips = array();
$ips[$ip] = array('ip' => $ip, 'mac' => NULL);
$sensors = array($rs->fields['sensor_id']);
$conn_aux = $db->connect();
$host = new Asset_host($conn_aux, $id);
Util::disable_perm_triggers($conn_aux, TRUE);
$host->set_name($hostname);
$host->set_ctx($ctx);
$host->set_ips($ips);
$host->set_sensors($sensors);
示例3: list_results
//.........这里部分代码省略.........
while (!$resultt->EOF) {
$riskcount = $resultt->fields['total'];
$risk = $resultt->fields['risk'];
if ($risk == 7) {
$data['vInfo'] += $riskcount;
} else {
if ($risk == 6) {
$data['vLow'] += $riskcount;
} else {
if ($risk == 3) {
$data['vMed'] += $riskcount;
} else {
if ($risk == 2) {
$data['vHigh'] += $riskcount;
} else {
if ($risk == 1) {
$data['vSerious'] += $riskcount;
}
}
}
}
}
$resultt->MoveNext();
}
if ($data['vInfo'] == 0 && $data['vLow'] == 0 && $data['vMed'] == 0 && $data['vHigh'] == 0 && $data['vSerious'] == 0) {
$tdata[] = array("report_id" => "All", "host_name" => "", "scantime" => "", "username" => "", "scantype" => "", "report_key" => "", "report_type" => "", "sid" => "", "profile" => "", "hlink" => "", "plink" => "", "xlink" => "", "vSerious" => $data['vSerious'], "vHigh" => $data['vHigh'], "vMed" => $data['vMed'], "vLow" => $data['vLow'], "vInfo" => $data['vInfo']);
} else {
$tdata[] = array("report_id" => "All", "host_name" => "", "scantime" => "", "username" => "", "scantype" => "", "report_key" => "", "report_type" => "", "sid" => "", "profile" => "", "hlink" => "lr_reshtml.php?ipl=all&disp=html&output=full&scantype=M", "plink" => "lr_respdf.php?ipl=all&scantype=M", "xlink" => "lr_rescsv.php?ipl=all&scantype=M", "dlink" => "", "vSerious" => $data['vSerious'], "vHigh" => $data['vHigh'], "vMed" => $data['vMed'], "vLow" => $data['vLow'], "vInfo" => $data['vInfo']);
}
foreach ($result as $data) {
if (!Session::hostAllowed_by_ip_ctx($dbconn, $data["hostIP"], $data["ctx"])) {
continue;
}
$host_id = key(Asset_host::get_id_by_ips($dbconn, $data["hostIP"], $data["ctx"]));
if (valid_hex32($host_id)) {
$data['host_name'] = Asset_host::get_name_by_id($dbconn, $host_id);
}
$data['vSerious'] = 0;
$data['vHigh'] = 0;
$data['vMed'] = 0;
$data['vLow'] = 0;
$data['vInfo'] = 0;
// query for reports for each IP
$query_risk = "SELECT distinct risk, port, protocol, app, scriptid, msg, hostIP FROM vuln_nessus_latest_results WHERE hostIP = '" . $data['hostIP'];
$query_risk .= "' AND username = '" . $data['username'] . "' AND sid =" . $data['sid'] . " AND ctx = UNHEX('" . $data['ctx'] . "') AND falsepositive='N'";
$result_risk = $dbconn->Execute($query_risk);
while (!$result_risk->EOF) {
if ($result_risk->fields["risk"] == 7) {
$data['vInfo']++;
} else {
if ($result_risk->fields["risk"] == 6) {
$data['vLow']++;
} else {
if ($result_risk->fields["risk"] == 3) {
$data['vMed']++;
} else {
if ($result_risk->fields["risk"] == 2) {
$data['vHigh']++;
} else {
if ($result_risk->fields["risk"] == 1) {
$data['vSerious']++;
}
}
}
}
}
示例4: _
<td width="128" style='background-color:#FFFFE3;border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px;border: 1px solid #F0E68C;'>
<?php
echo _("Info");
?>
</td></tr>
<?php
$tp = intval(count($vulns) / $maxpag);
$tp += count($vulns) % $maxpag == 0 ? 0 : 1;
$to = $pag * $maxpag;
$from = $to - $maxpag;
$ips_to_show = array();
$i = 1;
foreach ($vulns as $ctx_ip => $value) {
if ($i > $from && $i <= $to) {
list($ctx, $ip) = explode("#", $ctx_ip);
$host_id = key(Asset_host::get_id_by_ips($dbconn, $ip, $ctx));
if (valid_hex32($host_id)) {
$name = Asset_host::get_name_by_id($dbconn, $host_id);
} else {
$name = $ip;
}
$ips_to_show[] = $ctx_ip . "|" . $name;
?>
<tr>
<td style="text-align:center"><?php
echo $ip;
?>
</td>
<td style="text-align:center"><?php
echo $name;
?>
示例5: origdetails
function origdetails()
{
global $uroles, $user, $sid, $query_risk, $border, $report_id, $scantime, $scantype, $fp, $nfp, $filterip, $enableFP, $enableNotes, $output, $sortby, $dbconn, $arruser;
global $treport, $ipl, $query_byuser, $ips_inrange, $ctx, $key;
$colors = array("Serious" => "#FFCDFF", "High" => "#FFDBDB", "Medium" => "#FFF283", "Low" => "#FFFFC0", "Info" => "#FFFFE3");
$images = array("Serious" => "./images/risk1.gif", "High" => "./images/risk2.gif", "Medium" => "./images/risk3.gif", "Low" => "./images/risk6.gif", "Info" => "./images/risk7.gif");
$levels = array("Serious" => "1", "High" => "2", "Medium" => "3", "Low" => "6", "Info" => "7");
$query_host = '';
if ($filterip) {
$query_host = " AND hostip='{$filterip}'";
}
echo "<center>";
echo "<form>";
echo "<table width=\"900\" class=\"noborder\" style=\"background:transparent;\">";
echo "<tr><td style=\"text-align:left;\" class=\"nobborder\">";
echo "<input id=\"checkboxFP\" type=\"checkbox\" onclick=\"showFalsePositives()\"> <span style=\"color:black\">" . _("View false positives") . "</span>";
echo "</td><td class=\"nobborder\" style=\"text-align:center;\">";
// print the icon legend
if ($enableFP) {
echo "<img alt='True' src='images/true.gif' border=0 align='absmiddle'> - " . _("True result") . " ";
echo "<img alt='False' src='images/false.png' border=0 align='absmiddle'> - " . _("False positive result") . " ";
}
$feed = exists_feed_tables($dbconn);
echo "<img alt='Info' src='images/info.png' border=0 align='absmiddle'> - " . _("Additional information is available");
echo "</td></tr></table>";
echo "</form>";
echo "<br>";
$perms_where = Session::get_ctx_where() != "" ? " AND res.ctx in (" . Session::get_ctx_where() . ")" : "";
if ($ipl == "all") {
$query = "select distinct res.hostIP, HEX(res.ctx) as ctx\n from vuln_nessus_latest_results res\n where falsepositive='N' \n {$perms_where}\n {$query_byuser}";
} else {
if (!empty($ipl) && !empty($ctx)) {
$query = "select distinct res.hostIP, HEX(res.ctx) as ctx\n from vuln_nessus_latest_results res\n where falsepositive='N' \n and res.hostIP='{$ipl}'\n and res.ctx=UNHEX('{$ctx}')\n {$perms_where}\n {$query_byuser}";
} else {
if (!empty($scantime) && !empty($key)) {
$query = "select distinct res.hostIP, HEX(res.ctx) as ctx\n from vuln_nessus_latest_results res, vuln_nessus_latest_reports rep\n where res.falsepositive='N'\n and res.scantime='{$scantime}' \n and res.hostIP=rep.hostIP\n and res.ctx=rep.ctx\n and res.username=rep.username\n and res.sid=rep.sid\n {$perms_where}\n and rep.report_key='{$key}' {$query_byuser}";
}
}
}
$resultp = $dbconn->execute($query);
$host_range = array_keys($ips_inrange);
while (list($hostip, $hostctx) = $resultp->fields) {
$host_id = key(Asset_host::get_id_by_ips($dbconn, $hostip, $hostctx));
if (valid_hex32($host_id)) {
$hostname = Asset_host::get_name_by_id($dbconn, $host_id);
} else {
$hostname = _('unknown');
}
if (in_array($hostip . ";" . $hostctx, $host_range)) {
echo "<div class='hostip'>";
echo "<br><font color='red'><b><a name='{$hostip};{$hostctx}' href='javascript:;' ctx='{$hostctx}' id='{$hostip};{$hostname}' class='HostReportMenu'>{$hostip} - {$hostname}</a></b></font>";
echo "<br><br><table summary=\"{$hostip} - " . _("Reported Ports") . "\">";
echo "<tr><th colspan=2>" . _("Reported Ports") . "</th></tr>";
if (!empty($scantime) && !empty($key)) {
$query = "select distinct res.port, res.protocol\n from vuln_nessus_latest_results res, vuln_nessus_latest_reports rep\n where res.falsepositive='N'\n and res.scantime='{$scantime}' \n and res.hostIP=rep.hostIP\n and res.ctx=rep.ctx\n and res.username=rep.username\n and res.sid=rep.sid\n and res.hostIP='{$hostip}'\n and res.ctx='{$hostctx}'\n and rep.report_key='{$key}' {$query_byuser}) as t group by risk";
} else {
$query = "select distinct res.port, res.protocol\n from vuln_nessus_latest_results res \n where hostip='{$hostip}' and ctx=UNHEX('{$hostctx}') {$query_byuser} AND port > '0' ORDER BY port ASC";
}
$result1 = $dbconn->execute($query);
$k = 1;
$pos = '';
if (!$result1->fields) {
print "<tr><td>" . _("No reported ports found") . "</td></tr>";
} else {
while (list($port, $proto) = $result1->fields) {
if ($k % 2) {
echo "<tr><td>{$port}/{$proto}</td>";
$pos = "open";
} else {
echo "<td>{$port}/{$proto}</td></tr>";
$pos = "closed";
}
$k++;
$result1->MoveNext();
}
// end while
// close up the table
if ($pos != "closed") {
echo "<td> </td></tr>";
}
}
echo "</table><br/>";
echo "<table width='900' summary='{$hostip} - risks'><tr>";
echo "<th>" . _("Vuln Name") . "</th>";
echo "<th>" . _("VulnID") . "</th>";
echo "<th>" . _("Service") . "</th>";
echo "<th>" . _("Severity") . "</th>";
echo "</tr>";
if (!empty($scantime) && !empty($key)) {
if ($feed) {
$query = "select res.result_id, res.service, res.risk, res.falsepositive, res.scriptid, v.name, res.msg, rep.sid\n from vuln_nessus_latest_results AS res LEFT JOIN vuln_nessus_plugins AS v ON v.id=res.scriptid, vuln_nessus_latest_reports rep\n where res.msg<>''\n and res.scantime='{$scantime}' \n and res.hostIP=rep.hostIP\n and res.ctx=rep.ctx\n and res.hostIP='{$hostip}'\n and res.ctx=UNHEX('{$hostctx}')\n and res.username=rep.username\n and res.sid=rep.sid\n and rep.report_key='{$key}' and rep.sid>=0 {$query_byuser}\n UNION DISTINCT\n select res.result_id, res.service, res.risk, res.falsepositive, res.scriptid, v.name, res.msg, rep.sid\n from vuln_nessus_latest_results AS res LEFT JOIN vuln_nessus_plugins_feed AS v ON v.id=res.scriptid, vuln_nessus_latest_reports rep\n where res.msg<>''\n and res.scantime='{$scantime}' \n and res.hostIP=rep.hostIP\n and res.ctx=rep.ctx\n and res.hostIP='{$hostip}'\n and res.ctx=UNHEX('{$hostctx}')\n and res.username=rep.username\n and res.sid=rep.sid\n and rep.report_key='{$key}' and rep.sid<0 {$query_byuser}\n ";
} else {
$query = "select res.result_id, res.service, res.risk, res.falsepositive, res.scriptid, v.name, res.msg, rep.sid\n from vuln_nessus_latest_results AS res LEFT JOIN vuln_nessus_plugins AS v ON v.id=res.scriptid, vuln_nessus_latest_reports rep\n where res.msg<>''\n and res.scantime='{$scantime}' \n and res.hostIP=rep.hostIP\n and res.ctx=rep.ctx\n and res.hostIP='{$hostip}'\n and res.ctx=UNHEX('{$hostctx}')\n and res.username=rep.username\n and res.sid=rep.sid\n and rep.report_key='{$key}' {$query_byuser}";
}
} else {
if ($feed) {
$query = "select res.result_id, res.service, res.risk, res.falsepositive, res.scriptid, v.name, res.msg, rep.sid\n FROM vuln_nessus_latest_results res LEFT JOIN vuln_nessus_plugins AS v ON v.id=res.scriptid, vuln_nessus_latest_reports rep\n WHERE\n res.hostIP=rep.hostIP\n and res.ctx=rep.ctx\n and res.username=rep.username\n and res.sid=rep.sid\n and res.hostIP='{$hostip}'\n and res.ctx=UNHEX('{$hostctx}')\n {$query_byuser} and msg<>'' and rep.sid>=0\n UNION DISTINCT\n select res.result_id, res.service, res.risk, res.falsepositive, res.scriptid, v.name, res.msg, rep.sid\n FROM vuln_nessus_latest_results res LEFT JOIN vuln_nessus_plugins_feed AS v ON v.id=res.scriptid, vuln_nessus_latest_reports rep\n WHERE\n res.hostIP=rep.hostIP\n and res.ctx=rep.ctx\n and res.username=rep.username\n and res.sid=rep.sid\n and res.hostIP='{$hostip}'\n and res.ctx=UNHEX('{$hostctx}')\n {$query_byuser} and msg<>'' and rep.sid<0";
} else {
$query = "select res.result_id, res.service, res.risk, res.falsepositive, res.scriptid, v.name, res.msg, rep.sid\n FROM vuln_nessus_latest_results res LEFT JOIN vuln_nessus_plugins AS v ON v.id=res.scriptid, vuln_nessus_latest_reports rep\n WHERE\n res.hostIP=rep.hostIP\n and res.ctx=rep.ctx\n and res.username=rep.username\n and res.sid=rep.sid\n and res.hostIP='{$hostip}'\n and res.ctx=UNHEX('{$hostctx}')\n {$query_byuser} and msg<>''";
}
//.........这里部分代码省略.........
示例6: list
$result = 'Impossible to save the host';
}
} else {
$result = 'The host already exists.';
}
break;
case 'update_aliases':
list($hostip, $ctx, $aliases) = explode('|', base64_decode($asset));
$hostid = key(Asset_host::get_id_by_ips($dbconn, $hostip, $ctx));
if (Asset_host::is_in_db($dbconn, $hostid)) {
try {
$asset = new Asset_host($dbconn, $hostid);
$asset->load_from_db($dbconn);
$asset->set_fqdns($aliases);
$asset->save_in_db($dbconn);
$result = 'Host aliases updated';
} catch (Exception $e) {
$result = 'Impossible to save the host aliases';
}
}
break;
case "get_host_id":
list($hostip, $ctx) = explode('|', base64_decode($asset));
$result = key(Asset_host::get_id_by_ips($dbconn, $hostip, $ctx));
break;
default:
$db->close();
die("The option isn't correct\n");
}
$db->close();
echo "{$result}\n";
示例7: import_assets_from_csv
//.........这里部分代码省略.........
$asset_value = !empty($param[4]) ? $param[4] : 2;
if (preg_match('/Host ID/', $csv_headers[8])) {
$os = $param[5];
$latitude = floatval($param[6]);
$longitude = floatval($param[7]);
$external = empty($param[9]) ? 0 : intval($param[9]);
$csv_devices = $param[10];
} else {
$os = $param[6];
$latitude = floatval($param[7]);
$longitude = floatval($param[8]);
$external = 0;
$csv_devices = '';
}
} else {
$descr = $param[2];
$os = $param[3];
$latitude = 0;
$longitude = 0;
$asset_value = 2;
$external = 0;
$csv_devices = $param[4];
}
//Permissions
$can_i_create_assets = Session::can_i_create_assets();
$can_i_modify_ips = TRUE;
//IPs
if (!ossim_valid($csv_ips, OSS_IP_ADDR, 'illegal:' . _('IP'))) {
$summary['by_hosts'][$num_line]['errors']['IP'] = ossim_get_error_clean();
$summary['general']['statistics']['errors']++;
continue;
}
//Check Host ID: Is there a host registered in the System?
$host_ids = Asset_host::get_id_by_ips($conn, $csv_ips, $ctx);
$host_id = key($host_ids);
if (!empty($host_id)) {
$is_in_db = TRUE;
} else {
$host_id = Util::uuid();
}
// Special case: Forced Host ID [Version 4.x.x or higher]
if ($import_type == 'hosts' && preg_match('/Host ID/', $csv_headers[8]) && valid_hex32($param[8])) {
$csv_hosts_id = strtoupper($param[8]);
if ($is_in_db == TRUE && $csv_hosts_id != $host_id) {
$id_error_msg = _('Host is already registered in the System with another Host ID');
$summary['by_hosts'][$num_line]['errors']['Host'] = $id_error_msg;
$summary['general']['statistics']['errors']++;
continue;
} else {
if ($is_in_db == FALSE) {
$host_id = $csv_hosts_id;
// Save host ID to insert it
}
}
}
//Hostname
if (!empty($iic)) {
$name = clean_iic($name);
}
if (!ossim_valid($name, OSS_HOST_NAME, 'illegal:' . _('Hostname'))) {
ossim_clean_error();
$name = Asset_host::create_valid_name($name);
$warning_msg = _('Hostname does not match with RFC 1123 specifications') . '<br/>' . _('Hostname will be replaced by') . ": <strong>{$name}</strong>";
$summary['by_hosts'][$num_line]['warnings']['Hostname'] = $warning_msg;
$summary['by_hosts'][$num_line]['status'] = 'warning';
$summary['general']['statistics']['warnings']++;
示例8: scan2html
function scan2html($conn, $scan)
{
$count = 0;
$text_hostname = "<div>" . _('A valid hostname satisfy the following rules (according RFC 1123)') . ":</div>\n <div>\n <ul>\n <li>" . _("A hostname can start or end with a letter or a number [a-zA-z0-9]") . "</li>\n <li>" . _("A hostname <strong>MUST NOT</strong> contain any '.' (dot)") . "</li>\n <li>" . _("A hostname <strong>MUST NOT</strong> start or end with a '-' (dash)") . "</li>\n <li>" . _("A hostname can be up to 63 characters") . "</li>\n </ul>\n </div>";
$text_fqdn = "<div>" . _('If FQDN contains any dot, only the first label will be used') . "</div>";
$text_mac = "<div>" . _('Place the pointer over the MAC address to show MAC vendor') . "</div>";
$text_services = "<div>" . _('Place the pointer over the service name to show more information') . "</div>";
$text_os = "<div>" . _('Place the pointer over the OS to show more information') . "</div>";
$html = '';
$s_ctx = $scan['sensor']['ctx'];
foreach ($scan['scanned_ips'] as $ip => $host) {
$w_msg = '';
$w_html = '';
$external_ctxs = Session::get_external_ctxs($conn);
//Checking forwarded hosts
if (empty($external_ctxs[$s_ctx])) {
$can_i_modify_elem = TRUE;
$md_check = "<input id='icheckbox" . $count . "' type='checkbox' checked='checked' class='mc' value='" . $ip . "' name='ip_" . $count . "'/>";
} else {
$can_i_modify_elem = FALSE;
$md_check = "<input id='icheckbox" . $count . "' type='checkbox' disabled='disabled' class='mc' name='ip_" . $count . "'/>";
}
$host_name = $host['hostname'];
$fqdn = $host['fqdn'];
$ids = Asset_host::get_id_by_ips($conn, $ip, $s_ctx);
$id = key($ids);
//Host already exists
if (!empty($id)) {
$host_object = Asset_host::get_object($conn, $id);
if (is_object($host_object) && !empty($host_object)) {
$host_name = $host_object->get_name();
$h_fqdn = $host_object->get_fqdns();
$fqdn = !empty($fqdn) ? $fqdn : $h_fqdn;
}
}
//FQDN
if (!empty($fqdn)) {
$fqdn_check = "<input id='fcheckbox" . $count . "' type='checkbox' class='fqdn' value='" . $ip . "' name='fqdn_" . $count . "'/>";
} else {
$fqdn = '-';
$fqdn_check = "<input id='fcheckbox" . $count . "' type='checkbox' disabled='disabled' class='fqdn' value='" . $ip . "' name='fqdn_" . $count . "'/>";
}
//Devices types
$devices_types = count($host['device_types']) > 0 ? implode(', ', $host['device_types']) : '-';
//MAC
$mac = !empty($host['mac']) != '' ? "<a class='more_info' title='" . $host['mac_vendor'] . "'>" . $host['mac'] . "</a>" : '-';
//Operating System
$os = !empty($host['os']) != '' ? Properties::get_os_pixmap($host['os']) . ' ' . $host['os'] : '-';
//Services
$services = array();
if (is_array($host['services'])) {
foreach ($host['services'] as $port_and_proto => $s_data) {
$service_name = $s_data['service'] != 'unknown' ? $s_data['service'] : $port_and_proto;
$version = $s_data['version'];
if (preg_match('/^cpe:\\/a/', $s_data['version'])) {
$version = Software::get_info($conn, $s_data['version']);
}
$version = !empty($version) && !preg_match("/^cpe/", $version) ? $version : $s_data['service'];
$title = $port_and_proto . " (" . $version . ')';
$html_data = "<a class='more_info' title='{$title}'>{$service_name}</a>";
$services[] = $html_data;
}
}
$services = implode(', ', $services);
if ($can_i_modify_elem == FALSE) {
$w_msg = _('The properties of this asset can only be modified at the USM') . ": <strong>" . $external_ctxs[$s_ctx] . '</strong>';
}
if (!empty($w_msg)) {
$w_html = "<a class='more_info' title='" . $w_msg . "'>\n <img src='../pixmaps/warning.png' border='0'/>\n </a>";
}
$html .= "\n <tr>\n <td class='td_chk_hosts'>" . $md_check . "</td>\n\n <td class='td_ip' id='ip" . $count . "'>{$w_html} " . $host['ip'] . "</td>\n\n <td class='td_hostname' id='hostname" . $count . "'>" . $host_name . "</td>\n\n <td class='td_fqdn' id='fqdn" . $count . "'>" . $fqdn . "</td>\n\n <td class='td_device_types' id='device_types" . $count . "'>" . ucwords($devices_types) . "</td>\n\n <td class='td_mac' id='mac" . $count . "'>" . $mac . "</td>\n\n <td class='td_os' id='os" . $count . "'>" . $os . "</td>\n\n <td class='td_services' id='services" . $count . "'>" . $services . "</td>\n\n <td class='td_chk_fqdns'>" . $fqdn_check . "</td>\n\n </tr>";
$count++;
}
?>
<form method="POST" action="scan_form.php" name="scan_form" id="scan_form">
<input type="hidden" name="ips" value='<?php
echo $count;
?>
'/>
<div class='results_title'><?php
echo _('Scan Results');
?>
</div>
<table class='table_data' id='t_sresults'>
<thead>
</tr>
<th class="th_chk_hosts">
<input type='checkbox' name='chk_all_hosts' id='chk_all_hosts' checked="checked" value="1"/>
</th>
<th class="th_ip"><?php
echo _('Host');
?>
</th>
<th class="th_hostname"><?php
echo _('Hostname');
//.........这里部分代码省略.........
示例9: ossim_db
//Database connection
$db = new ossim_db();
$conn = $db->connect();
if ($edition_type == 'single') {
// Single edition
$id = GET('id');
$_ip = GET('ip');
$_ctx = GET('ctx');
//Getting host by IP and CTX
if (empty($id) && !empty($_ctx) && !empty($_ip)) {
$entity_type = Session::get_entity_type($conn, $_ctx);
$entity_type = strtolower($entity_type);
//Sometimes CTX is an engine instead of context
$_ctx = $entity_type == 'context' ? $_ctx : Session::get_default_ctx();
if (Asset_host_ips::valid_ip($_ip) && valid_hex32($_ctx)) {
$aux_ids = Asset_host::get_id_by_ips($conn, $_ip, $_ctx);
$aux_id = key($aux_ids);
if (Asset_host::is_in_db($conn, $aux_id)) {
$id = $aux_id;
}
} else {
unset($_ip);
unset($_ctx);
}
}
if (!empty($id) && Asset_host::is_in_db($conn, $id)) {
ossim_valid($id, OSS_HEX, 'illegal:' . _('Asset ID'));
if (ossim_error()) {
echo ossim_error(_('Error! Asset not found'));
exit;
}
示例10: submit_scan
//.........这里部分代码省略.........
$requested_run = sprintf("%04d%02d%02d%02d%02d%02d", $b_y, $b_m, $b_d, $b_h, $b_u, "00");
//error_log("M-> $requested_run $begin_in_seconds $current_in_seconds\n" ,3,"/tmp/sched.log");
$recurring = True;
$sched_message = "Schedule Reccurring";
$reccur_type = "Montly";
break;
case "NW":
if ($begin_in_seconds > $current_in_seconds) {
// if it is a future date
$array_time = array('month' => $bbimonth, 'day' => $bbiday, 'year' => $bbiyear);
$requested_run = weekday_month(strtolower($daysMap[$dayofweek]), $nthweekday, $btime_hour, $btime_min, $array_time);
} else {
$requested_run = weekday_month(strtolower($daysMap[$dayofweek]), $nthweekday, $btime_hour, $btime_min);
}
preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $requested_run, $found);
list($b_y, $b_m, $b_d, $b_h, $b_u, $b_s, $b_time) = Util::get_utc_from_date($dbconn, $found[1] . "-" . $found[2] . "-" . $found[3] . " " . $found[4] . ":" . $found[5] . ":00", $tz);
$requested_run = sprintf("%04d%02d%02d%02d%02d%02d", $b_y, $b_m, $b_d, $b_h, $b_u, "00");
//error_log("NW-> $requested_run\n" ,3,"/tmp/sched.log");
$dayofmonth = $nthweekday;
$recurring = True;
$sched_message = "Schedule Reccurring";
$reccur_type = "Nth weekday of the month";
break;
default:
break;
}
$insert_time = gmdate("YmdHis");
if (!empty($_SESSION["_vuln_targets"]) && count($_SESSION["_vuln_targets"]) > 0) {
$arr_ctx = array();
$sgr = array();
foreach ($_SESSION["_vuln_targets"] as $target_selected => $server_id) {
$sgr[$server_id][] = $target_selected;
if (preg_match("/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\/\\d{1,2}\$/i", $target_selected)) {
$related_ctxs = array_values(Asset_net::get_id_by_ips($dbconn, $target_selected));
if (is_array($related_ctxs) && count($related_ctxs) > 0) {
$arr_ctx[$target_selected] = key(array_shift($related_ctxs));
}
} else {
if (preg_match("/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\$/i", $target_selected)) {
$related_ctxs = array_values(Asset_host::get_id_by_ips($dbconn, $target_selected));
if (is_array($related_ctxs) && count($related_ctxs) > 0) {
$arr_ctx[$target_selected] = key(array_shift($related_ctxs));
// to assign a ctx for a IP
}
} else {
if (valid_hostname($target_selected) || valid_fqdns($target_selected)) {
$filters = array('where' => "hostname like '{$target_selected}' OR fqdns like '{$target_selected}'");
$_hosts_data = Asset_host::get_basic_list($dbconn, $filters);
$host_list = $_hosts_data[1];
if (count($host_list) > 0) {
$first_host = array_shift($host_list);
$hips = explode(",", $first_host['ips']);
foreach ($hips as $hip) {
$hip = trim($hip);
$arr_ctx[$hip] = $first_host['ctx'];
}
}
}
}
}
}
ossim_clean_error();
unset($_SESSION["_vuln_targets"]);
// clean scan targets
$query = array();
$IP_ctx = array();
示例11: ossim_db
/****************************************************
******************** Host Data *********************
****************************************************/
//Flags
$is_new_host = TRUE;
//Database connection
$db = new ossim_db();
$conn = $db->connect();
$msg = GET('msg');
$id = GET('id');
$_aux_ip = $_GET['ip'];
$_aux_ctx = $_GET['ctx'];
//Getting host by IP and CTX
if (empty($id) && !empty($_aux_ctx) && !empty($_aux_ip)) {
if (Asset_host_ips::valid_ip($_aux_ip) && valid_hex32($_aux_ctx)) {
$aux_ids = Asset_host::get_id_by_ips($conn, $_GET['ip'], $_GET['ctx']);
$aux_id = key($aux_ids);
if (Asset_host::is_in_db($conn, $aux_id)) {
$id = $aux_id;
}
} else {
unset($_aux_ip);
unset($_aux_ctx);
}
}
if (!empty($id)) {
ossim_valid($id, OSS_HEX, 'illegal:' . _('Host ID'));
if (ossim_error()) {
echo ossim_error(_('Error! Host not found'));
exit;
}
示例12: file_get_contents
$conn = $db->connect();
//Validating icon format and size
$icon = '';
if (is_uploaded_file($_FILES['icon']['tmp_name'])) {
$icon = file_get_contents($_FILES['icon']['tmp_name']);
}
if ($icon != '') {
$image = @imagecreatefromstring($icon);
if (!$image || imagesx($image) > 16 || imagesy($image) > 16) {
$validation_errors['icon'] = _('Image format is not allowed. Allowed only 16x16 PNG images');
}
}
//Validating IPs
$aux_ips = explode(',', $ips_string);
foreach ($aux_ips as $ip) {
$host_ids = Asset_host::get_id_by_ips($conn, $ip, $ctx);
unset($host_ids[$id]);
if (!empty($host_ids)) {
$validation_errors['ip'] = _('Error! IP not allowed.') . " IP {$ip} " . _('already exists for this entity');
break;
} else {
$cnd_1 = Session::get_net_where() != '' && !Session::only_ff_net();
$cnd_2 = Asset_host::is_ip_in_cache_cidr($conn, $ip, $ctx, TRUE);
if ($cnd_1 && !$cnd_2) {
$validation_errors['ip'] = _("Error! IP {$ip} not allowed. Check your asset filter");
break;
}
}
}
//Validating Sensors
if (is_array($sensors) && !empty($sensors)) {