public function testInvalidDescription() { $invalidTest = array('sensor_id' => 1, 'dataset_id' => 1, 'sensor_name' => 'sensor_0', 'sensor_type' => 'TEMPERATURE', 'sensor_units' => 'DEGREES-FAHRENHEIT', 'sequence_type' => 'TIME-CODED', 'description' => 'This description is 132 characters long' . ' Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna ', 'measurements' => array()); $invalidSensor = new Sensor($invalidTest); $this->assertEquals(1, $invalidSensor->getErrorCount(), 'The Sensor object should have exactly 1 error'); $this->assertTrue(!empty($invalidSensor->getError('description')), 'The Sensor should have a description error'); }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $modelSensor = new Sensor(); $modelSensor->setScenario('buscar'); $model = null; $idSensor = null; if (isset($_POST['Sensor'])) { $modelSensor->attributes = $_POST['Sensor']; if ($modelSensor->validate()) { $model = Sensor::model()->getSensorValores($modelSensor->idsensor); $idSensor = $modelSensor->idsensor; } } $this->render('index', array('model' => $model, 'modelSensor' => $modelSensor, 'idSensor' => $idSensor)); }
public static function watch() { $temp = Sensor::getTemperature(); if ($temp < -50 || $temp > 50) { throw new RangeException('The sennor broke down'); } }
public function show($daysAgo) { $date = new Carbon\Carbon(); $date->subDays($daysAgo); $sensors = Sensor::findMany(Data::where('timestamp', '>', $date->toDateTimeString())->distinct('sensor_id')->get(array('sensor_id'))->toArray()); $timestamps = Data::where('timestamp', '>', $date->toDateTimeString())->distinct('timestamp')->get(array('timestamp')); return View::make("showGraph", ["daysAgo" => $daysAgo, "sensors" => $sensors, "timestamps" => $timestamps]); }
public static function getSensorsArray($rows) { $sensors = array(); if (!empty($rows)) { // Convert the array of arrays into an array of Sensors // and set the id field foreach ($rows as $sensorRow) { $sensor = new Sensor($sensorRow); $sensorId = $sensorRow['sensor_id']; $sensor->setSensorId($sensorId); // TODO: We should also get the sensor's associated measurements // Coordinate this in the controller array_push($sensors, $sensor); } } return $sensors; }
function update(Sensor $sen) { $query = "UPDATE `sensor` SET `sensor_board_id`='" . $sen->getSensorBoardId() . "',`manufactured_date`='" . $sen->getManufacturedDate() . "',`sensor_type`='" . $sen->getSensorType() . "',`sensor_status`='" . $sen->getSensorStatus() . "' WHERE `idsensor`='" . $sen->getIdsensor() . "'"; $this->con->openConnection(); $this->con->executeRawQuery($query); $this->con->closeConnection(); }
function host_row_basic($host, $conn, $criterias, $has_criterias, $networks, $hosts_ips, $i) { require_once "classes/Sensor.inc"; $color = $i % 2 == 0 ? "#F2F2F2" : "#FFFFFF"; $ip = $host->get_ip(); $host_name = $ip != $host->get_hostname() ? $host->get_hostname() . " ({$ip})" : $ip; $gi = geoip_open("/usr/share/geoip/GeoIP.dat", GEOIP_STANDARD); $country = strtolower(geoip_country_code_by_addr($gi, $ip)); $country_name = geoip_country_name_by_addr($gi, $ip); geoip_close($gi); if ($country) { $country_img = " <img src=\"../pixmaps/flags/" . $country . ".png\" alt=\"{$country_name}\" title=\"{$country_name}\">"; } else { $country_img = ""; } //$homelan = (Net::isIpInNet($ip, $networks) || in_array($ip, $hosts_ips)) ? " <a href=\"javascript:;\" class=\"scriptinfo\" style=\"text-decoration:none\" ip=\"".$ip."\"><img src=\"../forensics/images/homelan.png\" border=0></a>" : ""; // Network require_once 'classes/Net.inc'; $netname = Net::GetClosestNet($conn, $ip); if ($netname != false) { $ips = Net::get_ips_by_name($conn, $netname); $net = "<b>{$netname}</b> ({$ips})"; } else { $net = "<i>" . _("Asset Unknown") . "</i>"; } // Inventory $os_data = Host_os::get_ip_data($conn, $ip); if ($os_data["os"] != "") { $os = $os_data["os"]; $os_pixmap = Host_os::get_os_pixmap($conn, $ip); } else { $os = _("OS Unknown"); $os_pixmap = ""; } require_once 'classes/Host_services.inc'; $services = Host_services::get_ip_data($conn, $ip, 0); $services_arr = array(); foreach ($services as $serv) { $services_arr[$serv['service']]++; } // Vulnerabilities require_once 'classes/Status.inc'; list($vuln_list, $num_vuln, $vuln_highrisk, $vuln_risknum) = Status::get_vul_events($conn, $ip); $vuln_list_str = ""; $v = 0; foreach ($vuln_list as $vuln) { if ($v++ < 20) { $vuln_list_str .= $vuln['name'] . "<br>"; } } $vuln_list_str = str_replace("\"", "", $vuln_list_str); $vuln_caption = $num_vuln > 0 ? ' class="greybox_caption" data="' . $vuln_list_str . '"' : ' class="greybox"'; // Incidents $sql = "SELECT count(*) as num FROM alarm WHERE src_ip=INET_ATON(\"{$ip}\") OR dst_ip=INET_ATON(\"{$ip}\")"; if (!($rs =& $conn->Execute($sql))) { $num_alarms = _("Error in Query: {$sql}"); } else { if (!$rs->EOF) { $num_alarms = $rs->fields['num']; } } if ($num_alarms > 0) { $alarm_link = '<a href="../control_panel/alarm_console.php?&hide_closed=1&hmenu=Alarms&smenu=Alarms&src_ip=' . $ip . '&dst_ip=' . $ip . '" target="main"><b>' . $num_alarms . '</b></a>'; } else { $alarm_link = '<b>' . $num_alarms . '</b>'; } $sql = "SELECT count(*) as num FROM incident_alarm WHERE src_ips=\"{$ip}\" OR dst_ips=\"{$ip}\""; if (!($rs =& $conn->Execute($sql))) { $num_tickets = _("Error in Query: {$sql}"); } else { if (!$rs->EOF) { $num_tickets = $rs->fields['num']; } } if ($num_tickets > 0) { $tickets_link = '<a href="../incidents/index.php?status=Open&hmenu=Tickets&smenu=Tickets&with_text=' . $ip . '" target="main"><b>' . $num_tickets . '</b></a>'; } else { $tickets_link = '<b>' . $num_tickets . '</b>'; } // Events list($sim_events, $sim_foundrows, $sim_highrisk, $sim_risknum, $sim_date) = Status::get_SIM_light($ip, $ip); if ($sim_foundrows > 0) { $sim_link = '<a href="../forensics/base_qry_main.php?&num_result_rows=-1&submit=Query+DB¤t_view=-1&sort_order=time_d&ip=' . $ip . '&date_range=week&hmenu=Forensics&smenu=Forensics" target="main"><b>' . $sim_foundrows . '</b></a>'; } else { $sim_link = '<b>' . $sim_foundrows . '</b>'; } // $txt_tmp1 = _('Events in the SIEM'); $txt_tmp2 = _('Events in the logger'); if ($_SESSION['inventory_search']['date_from'] != "" && $_SESSION['inventory_search']['date_from'] != '1700-01-01') { $start_week = $_SESSION['inventory_search']['date_from']; } else { $start_week = strftime("%Y-%m-%d", time() - 24 * 60 * 60 * 1); } if ($_SESSION['inventory_search']['date_to'] != "" && $_SESSION['inventory_search']['date_to'] != '3000-01-01') { $end = $_SESSION['inventory_search']['date_to']; } else { $end = strftime("%Y-%m-%d", time()); } if ($start_week == strftime("%Y-%m-%d", time() - 24 * 60 * 60 * 1) && $end == strftime("%Y-%m-%d", time())) { $txt_tmp1 .= _(' (Last Week)'); $txt_tmp2 .= _(' (Last Day)'); } $start_week_temp = $start_week; $start_week .= ' 00:00:00'; $end_temp = $end; $end .= ' 23:59:59'; // //$start_week = strftime("%Y-%m-%d %H:%M:%S", time() - (24 * 60 * 60 * 7)); //$end = strftime("%Y-%m-%d %H:%M:%S", time()); list($sem_events_week, $sem_foundrows_week, $sem_date, $sem_wplot_y, $sem_wplot_x) = Status::get_SEM("", $start_week, $end, "none", 1234, $ip); if ($sem_foundrows_week > 0) { $sem_link = '<a href="../sem/index.php?hmenu=SEM&smenu=SEM&query=' . urlencode($ip) . '&start=' . urlencode($start_week) . '" target="main"><b>' . $sem_foundrows_week . '</b></a>'; } else { $sem_link = '<b>' . $sem_foundrows_week . '</b>'; } // Anomalies list($event_list, $anm_foundrows, $anm_foundrows_week, $anm_date) = Status::get_anomalies($conn, $ip); // Ntp link $ntop_lnk = Sensor::get_sensor_link($conn, $ip); if (preg_match("/(\\d+\\.\\d+\\.\\d+\\.\\d+)/", $ntop_lnk, $fnd)) { $ntop_ip = $fnd[1]; } else { $ntop_ip = $ip; } // $row = '<tr bgcolor="' . $color . '"> <td class="nobborder" style="text-align:center;padding:2px"><a href="../report/host_report.php?host=' . $ip . '&star_date=' . $start_week_temp . '&end_date=' . $end_temp . '" id="' . $ip . ';' . $host->get_hostname() . '" class="HostReportMenu" style="color:#17457c;font-size:15px;text-align:left"><b>' . $host_name . '</b></font></a><br><font style="color:gray">' . $net . '</font></td> <td class="nobborder" style="text-align:center;padding:2px">' . $os . ' ' . $os_pixmap . '<br>' . implode("<br>", array_keys($services_arr)) . '</td> <td class="nobborder" style="text-align:center;padding:2px"><a href="../vulnmeter/index.php?value=' . $ip . '&type=hn&withoutmenu=1&hmenu=Vulnerabilities&smenu=Vulnerabilities" title="Top 20 ' . _("Vulnerabilities for") . ' ' . $ip . '"' . $vuln_caption . '>' . $num_vuln . '</a></td> <td class="nobborder" style="text-align:center;padding:2px">' . $alarm_link . ' ' . _("Alarms") . '<br>' . $tickets_link . ' ' . _("Tickets") . '</td> <td class="nobborder" style="padding:2px">' . $sim_link . ' ' . $txt_tmp1 . '<br>' . $sem_link . ' ' . $txt_tmp2 . '</td> <td class="nobborder" style="text-align:center;padding:2px"><a href="../control_panel/anomalies.php?withoutmenu=1" class="greybox" title="' . _("Anomalies") . '"><b>' . $anm_foundrows . '</b></a></td> <td class="nobborder" style="text-align:center;padding:2px"> <table class="transparent"> <tr> <td class="nobborder"><img src="../pixmaps/ntop_graph_thumb.gif" width="40"></td> <td class="nobborder"><a href="../ntop/index.php?opc=services&sensor=' . $ntop_ip . '&hmenu=Network&smenu=Profiles&link_ip=' . $ip . '" target="main">' . _("Traffic Sent/Rcvd") . '</a></td> </tr> </table> </td> </tr>'; // <td class="nobborder"><a href="'.Sensor::get_sensor_link($conn,$ip).'/hostTimeTrafficDistribution-'.$ip.'-65535.png?1" class="greybox">'._("Traffic Sent").'</a><br><a href="'.Sensor::get_sensor_link($conn,$ip).'/hostTimeTrafficDistribution-'.$ip.'-65535.png" class="greybox">'._("Traffic Rcvd").'</a></td> echo str_replace("\n", "", str_replace("\r", "", str_replace("'", "", $row))); }
require_once 'classes/Host.inc'; $host_list = Host::get_list($conn); $hosts[] = array("value" => ANY, "name" => "ANY"); foreach ($host_list as $h) { $hosts[] = array("value" => $h->get_ip(), "name" => $h->get_hostname() . " (" . $h->get_ip() . ")"); } /* nets */ require_once 'classes/Net.inc'; $net_list = Net::get_list($conn); $nets[] = array("value" => ANY, "name" => "ANY"); foreach ($net_list as $n) { $nets[] = array("value" => $n->get_name(), "name" => $n->get_name()); } /* sensors */ require_once 'classes/Sensor.inc'; $sensor_list = Sensor::get_list($conn); $sensors[] = array("value" => ANY, "name" => "ANY"); foreach ($sensor_list as $s) { $sensors[] = array("value" => $s->get_ip(), "name" => $s->get_name() . " (" . $s->get_ip() . ")"); } /* ports */ require_once 'classes/Port_group.inc'; $port_list = Port_group::get_list($conn); $ports[] = array("value" => ANY, "name" => "ANY"); foreach ($port_list as $p) { $ports[] = array("value" => $p->get_name(), "name" => $p->get_name() . " (" . $p->get_descr() . ")"); } /* plugins */ require_once 'classes/Plugin.inc'; $plugin_list = Plugin::get_list($conn); $plugins[] = array("value" => ANY, "name" => "ANY");
$agent_type = 0; } else { exec("sudo /var/ossec/bin/agent_control -i " . $agent[0] . " -s", $more_info, $ret); $more_info = $ret !== 0 ? _("Information from agent not available") : explode(",", $more_info[0]); $agent_name = "<a class='agent_id'><img src='../pixmaps/plus-small.png' alt='More info' align='absmiddle'/>" . $agent[0] . "</a>"; $agent_actions = get_actions($agent); $agent_type = 1; } //Agents trends $trend = array(); if ($agent[2] == "127.0.0.1") { require_once 'classes/Sensor.inc'; $db = new ossim_db(); $dbconn = $db->connect(); $name = trim(str_replace("(server)", "", $agent[1])); $sensor = Sensor::get_list($dbconn, "WHERE name = '{$name}'"); $ip = empty($sensor) ? $agent[2] : $sensor[0]->get_ip(); } else { $ip = $agent[2]; } $data = SIEM_trends_hids($ip); if (is_array($data)) { $max = 7; for ($ii = $max - 1; $ii >= 0; $ii--) { $d = gmdate("j M", $timetz - 86400 * $ii); $trend[$d] = $data[$d] != "" ? $data[$d] : 0; } $i = 0; foreach ($trend as $k => $v) { $x[$k] = $i; $i++;
function import_assets_csv($filename) { require_once 'classes/Util.inc'; $response = array(); $db = new ossim_db(); $conn = $db->connect(); if (($content = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)) == false) { $response['file_errors'] = "Failed to read file"; $response['status'] = false; return $response; } else { foreach ($content as $k => $v) { $data[] = explode(";", $v); } } $cont = 0; ini_set('max_execution_time', 180); ids_valid($data); if (count($data) <= 0) { $response['file_errors'] = _("Incompatible file format"); $response['status'] = false; return $response; } $allowed_sensors = Session::allowedSensors(); if (!empty($allowed_sensors)) { $my_allowed_sensors = explode(',', $allowed_sensors); } else { $response['file_errors'] = _("You need at least one sensor assigned"); $response['status'] = false; return $response; } foreach ($data as $k => $v) { $response['status'] = true; $response['read_line'] = $cont; $cont++; if (count($v) != 8) { $response['line_errors'][$cont][] = array("Line", _("Format not allowed")); $response['status'] = false; } $param = array(); foreach ($v as $i => $field) { $parameter = trim($field); $pattern = '/^\\"|\\"$|^\'|\'$/'; $param[] = preg_replace($pattern, '', $parameter); } //IP if (!ossim_valid($param[0], OSS_IP_ADDR, 'illegal:' . _("IP"))) { $response['line_errors'][$cont][] = array("IP", ossim_get_error_clean()); $response['status'] = false; } //Hostname if (empty($param[1])) { $param[1] = $param[0]; } else { if (!ossim_valid($param[1], OSS_SCORE, OSS_ALPHA, OSS_PUNC, 'illegal:' . _("Hostname"))) { $response['line_errors'][$cont][] = array("Hostname", ossim_get_error_clean()); $response['status'] = false; ossim_clean_error(); } } //FQDNs if (!empty($param[2])) { $fqdns_list = explode(",", $param[2]); foreach ($fqdns_list as $k => $fqdn) { if (!ossim_valid(trim($fqdn), OSS_NULLABLE, OSS_ALPHA, OSS_PUNC, 'illegal:' . _("FQDN/Aliases"))) { $response['line_errors'][$cont][] = array("FQDN/Aliases", ossim_get_error_clean()); $response['status'] = false; ossim_clean_error(); } } } //Description if (!ossim_valid($param[3], OSS_NULLABLE, OSS_SCORE, OSS_ALPHA, OSS_PUNC, OSS_AT, 'illegal:' . _("Description"))) { $response['line_errors'][$cont][] = array("Description", ossim_get_error_clean()); $response['status'] = false; ossim_clean_error(); } //Asset if ($param[4] == '') { $param[4] = 2; } else { if (!ossim_valid($param[4], OSS_NULLABLE, OSS_DIGIT, 'illegal:' . _("Asset value"))) { $response['line_errors'][$cont][] = array("Asset", ossim_get_error_clean()); $response['status'] = false; ossim_clean_error(); } } //NAT if (!ossim_valid($param[5], OSS_NULLABLE, OSS_IP_ADDR, 'illegal:' . _("NAT"))) { $response['line_errors'][$cont][] = array("NAT", ossim_get_error_clean()); $response['status'] = false; ossim_clean_error(); } //Sensors $sensors = array(); if (!empty($param[6])) { $sensor_name = array(); $list = explode(",", $param[6]); $sensors_list = array_intersect($list, $my_allowed_sensors); if (!empty($sensors_list)) { foreach ($sensors_list as $sensor) { $sensors[] = Sensor::get_sensor_name($conn, $sensor); } } else { $response['line_errors'][$cont][] = array("Sensors", _("You need at least one allowed Sensor")); $response['status'] = false; ossim_clean_error(); } } else { $response['line_errors'][$cont][] = array("Sensors", _("Column Sensors is empty")); $response['status'] = false; ossim_clean_error(); } $list_os = array("Windows", "Linux", "FreeBSD", "NetBSD", "OpenBSD", "MacOS", "Solaris", "Cisco", "AIX", "HP-UX", "Tru64", "IRIX", "BSD/OS", "SunOS", "Plan9", "IPhone"); //Operating System if (!empty($param[7]) && !in_array($param[7], $list_os)) { $param[7] = "Unknown"; } if ($response['status'] == true) { //Parameters $ip = $param[0]; $hostname = $param[1]; $asset = $param[4]; $threshold_c = 30; $threshold_a = 30; $rrd_profile = ""; $alert = 0; $persistence = 0; $nat = $param[5]; $descr = $param[3]; $os = $param[7]; $fqdns = $param[2]; $latitude = ''; $longitude = ''; $icon = 0; if (!Host::in_host($conn, $ip)) { Host::insert($conn, $ip, $hostname, $asset, $threshold_c, $threshold_a, $rrd_profile, $alert, $persistence, $nat, $sensors, $descr, $os, $mac, $mac_vendor, $latitude, $longitude, $fqdns, $icon); } else { Host::update($conn, $ip, $hostname, $asset, $threshold_c, $threshold_a, $rrd_profile, $alert, $persistence, $nat, $sensors, $descr, $os, $mac, $mac_vendor, $latitude, $longitude, $fqdns, $icon); } } } $response['read_line'] = $cont; return $response; }
echo _("Description"); ?> </th> <?php if ($_SESSION["_user"] == "admin") { ?> <th><?php echo _("User"); ?> </th><?php } ?> <th></th> <?php $locations = Wireless::get_locations($conn); $ossim_sensors = Sensor::get_list($conn, "s, sensor_properties p WHERE s.ip=p.ip AND p.has_kismet=1"); $sensors_list = ""; foreach ($ossim_sensors as $sensor) { $sensors_list .= "<option value='" . $sensor->get_name() . "'>" . $sensor->get_name() . " [" . $sensor->get_ip() . "]"; } $c = 0; foreach ($locations as $data) { $c++; echo "<tr bgcolor='#f2f2f2'>\n\t<td width='20'><a href=\"javascript:;\" onclick=\"showhide('#cell{$c}','#img{$c}')\"><img src='../pixmaps/plus-small.png' id='img{$c}' border=0></a></td>\n\t<td>" . $data["location"] . "</td>\n\t<td style='text-align:left;padding-left:10px'>" . $data['description'] . "</td>"; if ($_SESSION["_user"] == "admin") { echo "<td>" . $data["user"] . "</td>"; } echo "<td width='20'>\n\t\t<a href='?action=del&location=" . urlencode($data["location"]) . "'><img src='../repository/images/del.gif' border=0></a>\n\t</td></tr>\n\t<tr><td colspan=3 style='padding:10px 0px 10px 40px;display:none' id='cell{$c}'>\n\t\t<table width='100%'>\n\t\t<tr><td colspan=7>\n\n\t\t\t<form>\n\t\t\t<input type='hidden' name='action' value='add_sensor'>\n\t\t\t<input type='hidden' name='layer' value='{$c}'>\n\t\t\t<input type='hidden' name='location' value='" . $data["location"] . "'>\n\t\t\t<table class='noborder'>\n\t\t\t<tr>\n\t\t\t\t<td class='noborder'><select name='sensor'>" . $sensors_list . "</select></td>\n\t\t\t\t<td class='noborder'><input type='text' size='15' name='model' id='model{$c}'></td>\n\t\t\t\t<td class='noborder'><input type='text' size='15' name='serial' id='serial{$c}'></td>\n\t\t\t\t<td class='noborder'><input type='text' size='25' name='mounting' id='mounting{$c}'></td>\n\t\t\t\t<td class='noborder'><input type='submit' value='Add Sensor' class='lbutton'></td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t</form>\n\t\n\t\t</td></tr>\n\t\t<th nowrap>" . _("Sensor") . "</th>\n\t\t<th nowrap>" . _("IP Addr") . "</th>\n\t\t<th nowrap>" . _("Mac Address") . "</th>\n\t\t<th nowrap>" . _("Model #") . "</th>\n\t\t<th nowrap>" . _("Serial #") . "</th>\n\t\t<th nowrap>" . _("Mounting Location") . "</th>\n\t\t<th></th>"; $i = 0; foreach ($data["sensors"] as $sensors) { $color = $i++ % 2 == 0 ? "bgcolor='#f2f2f2'" : "";
$j++; } if ($html != "") { $buffer .= preg_replace("/,\$/", "", $html); } if ($j > $to) { $li = "key:'{$key}', page:'{$nextpage}', isFolder:true, isLazy:true, icon:'../../pixmaps/theme/net.png', title:'" . _("next") . " {$maxresults} " . _("nets") . "'"; $buffer .= ",{ {$li} }\n"; } $buffer .= "]"; if ($buffer == "[]" || $buffer == "") { $buffer = "[{title:'" . _("No Networks Found") . "', noLink:true}]"; } } else { if ($key == "sensor") { if ($sensor_list = Sensor::get_list($conn, "ORDER BY name")) { $buffer .= "["; $j = 0; foreach ($sensor_list as $sensor) { if ($j >= $from && $j < $to) { $sensor_name = $sensor->get_name(); $s_title = Util::htmlentities(utf8_encode($sensor_name)); $sensor_key = utf8_encode("SENSOR:" . $sensor_name); $title = strlen($sensor_name) > $length_name ? substr($sensor_name, 0, $length_name) . "..." : $sensor_name; $title = Util::htmlentities(utf8_encode($title)); $tooltip = $s_title; $li = "key:'{$sensor_key}', asset_data:'" . $sensor->get_ip() . "/32', icon:'../../pixmaps/theme/host.png', title:'{$title}', tooltip:'{$tooltip}'\n"; $buffer .= ($j > $from ? "," : "") . "{ {$li} }\n"; } $j++; }
} } $active_sensors = 0; $total_sensors = 0; // Munin $ossim_conf = $GLOBALS["CONF"]; $use_munin = $ossim_conf->get_conf("use_munin"); if ($use_munin == 1) { $munin_link = $ossim_conf->get_conf("munin_link"); } $xml = ""; if (preg_match("/version/", $order)) { $sensor_list = Sensor::get_list_by_version($conn, $order, $limit); } else { $sensor_list = Sensor::get_all($conn, "ORDER BY {$order} {$limit}"); $sensor_list_total = Sensor::get_all($conn, ""); } // if ($sensor_list[0]) { $total = $sensor_list[0]->get_foundrows(); if ($total == 0) { $total = count($sensor_list); } if (count($sensor_list_total) > 0) { $total = count($sensor_list_total); } } else { $total = 0; } $xml .= "<rows>\n"; $xml .= "<page>{$page}</page>\n";
$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); } } $tmp_index = 0; foreach ($tmp_group_nets as $gn) { $net_group_index[$gn->get_name($conn)] = $tmp_index; $tmp_index++; array_push($net_group_list, $gn); } $tmp_index = 0; foreach ($tmp_group_hosts as $gh) { $host_group_index[$gh->get_name($conn)] = $tmp_index; $tmp_index++;
function getSensorList() { global $conn; if ($host_list = Sensor::get_list($conn, '', '')) { return $host_list; } return ""; }
/** * Display the specified resource. * GET /sensors/{id} * * @param int $id * @return Response */ public function show($id) { $sensor = Sensor::find($id); return View::make("viewSensor", ['sensor' => $sensor]); }
static function getListSensor() { $models = Sensor::model()->findAll(array('order' => 'idsensor')); $list = CHtml::listData($models, 'idsensor', 'descripcion'); return $list; }
list($sensor_list, $err) = server_get_sensors($conn); if ($err != "") { echo $err; } if ($sensor_list) { $_SESSION["_sensor_list"] = $sensor_list; foreach ($sensor_list as $sensor => $plugins) { array_push($sensor_stack_on, $sensor); $sensor_stack[$sensor] = 1; } } $sensor_templates = array(); if ($sensor_list = Sensor::get_all($conn, "")) { $total_sensors = count($sensor_list); foreach ($sensor_list as $sensor) { $s_tpl = Sensor::is_sensor_in_templates($conn, $sensor->get_ip()); if (!empty($s_tpl)) { $sensor_templates[$sensor->get_ip()] = implode(",", $s_tpl); } if ($sensor_stack[$sensor->get_ip()] == 1) { $active_sensors++; array_push($sensor_configured_stack, $sensor->get_ip()); } } } $active_sensors = $active_sensors == 0 ? "<font color=red><b>{$active_sensors}</b></font>" : "<a href=\"sensor.php?onlyactive=1\"><font color=green><b>{$active_sensors}</b></font></a>"; $total_sensors = "<a href=\"sensor.php\"><b>{$total_sensors}</b></a>"; $db->close($conn); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<td class="nobborder">|</td> <td class="nobborder" nowrap> <a href="<?php echo Sensor::get_sensor_link($conn, $host) . "/{$host}.html"; ?> " target="report"> <?php echo gettext("Usage"); ?> </a> </td> <?php if (Host::in_host($conn, $host) || Net::isIpInAnyNet($conn, $host)) { $interface = Sensor::get_sensor_interface($conn, $host); ?> <td class="nobborder">|</td> <td class="nobborder" nowrap> <a href="<?php echo Sensor::get_sensor_link($conn, $host) . "/plugins/rrdPlugin?action=list&key=interfaces/{$interface}/hosts/{$ip_slashed}&title=host%20{$host}"; ?> " target="report"> <?php echo gettext("Anomalies"); ?> </a> </td> <?php } $db->close($conn); ?> <td class="nobborder">]</td> </table> </body>
function ReadProfile($profileswitch) { // User sensors filtering require_once 'classes/Session.inc'; require_once 'classes/Sensor.inc'; require_once 'ossim_db.inc'; $db_aux = new ossim_db(); $conn_aux = $db_aux->connect(); $sensors_list = Sensor::get_list($conn_aux); $db_aux->close($conn_aux); $opts['profile'] = $profileswitch; $profileinfo = nfsend_query("get-profile", $opts, 0); if (!is_array($profileinfo)) { return false; } if (!array_key_exists('description', $profileinfo)) { $profileinfo['description'] = array(); } $channels = array(); // in case it's a new profile with no channels associated yet if (!array_key_exists('channel', $profileinfo)) { $profileinfo['channel'] = $channels; } // Decode channel information foreach ($profileinfo['channel'] as $channel) { list($name, $sign, $colour, $order, $sourcelist) = explode(":", $channel); $has_perm = 0; foreach ($sensors_list as $s) { if ($name == $s->get_name()) { $has_perm = 1; } } if (Session::am_i_admin()) { $has_perm = 1; } if (!$has_perm) { continue; } $_tmp = array(); $_tmp['name'] = $name; $_tmp['sign'] = $sign; $_tmp['colour'] = $colour; $_tmp['order'] = $order; $_tmp['sourcelist'] = $sourcelist; $channels[$name] = $_tmp; } $profileinfo['channel'] = $channels; return $profileinfo; }
} else { echo $buffer; } } else { if (preg_match("/^e_(.*)_net\$/", $key)) { $buffer = Net::draw_nets_by_class($conn, $key, $filter, $length_name, 1); echo $buffer; } else { if (preg_match("/^e_(.*)_.class_(.*)/", $key)) { $buffer = Net::draw_nets_by_class($conn, $key, $filter, $length_name, 1); echo $buffer; } else { if (preg_match("/e_(.*)_sensor/", $key, $found)) { $entityPerms = Acl::entityPerms($conn, $found[1]); $all = count($entityPerms["sensors"]); $sensors = Sensor::get_all($conn); $j = 0; $buffer .= "["; foreach ($sensors as $sensor) { if (!$all || $entityPerms["sensors"][$sensor->get_ip()]) { $sensor_name = $sensor->get_name(); $s_title = Util::htmlentities($sensor_name); $sensor_key = utf8_encode("sensor;" . $sensor_name); $title = strlen($sensor_name) > $length_name ? substr($sensor_name, 0, $length_name) . "..." : $sensor_name; $title = Util::htmlentities($title); $tooltip = $s_title; $li = "url:'" . $sensor->get_ip() . "', icon:'../../pixmaps/theme/server.png', title:'{$title}', tooltip:'{$tooltip}'\n"; $buffer .= ($j > 0 ? "," : "") . "{ {$li} }"; $j++; } }
?> <?php echo gettext("properties"); ?> </h1> <?php require_once 'ossim_db.inc'; require_once 'classes/Sensor.inc'; $db = new ossim_db(); $conn = $db->connect(); if (!(REQUEST('snort') || REQUEST('spade') || REQUEST('ossim') || REQUEST('ntop') || REQUEST('snortwrite') || REQUEST('spadewrite') || REQUEST('ossimwrite') || REQUEST('ntopwrite'))) { if (empty($ip)) { echo "<p> " . gettext("What sensor do you want to edit") . " ?</p>\n"; if ($sensor_list = Sensor::get_list($conn, "")) { foreach ($sensor_list as $sensor) { $ip = $sensor->get_ip(); $name = $sensor->get_name(); ?> <p><a href="<?php echo $_SERVER["SCRIPT_NAME"]; ?> ?ip=<?php echo $ip; ?> "><?php echo $name; ?> </a></p> <?php
{ global $acid_link; global $acid_prefix; if ($val - $max > 0) { echo "<a href=\"" . Util::get_acid_info($ip, $acid_link, $acid_prefix) . "\"><font color=\"#991e1e\">{$val}</font></a>/" . "<a href=\"{$image}\">" . intval($val * 100 / $max) . "</a>%"; } else { echo "<a href=\"" . Util::get_acid_info($ip, $acid_link, $acid_prefix) . "\">{$val}</a>/" . "<a href=\"{$image}\">" . intval($val * 100 / $max) . "</a>%"; } } /* get conf */ $conf = $GLOBALS["CONF"]; $graph_link = $conf->get_conf("graph_link"); $acid_link = $conf->get_conf("acid_link"); $acid_prefix = $conf->get_conf("event_viewer"); //$ntop_link = $conf->get_conf("ntop_link"); $ntop_links = Sensor::get_ntop_link("127.0.0.1"); $ntop_link = $ntop_links["ntop"]; $ntop_link = preg_replace("/\\/\$/", "", $ntop_link); $nagios_link = $conf->get_conf("nagios_link"); /* connect to db */ $db = new ossim_db(); $conn = $db->connect(); ?> <body> <table align="center" width="100%"> <tr> <th colspan=8><?php echo gettext("RRD global anomalies"); ?>
*/ require_once 'classes/Security.inc'; require_once 'classes/Session.inc'; require_once 'languages.inc'; Session::logcheck("MenuConfiguration", "ConfigurationUsers"); ?> <?php require_once 'ossim_acl.inc'; require_once 'ossim_db.inc'; require_once 'classes/Net.inc'; require_once 'classes/Sensor.inc'; $db = new ossim_db(); $conn = $db->connect(); $net_list = Net::get_all($conn); $sensor_list = Sensor::get_all($conn, "ORDER BY name ASC"); $pass_length_min = $conf->get_conf("pass_length_min", FALSE) ? $conf->get_conf("pass_length_min", FALSE) : 7; $pass_length_max = $conf->get_conf("pass_length_max", FALSE) ? $conf->get_conf("pass_length_max", FALSE) : 255; if ($pass_length_max < $pass_length_min || $pass_length_max < 1) { $pass_length_max = 255; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title> <?php echo gettext("OSSIM Framework"); ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <meta http-equiv="Pragma" content="no-cache"/>
private function updateSensor() { $sensor = $_SESSION['sensor']; if (empty($sensor)) { HomeView::show(); header('Location: /' . $_SESSION['base']); } elseif ($_SERVER['REQUEST_METHOD'] == 'GET') { SensorView::showUpdate(); } else { $params = $sensor->getParameters(); $params['sensor_name'] = array_key_exists('sensor_name', $_POST) ? $_POST['sensor_name'] : ''; $params['description'] = array_key_exists('description', $_POST) ? $_POST['description'] : ''; $updatedSensor = new Sensor($params); $updatedSensor->setSensorId($sensor->getSensorId()); $returnedSensor = SensorsDB::updateSensor($updatedSensor); if ($returnedSensor->getErrorCount() == 0) { // Show the Sensor View which should display the updated params SensorView::show(); header('Location: /' . $_SESSION['base'] . '/sensor/show/' . $sensor->getSensorId()); } else { // Carry over the measurements, if any $updatedSensor->setMeasurements($sensor->getMeasurements()); $_SESSION['sensor'] = $updatedSensor; SensorView::showUpdate(); } } }
$j++; } } else { $buffer .= "{title:'" . _("No Databases Found") . "', noLink:true}"; } $buffer .= "]"; echo $buffer; } else { if (preg_match("/sensors/", $key)) { $j = 0; $sensors = Sensor::get_list($conn); $buffer = "["; foreach ($sensors as $sensor) { $icon = "../../pixmaps/server.png"; $sensor_name = $sensor->get_name(); $related_assets = Sensor::get_assets($conn, $sensor_name); $s_title = Util::htmlentities($sensor_name); $s_url = urlencode($sensor_name); $title = strlen($sensor_name) > $length_name ? substr($sensor_name, 0, $length_name) . "..." : $sensor_name; $title = Util::htmlentities($title); $tooltip = $s_title; if (count($related_assets["host"]) == 0 && count($related_assets["net"]) == 0 && count($related_assets["hgroup"]) == 0 && count($related_assets["ngroup"]) == 0) { $li = "title:'{$title}', tooltip:'{$tooltip}', icon:'{$icon}', h:'{$h}', url:'../sensor/interfaces.php?sensor=" . $s_url . "&name=" . utf8_encode($sensor_name) . "'"; } else { $li = "title:'{$title}', tooltip:'{$tooltip}', icon:'{$icon}', key:'sensor_" . utf8_encode($sensor_name) . "' ,isLazy:true, h:'{$h}', url:'../sensor/interfaces.php?sensor=" . $s_url . "&name=" . utf8_encode($sensor_name) . "'"; } $buffer .= ($j > 0 ? "," : "") . "{ {$li} }"; $j++; } $buffer .= "]"; echo $buffer;
if (POST('withoutmenu') != "1") { include "../hmenu.php"; $get_param = "ip={$ip}&name=" . urlencode($sname); } else { $get_param = "ip={$ip}&name=" . urlencode($sname) . "&withoutmenu=1"; } if (POST('insert') && !empty($sname)) { if ($error == true) { $txt_error = "<div>" . _("We Found the following errors") . ":</div><div style='padding:10px;'>" . implode("<br/>", $message_error) . "</div>"; Util::print_error($txt_error); Util::make_form("POST", "modifysensorform.php?" . $get_param); die; } $db = new ossim_db(); $conn = $db->connect(); Sensor::update($conn, $sname, $ip, $priority, $port, $tzone, $descr); $db->close($conn); Util::clean_json_cache_files("sensors"); } if (isset($_SESSION['_sensor'])) { unset($_SESSION['_sensor']); } ?> <script type='text/javascript'>document.location.href="modifysensorform.php?<?php echo $get_param; ?> &update=1"</script> </body> </html>
?> " title="<?php echo $tit; ?> "><?php echo $tit2; ?> <br><img src="../pixmaps/<?php echo $graph; ?> "></a></td></tr> </table> <?php } } else { $ntop_link = Sensor::get_sensor_link($conn, $host); if ($n == 1) { $source = "{$ntop_link}/hostTimeTrafficDistribution-{$host}-65535.png?1"; $tit = $title . " " . gettext("Traffic Sent"); $tit2 = gettext("Traffic Sent"); $graph = "ntop_graph_thumb.gif"; } elseif ($n == 2) { $source = "{$ntop_link}/hostTimeTrafficDistribution-{$host}-65535.png"; $tit = $title . " " . gettext("Traffic Rcvd"); $graph = "ntop_graph_thumb.gif"; $tit2 = gettext("Traffic Rcvd"); } //echo "headers de: ".$source."<br>"; $salida = get_headers($source); //print_r($salida); if (!preg_match("/Not Found/", $salida[0]) && $salida != null) {
} } ?> </select> <?php require_once 'ossim_conf.inc'; $conf = $GLOBALS["CONF"]; if (preg_match('/\\d+\\.\\d+\\.\\d+\\.\\d+/', $sensor)) { //if (!$conf->get_conf("use_ntop_rewrite")) { // $ntop_link = "$proto://$sensor:$port"; //} else { //if use_ntop_rewrite is enabled // $protocol = "http"; // if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") $protocol = "https"; // $ntop_link = "$protocol://" . $_SERVER['SERVER_NAME'] . "/ntop_$sensor"; //} $ntop_links = Sensor::get_ntop_link($sensor); $ntop_link = $ntop_links["ntop"]; $ntop_link = preg_replace("/\\/\$/", "", $ntop_link); ?> <a href="<?php echo $ntop_link; ?> /NetNetstat.html" target="ntop"> <?php echo gettext("Reload"); ?> </a> <?php } else { if ($net_list = Net::get_list($conn, "name = '{$sensor}'")) {
<?php $data = $_GET["feed"]; include_once 'includes/dbcon.php'; include_once 'includes/sensor.php'; $SensorObj = new Sensor(); $FeedArr = explode("!", $data); // SensorCOmponentName!DeviceName!timedelay!data!data!data!data!data!data!data!data!data!data! $type = $FeedArr[0]; $name = $FeedArr[1]; $delay = $FeedArr[2]; //Foreach loop starting from 3 till end $cnt = 0; foreach ($FeedArr as $val) { if ($cnt >= 3) { $SensorObj->add_feed($type, $name, $delay, $val); } $cnt++; } // $device->add_device($mac,$ip,$type,$name,$details);