function freshports_ListOfPorts($result, $db, $ShowDateAdded, $ShowCategoryHeaders, $User, $PortCount = -1) { require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/ports.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/port-display.php'; $port_display = new port_display($db, $User); $port_display->SetDetailsReports(); $port = new Port($db); $port->LocalResult = $result; $LastCategory = ''; $GlobalHideLastChange = 'N'; $numrows = pg_numrows($result); if ($PortCount == -1) { $PortCount = $numrows; } $PortCountText = "<TR><TD>{$PortCount} ports found."; if ($numrows != $PortCount) { $PortCountText .= " (showing only {$numrows} ports on this page)"; } $PortCountText .= "</TD></TR>\n"; $HTML = $PortCountText; $HTML .= "<TR><TD>\n"; $HTML .= "<br><center>\n" . Ad_728x90() . "\n</center>\n"; if ($numrows > 0 && $ShowCategoryHeaders) { $HTML .= '<DL>'; } for ($i = 0; $i < $numrows; $i++) { $port->FetchNth($i); if ($ShowCategoryHeaders) { $Category = $port->category; if ($LastCategory != $Category) { if ($i > 0) { $HTML .= "\n</DD>\n"; } $LastCategory = $Category; if ($ShowCategoryHeaders) { $HTML .= '<DT>'; } $HTML .= '<BIG><BIG><B><a href="/' . $Category . '/">' . $Category . '</a></B></BIG></BIG>'; if ($ShowCategoryHeaders) { $HTML .= "</DT>\n<DD>"; } } } $port_display->port = $port; $Port_HTML = $port_display->Display(); $HTML .= $port_display->ReplaceWatchListToken($port->{'onwatchlist'}, $Port_HTML, $port->{'element_id'}); $HTML .= '<BR>'; } if ($numrows && $ShowCategoryHeaders) { $HTML .= "\n</DD>\n</DL>\n"; } $HTML .= "</TD></TR>\n"; $HTML .= $PortCountText; return $HTML; }
private static function buildPorts(array $env) { return array_reduce(array_keys($env), function ($linkPorts, $name) use($env) { if (preg_match("/^PORT_(?<port>[0-9]+)_(?<protocol>((TCP)|(UDP)))\$/", $name, $matches) === 1) { $linkPorts[] = Port::build($env, $matches['port'], $matches['protocol']); } return $linkPorts; }, []); }
public function check($ip, $port, $timeout = 2) { $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_set_nonblock($sock); socket_connect($sock, $ip, $port); socket_set_block($sock); self::$status = socket_select($r = array($sock), $w = array($sock), $f = array($sock), 2); return self::$status; }
public function index() { // $pass=_get('pass'); // $name=I ('get.name'); // $arr=array("xx"=>$pass,"name"=>$name,"time"=>\lib_time::gmtime()); // \Msg::outPut($arr); // $out= json_encode($arr); // exit($out); //$this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-family: "微软雅黑"; color: #333;font-size:24px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-size: 36px } a,a:hover,{color:blue;}</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>!</p><br/>版本 V{$Think.version}</div><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_55e75dfae343f5a1"></thinkad><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script>','utf-8'); $ip = "bookfuns.com"; $port = 80; echo \Port::check($ip, $port); }
public function actionAdd() { $port = Port::model()->findAll(); $this->render('add', array('port' => $port)); }
public function actionAdd_port() { $port = new Port(); $port->name = $_POST['title']; $port->area = $_POST['area']; $port->description = $_POST['content']; if (isset($_POST['source'])) { /* $t = explode(',', $_POST['source']); $id = ''; foreach($t as $a) { if($a != '') { $source = new Source; $source->source = $a; $source->save(); $id .= $source->id.','; } } */ $port->source = $_POST['source']; } if (isset($_POST['thumb'])) { /* $t = explode(',', $_POST['thumb']); $id = ''; foreach($t as $a) { if($a != '') { $thumb = new Thumb; $thumb->thumb = $a; $thumb->save(); $id .= $thumb->id.','; } } */ $port->thumb = $_POST['thumb']; } $port->save(); echo 1; }
require_once 'classes/Security.inc'; Session::logcheck("MenuPolicy", "PolicyPorts"); //Autocomplete Ports $db = new ossim_db(); $conn = $db->connect(); $ports = array(); $port_list = array(); $arr_ports_input = array(); $ports_input = ""; $update = intval(GET('update')); $style_success = "style='display: none;'"; if ($update == 1) { $success_message = gettext("Port Group succesfully updated"); $style_success = "style='display: block;text-align:center;'"; } if ($port_list = Port::get_list($conn)) { foreach ($port_list as $port) { $ports[] = $port->get_port_number() . " - " . $port->get_protocol_name(); } } foreach ($ports as $k => $v) { $arr_ports_input[] = '{ txt:"' . $v . '", id: "' . $v . '" }'; } $ports_input = implode(",", $arr_ports_input); if (isset($_SESSION['_portgroup'])) { $pgname = $_SESSION['_portgroup']['pgname']; $actives_ports = $_SESSION['_portgroup']['actives_ports']; $descr = $_SESSION['_portgroup']['descr']; unset($_SESSION['_portgroup']); } else { $pgname = GET('portname');
$h_list .= '{ txt:"' . $_ip . '", id: "' . Asset_host_ips::ip2ulong($_ip) . '" },'; } } } // Protocol list if ($protocol_list = Protocol::get_list()) { echo "var protocols = new Array(" . count($protocol_list) . ")\n"; foreach ($protocol_list as $proto) { //$_SESSION[$id] = $plugin->get_name(); echo "protocols['proto_" . $proto['id'] . "'] = '" . $proto['name'] . "'\n"; //Load available protocols (Autocompleted) $p_list .= '{ txt: "Protocol:' . $proto['name'] . '", id: "' . $proto['id'] . '" },'; } } //Port list (Autocompleted) if ($port_list = Port::get_list($conn, " AND protocol_name='tcp'")) { foreach ($port_list as $port) { $prt_list .= '{ txt:"' . $port->get_port_number() . " - " . $port->get_service() . '", id: "' . $port->get_port_number() . '" },'; } } // Plugin list $sids = array(); if ($plugin_list = Plugin::get_list($conn, "")) { echo "var plugins = new Array(" . count($plugin_list) . ")\n"; foreach ($plugin_list as $plugin) { $sids[$plugin->get_name()] = $plugin->get_id(); //$_SESSION[$id] = $plugin->get_name(); echo "plugins['id_" . $plugin->get_id() . "'] = '" . $plugin->get_name() . "';\n"; echo "plugins['id_" . $plugin->get_name() . "'] = '" . $plugin->get_name() . "';\n"; } }
public function actionRemove() { $portId = intval($_GET['portId']) ? intval($_GET['portId']) : ''; if (!$portId) { exit; } $port = Port::model()->findByPk($portId); // assuming there is a post whose ID is 10 $port->delete(); //$this->actionIndex(); $this->redirect(Yii::app()->request->urlReferrer); }
$prev = ""; $fnd = array(); if (preg_match("/(.*=)(.*\\|)(.*)/", $str, $fnd)) { $prev = $fnd[2]; $str = $fnd[1] . $fnd[3]; } $data = array(); $top = 10; $tag_typing = 0; if (trim($str) != "") { list($sensors, $hosts) = Host::get_ips_and_hostname($conn); $nets = Net::get_list($conn); $plugins = GetPlugins($conn); $sourcetypes = GetSourceTypes($conn); $plugingroups = Plugingroup::get_list($conn); $ports = Port::get_list($conn); $categories = GetPluginCategories($conn); $subcategories = GetPluginSubCategories($conn, $categories); // Typing a tag if (preg_match("/^(sensor|src|dst|plugin|datasource|plugingroup|dsgroup|src_port|dst_port|product_type|event_category|category|data)(\\!?\\=)(.*)/i", $str, $found)) { $tag_typing = 1; $str = $found[3]; $op = $found[2]; if ($str == "") { $str = "."; } $qstr = $str; if ($found[1] == "sensor") { foreach ($sensors as $ip => $name) { if ((preg_match("/^{$qstr}/i", $name) || preg_match("/^{$qstr}/i", $ip)) && !preg_match("/{$name}/i", $fnd[2]) && count($data) < $top && $current_query["sensor{$op}{$ip}"] == "") { $data[] = array("name" => "<b>sensor</b>{$op}{$prev}{$name}");
protected function renderPortConfig(Port $port) { ?> <td rowspan="<?php echo $port->nbDistant; ?> "><?php echo $port->getName(); ?> </td> <td rowspan="<?php echo $port->nbDistant; ?> "><?php $this->renderTrunk($port); ?> </td> <td rowspan="<?php echo $port->nbDistant; ?> "><?php $this->renderEnabledState($port); ?> </td> <td rowspan="<?php echo $port->nbDistant; ?> "><?php $this->renderPoEConfig($port); ?> </td> <td rowspan="<?php echo $port->nbDistant; ?> "><?php $this->renderMode($port); ?> </td> <?php }
* On Debian GNU/Linux systems, the complete text of the GNU General * Public License can be found in `/usr/share/common-licenses/GPL-2'. * * Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt * */ require_once 'av_init.php'; Session::logcheck("configuration-menu", "PolicyPorts"); $search = GET('q'); $limit = GET('limit'); $protocol = GET('protocol'); $ctx = GET('ctx'); ossim_valid($search, OSS_NOECHARS, OSS_ALPHA, OSS_SCORE, OSS_PUNC, 'illegal:' . _("search")); ossim_valid($limit, OSS_DIGIT, 'illegal:' . _("limit")); ossim_valid($protocol, OSS_LETTER, 'illegal:' . _("protocol")); ossim_valid($ctx, OSS_HEX, 'illegal:' . _("entity")); if (ossim_error()) { die; } //create filter and order $where = " AND service like '%" . $search . "%' and protocol_name = '" . $protocol . "' AND ctx = UNHEX('{$ctx}') "; $order = "order by service limit " . $limit; // connect to database $db = new ossim_db(); $conn = $db->connect(); // search ports $ports = Port::get_list($conn, $where, $order); $db->close(); foreach ($ports as $port) { echo $port->get_service() . "\n"; }
public function actionSearch() { $keyword = $_POST['keywords']; $port = $_POST['port']; $str = ''; echo header("Content-Type: text/html;charset=utf-8"); $model = NULL; if ($keyword) { $str = 'title like ' . '"' . '%' . $keyword . '%' . '"'; } if ($port) { if ($str != '') { $str .= ' and '; } $str .= ' port =' . '"' . $port . '"'; } $criteria = new CDbCriteria(); // 创建CDbCriteria对象 $criteria->condition = $str; // 设置查询条件 $model = Room::model()->findAll($criteria); $port = Port::model()->findAll(); $this->render('index', array('room' => $model, 'port' => $port)); }
<table class='transparent' width='100%'> <tr> <td class='medium' style='vertical-align:top;white-space:nowrap;text-align:left;width:1%;'> <img src='/ossim/alarm/style/img/port.png' height='15' align='absmiddle' style='padding-bottom:3px;'/> <?php echo _('Ports'); ?> </td> <td> <div id="cloud_port<?php echo $prefix; ?> " style='width:99%;text-align:center'> <?php foreach ($ports as $port => $np) { $tooltip = _('Port') . " {$port} - {$np} " . ($np == 1 ? _('Occurrence') : _('Occurrences')); $port = $port == 0 ? _('Unknown') : strtoupper(Port::port2service($conn, $port)); ?> <a href="#" class='alarm-help' style='text-decoration:none' title='<?php echo $tooltip; ?> ' rel="<?php echo $np; ?> "><?php echo $port; ?> </a> <?php } ?> </div>
public function actionAdd() { $boat = Boat::model()->findAll(); $area = Area::model()->findAll(); $company = Company::model()->findAll(); $port = Port::model()->findAll(); $continent = Continent::model()->findAll(); $this->render('add', array('boat' => $boat, 'area' => $area, 'port' => $port, 'company' => $company, 'continent' => $continent)); }
public function actionGetByPort($id) { $data = Port::find()->where(['id' => $id])->select(['id', 'device_id'])->one()->getDevice()->select(['id', 'network_id'])->one()->getNetwork()->one(); $temp = Json::encode($data); Yii::trace($temp); return $temp; }
function get_interfaces() { // returns array of interface id's (key) and interface name (value) return Port::get_device_interfaces($this->device_id); }
$datemark = $date_slices[0]; $alarm_name = ereg_replace("directive_event: ", "", $sid_name); $alarm_name = Util::translate_alarm($conn, $alarm_name, $alarm); $alarm_name_orig = $alarm_name; if ($backlog_id != 0) { $events_link = "events.php?backlog_id={$backlog_id}"; $alarm_name = $events_link; } else { $events_link = $_SERVER["SCRIPT_NAME"]; $alarm_link = Util::get_acid_pair_link($date, $alarm->get_src_ip(), $alarm->get_dst_ip()); $alarm_name = $alarm_link; } $src_ip = $alarm->get_src_ip(); $dst_ip = $alarm->get_dst_ip(); $src_port = Port::port2service($conn, $alarm->get_src_port()); $dst_port = Port::port2service($conn, $alarm->get_dst_port()); $sensors = $alarm->get_sensors(); $risk = $alarm->get_risk(); $src_link = "report/index.php?host={$src_ip}§ion=events"; $dst_link = "report/index.php?host={$dst_ip}§ion=events"; $src_name = Host::ip2hostname($conn, $src_ip); $dst_name = Host::ip2hostname($conn, $dst_ip); $event_id = $alarm->get_event_id(); $status = $alarm->get_status(); echo "\n <entry>\n <title>\n Alarm: {$alarm_name_orig} Risk: {$risk}</title>\n <id>http://" . $_SERVER['SERVER_ADDR'] . "/" . urlencode($alarm_name) . "</id>\n <link href=\"http://" . $_SERVER['SERVER_ADDR'] . "/" . urlencode($alarm_name) . "\"/>\n <summary>{$alarm_name_orig}</summary>\n <content type=\"application/xhtml+xml\" xml:space=\"preserve\">\n <div xmlns=\"http://www.w3.org/1999/xhtml\">\n <strong>Alarm:</strong> {$alarm_name_orig}<br/>\n <strong>Risk:</strong> {$risk}<br/>\n <strong>Date:</strong> {$since}<br/>\n"; foreach ($sensors as $sensor) { echo "\n <strong>Sensor:</strong>\n <a href=\"http://" . $_SERVER['SERVER_ADDR'] . "/ossim/sensor/sensor_plugins.php?sensor={$sensor}\" >{$sensor}</a>\n (" . Host::ip2hostname($conn, $sensor) . ")<br/>\n "; } echo "\n <strong>Source IP:</strong>\n <a href=\"http://" . $_SERVER['SERVER_ADDR'] . "/ossim/" . urlencode($src_link) . "\">{$src_ip}</a><br/>\n <strong>Destination IP:</strong>\n <a href=\"http://" . $_SERVER['SERVER_ADDR'] . "/ossim/" . urlencode($dst_link) . "\">{$dst_ip}</a><br/>\n </div>\n </content>\n <author>\n <name>\nOSSIM at " . $_SERVER['SERVER_ADDR'] . "\n </name>\n </author>\n <updated>" . Util::timestamp2RFC1459($alarm->get_timestamp()) . "</updated>\n </entry>\n"; } }
* */ require_once 'av_init.php'; Session::logcheck('configuration-menu', 'PolicyPorts'); $db = new ossim_db(); $conn = $db->connect(); $id = GET('id'); $id = explode('@@', $id); $port_number = $id[0]; $protocol_name = $id[1]; ossim_valid($port_number, OSS_PORT, 'illegal:' . _('Port Number')); ossim_valid($protocol_name, OSS_PROTOCOL, 'illegal:' . _("Protocol Name")); if (ossim_error()) { die(ossim_error()); } if ($port_list = Port::get_list($conn, " AND port_number='{$port_number}' and protocol_name='{$protocol_name}'")) { $port_selected = $port_list[0]; } $port = $port_selected->get_port_number(); $protocol = $port_selected->get_protocol_name(); $service = $port_selected->get_service(); $descr = $port_selected->get_descr(); $ctx = $port_selected->get_ctx(); ?> <!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 _("OSSIM Framework");
?> "/> </head> <body> <?php if ($data['status'] == 'error') { $txt_error = "<div>" . _("The following errors occurred") . ":</div>\n\t\t\t\t\t <div style='padding:2px 10px 5px 10px;'>" . implode("<br/>", $validation_errors) . "</div>"; $config_nt = array('content' => $txt_error, 'options' => array('type' => 'nf_error', 'cancel_button' => false), 'style' => 'width: 80%; margin: 20px auto; text-align: left;'); $nt = new Notification('nt_1', $config_nt); $nt->show(); Util::make_form("POST", "newportform.php"); exit; } $db = new ossim_db(); $conn = $db->connect(); Port::update($conn, $port, $protocol, $service, $descr, $ctx); Util::memcacheFlush(); $db->close(); ?> <script type='text/javascript'> if (!parent.is_lightbox_loaded(window.name)) { document.location.href="port.php?msg=updated"; } </script> </body> </html>
function freshports_PortDisplay($db, $category, $port) { global $TableWidth; global $FreshPortsTitle; global $User; require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/port-display.php'; # these two options must be the last on the line. And as such are mutually exclusive define('BYPASSCACHE', 'bypasscache=1'); # do not read the cache for display define('REFRESHCACHE', 'refreshcache=1'); # refresh the cache $BypassCache = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["REQUEST_URI"]) - strlen(BYPASSCACHE)) == BYPASSCACHE; $RefreshCache = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["REQUEST_URI"]) - strlen(REFRESHCACHE)) == REFRESHCACHE; $Debug = 0; if ($Debug) { echo 'into ' . __FILE__ . ' now' . "<br>\n"; } $PageNumber = 1; if (isset($_SERVER['REDIRECT_QUERY_STRING'])) { parse_str($_SERVER['REDIRECT_QUERY_STRING'], $query_parts); } else { $query_parts = null; } if ($Debug) { echo print_r($query_parts, true); } if (isset($query_parts['page']) && Is_Numeric($query_parts['page'])) { $PageNumber = intval($query_parts['page']); if ($PageNumber != $query_parts['page'] || $PageNumber < 1) { $PageNumber = 1; } } $port_display = new port_display($db, $User); $port_display->SetDetailsFull(); $Cache = new CachePort(); $Cache->PageSize = $User->page_size; $result = $Cache->RetrievePort($category, $port, CACHE_PORT_DETAIL, $PageNumber); if (!$result && !$BypassCache && !$RefreshCache) { if ($Debug) { echo "found something from the cache<br>\n"; } $HTML = $Cache->CacheDataGet(); # # we need to know the element_id of this port # and the whether or not it is on the person's watch list # let's create a special function for that! # $EndOfFirstLine = strpos($HTML, "\n"); if ($EndOfFirstLine == false) { die('Internal error: I was expecting an ElementID and found nothing'); } # extract the ElementID from the cache $ElementID = intval(substr($HTML, 0, $EndOfFirstLine)); if ($ElementID == 0) { syslog(LOG_ERR, "Extract of ElementID from cache failed. Is cache corrupt/deprecated? port was {$category}/{$port}"); die('sorry, I encountered a problem with the cache. Please send the URL and this message to the webmaster.'); } if ($User->id) { $OnWatchList = freshports_OnWatchList($db, $User->id, $ElementID); } else { $OnWatchList = 0; } $HTML = substr($HTML, $EndOfFirstLine + 1); } else { if ($Debug) { echo "found NOTHING in cache for '{$category}/{$port}'<br>\n"; } $HTML = ''; $port_id = freshports_GetPortID($db, $category, $port); if (!isset($port_id)) { if ($Debug) { echo "{$category}/{$port} is not a port according to freshports_GetPortID<br>\n"; } return -1; } if ($Debug) { echo "{$category}/{$port} found by freshports_GetPortID<br>"; } $MyPort = new Port($db); $MyPort->FetchByID($port_id, $User->id); $port_display->port = $MyPort; $HTML .= $port_display->Display(); $HTML .= "</TD></TR>\n</TABLE>\n\n"; $HTML .= DisplayPortCommits($MyPort, $PageNumber); # If we are not reading if (!$BypassCache || $RefreshCache) { $Cache->CacheDataSet($MyPort->{'element_id'} . "\n" . $HTML); $Cache->AddPort($MyPort->category, $MyPort->port, CACHE_PORT_DETAIL, $PageNumber); } $ElementID = $MyPort->{'element_id'}; $OnWatchList = $MyPort->{'onwatchlist'}; } # At this point, we have the port detail HTML $HTML = $port_display->ReplaceWatchListToken($OnWatchList, $HTML, $ElementID); global $ShowAds, $BannerAd; global $ShowAds; global $BannerAd; if ($ShowAds && $BannerAd) { $HTML_For_Ad = "<hr><center>\n" . Ad_728x90PortDescription() . "\n</center>\n<hr>\n"; } else { $HTML_For_Ad = ''; } $HTML = $port_display->ReplaceAdvertismentToken($HTML, $HTML_For_Ad); freshports_ConditionalGetUnix($Cache->LastModifiedGet()); header("HTTP/1.1 200 OK"); $Title = $category . "/" . $port; require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php'; freshports_Start($Title, "{$FreshPortsTitle} - new ports, applications", "FreeBSD, index, applications, ports"); ?> <?php echo freshports_MainTable(); ?> <tr><TD VALIGN="top" width="100%"> <?php echo freshports_MainContentTable(); ?> <TR> <?php echo freshports_PageBannerText("Port details"); ?> </TR> <tr><td valign="top" width="100%"> <?php echo $HTML; ?> </TD> <TD VALIGN="top" WIDTH="*" ALIGN="center"> <?php echo freshports_SideBar(); ?> </td> </TR> </TABLE> <?php echo freshports_ShowFooter(); ?> </body> </html> <?php return 0; }
private function get_files_for_device($device_id) { if (!is_numeric($device_id)) { return; } $selectedDevice = new Device($device_id); $output = "<h2>Displaying Counters for: <b>" . $selectedDevice->get_name() . "</b></h2><br>"; //print $selectedDevice->get_name() . "<br>"; $property = new Property(); if ($rrdtool = $property->get_property("path_rrdtool")) { } else { return; } if ($rrd_dir = $property->get_property("path_rrddir")) { } else { return; } $pattern = "{$rrd_dir}/fwcounters/fwcounter_deviceid" . $device_id . "_*.rrd"; $files = glob($pattern); foreach ($files as $v) { $path_parts = pathinfo($v); $fullPath = "fwcounters/" . $path_parts['basename']; $fileName = $path_parts['filename']; //(\d+)_(.+)$ $searchPattern = '/fwcounter_deviceid(\\d+)_(.+)$/'; $replacement = $selectedDevice->get_name() . ' $2'; $counterName = preg_replace($searchPattern, $replacement, $fileName); // If this is an interface-specific counter then show more info about the interface $outputPortInfo = ""; // print strtolower($counterName); //ge-0-2-5.0 $arrPortTypes = array(); $arrPortTypes[] = "fe"; $arrPortTypes[] = "ge"; $arrPortTypes[] = "xe"; $arrPortTypes[] = "et"; $interfaceName = false; foreach ($arrPortTypes as $k => $v) { $interfaceName = strstr($counterName, $v . "-"); if ($interfaceName != false) { $interfaceName = strtr($interfaceName, array('-' => '/')); $interfaceName = str_replace($v . "/", $v . "-", $interfaceName); break; } } if ($interfaceName != false) { $thisDevice = new Device($device_id); $interfaceID = $thisDevice->get_interface_id_by_name($interfaceName); if ($interfaceID) { $thisPort = new Port($interfaceID); $outputPortInfo = "<br>Port description: " . $thisPort->get_alias(); } } $output .= "<table>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan='2'><h3>RRD File: {$fileName} {$outputPortInfo} </h3></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>"; $height = 150; $width = 550; $from = "-1d"; if (isset($_GET['From'])) { $from = $_GET['From']; } $graph = "Bits Per Second"; $graph = str_replace(" ", "%20", $graph); $type = "traffic"; $type = str_replace(" ", "%20", $type); $link = "rrdgraph.php?file={$fullPath}&title=" . $fileName . " --- " . $graph . "&height=" . $height . "&width=" . $width . "&type=" . $type; $output .= "<a href='#'><img src='rrdgraph.php?file={$fullPath}&title=" . $counterName . " --- " . $graph . "&from={$from}&height={$height}&width={$width}&type={$type}'></a><br><br>"; $output .= "</td><td>"; $graph = "Unicast Packets Per Second"; $graph = str_replace(" ", "%20", $graph); $type = "unicastpkts"; $type = str_replace(" ", "%20", $type); $link = "rrdgraph.php?file={$fullPath}&title=" . $fileName . " --- " . $graph . "&height=" . $height . "&width=" . $width . "&type=" . $type; $output .= "<a href='#'><img src='rrdgraph.php?file={$fullPath}&title=" . $counterName . " --- " . $graph . "&from={$from}&height={$height}&width={$width}&type={$type}'></a><br>"; $output .= "</td></tr><br><hr>"; } return $output; }
?> </span> </td> </tr></table> </td> <!-- risk --> <?php $src_ip = $alarm->get_src_ip(); $dst_ip = $alarm->get_dst_ip(); $src_port = $alarm->get_src_port(); $dst_port = $alarm->get_dst_port(); //$src_port = Port::port2service($conn, $alarm->get_src_port()); //$dst_port = Port::port2service($conn, $alarm->get_dst_port()); $src_port = Port::port2service($conn, $src_port); $dst_port = Port::port2service($conn, $dst_port); $sensors = $alarm->get_sensors(); $risk = $alarm->get_risk(); if ($risk > 7) { echo "\n <td class='nobborder' style='text-align:center;background-color:red'>\n <b>\n <a href=\"{$events_link}\">\n <font color=\"white\">{$risk}</font>\n </a>\n </b>\n </td>\n "; } elseif ($risk > 4) { echo "\n <td class='nobborder' style='text-align:center;background-color:orange'>\n <b>\n <a href=\"{$events_link}\">\n <font color=\"black\">{$risk}</font>\n </a>\n </b>\n </td>\n "; } elseif ($risk > 2) { echo "\n <td class='nobborder' style='text-align:center;background-color:green'>\n <b>\n <a href=\"{$events_link}\">\n <font color=\"white\">{$risk}</font>\n </a>\n </b>\n </td>\n "; } else { echo "\n <td class='nobborder' style='text-align:center'><a href=\"{$events_link}\">{$risk}</a></td>\n "; } ?> <!-- end risk -->
"> <?php echo gettext("Yes"); ?> </a> <a href="port.php"> <?php echo gettext("No"); ?> </a> </p> <?php exit; } $db = new ossim_db(); $conn = $db->connect(); Port::delete($conn, $port_number, $protocol_name); $db->close(); ?> <p> <?php echo gettext("Port group deleted"); ?> </p> <p><a href="port.php"><?php echo gettext("Back"); ?> </a></p> <?php Util::memcacheFlush(); ?>
<body> <?php if ($data['status'] == 'error') { $txt_error = "<div>" . _("The following errors occurred") . ":</div>\n\t\t\t\t\t <div style='padding: 2px 10px 5px 10px;'>" . implode("<br/>", $validation_errors) . "</div>"; $config_nt = array('content' => $txt_error, 'options' => array('type' => 'nf_error', 'cancel_button' => false), 'style' => 'width: 80%; margin: 20px auto; text-align: left;'); $nt = new Notification('nt_1', $config_nt); $nt->show(); Util::make_form("POST", "newportform.php"); exit; } $db = new ossim_db(); $conn = $db->connect(); if (POST('insert')) { Port::insert($conn, $port, $protocol, $service, $descr, $ctx); Util::memcacheFlush(); } $db->close(); ?> <script type='text/javascript'> if (!parent.is_lightbox_loaded(window.name)) { document.location.href="port.php?msg=updated"; } </script> </body> </html>
} else { $list_ports[] = $ports_name; } $db = new ossim_db(); $conn = $db->connect(); $output_ajax = "["; foreach ($list_ports as $port) { if (is_numeric($port)) { if ($port < 0 && $port > 65535) { $db->close(); die("ZZZ"); } $output_ajax .= "'" . $port . "',"; continue; } $port = Port::service2port($conn, $port, $protocol); if (is_numeric($port)) { if ($port < 0 && $port > 65535) { $db->close(); die("ZZZ"); } $output_ajax .= "'" . $port . "',"; continue; } else { $db->close(); die("XXX"); } } $output_ajax = preg_replace('/,$/', '', $output_ajax); $output_ajax .= "];"; $db->close();
ossim_valid($rp, OSS_DIGIT, OSS_NULLABLE, 'illegal:' . _("rp")); if (ossim_error()) { echo "<rows>\n<page>1</page>\n<total>0</total>\n</rows>\n"; exit; } if (!empty($order)) { $order .= POST('sortorder') == "asc" ? "" : " desc"; } else { $order = "port_number"; } $start = ($page - 1) * $rp; $limit = "LIMIT {$start}, {$rp}"; $db = new ossim_db(); $conn = $db->connect(); $xml = ""; $port_list = Port::get_list($conn, " AND port_number > 0", "ORDER BY {$order} {$limit}"); if ($port_list[0]) { $total = $port_list[0]->get_foundrows(); if ($total == 0) { $total = count($port_list); } } else { $total = 0; } $xml .= "<rows>\n"; $xml .= "<page>{$page}</page>\n"; $xml .= "<total>{$total}</total>\n"; foreach ($port_list as $port) { $port_number = $port->get_port_number(); $protocol = $port->get_protocol_name(); $service = $port->get_service() == '' ? " " : $port->get_service();
case 'match': case 'tree': case 'exact': case 'soundex': fwrite($fp, date("Y-m-d H:i:s") . " {$stype} : {$method} : {$query} : {$num} : {$NumFetches} : {$deleted} : {$casesensitivity}\n"); break; default: fwrite($fp, date("Y-m-d H:i:s") . " {$stype} : {$method} : {$category}/{$port} : {$num} : {$NumFetches} : {$deleted}\n"); } fclose($fp); } else { print "Please let postmaster@freshports.org know that the search log could not be opened. This does not affect the search results.\n"; define_syslog_variables(); syslog(LOG_ERR, "FreshPorts could not open the search log file: {$logfile}"); } $Port = new Port($db); $Port->LocalResult = $result; } ?> <!-- SiteSearch Google --> <script> (function() { var cx = '015787766717316021231:u1yjof0lhkk'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); })();
if ($no_resolv || !$dst_host) { $s_dst_name = $s_dst_ip; $ctx_dst = $ctx; } elseif ($dst_host) { $s_dst_name = $dst_host->get_name(); $ctx_dst = $dst_host->get_ctx(); } // Dst icon and bold $dst_output = Asset_host::get_extended_name($conn, $geoloc, $s_dst_ip, $ctx_dst, $event_info["dst_host"], $event_info["dst_net"]); $homelan_dst = $dst_output['is_internal']; $dst_img = $dst_output['html_icon']; // Clean icon hover tiptip $s_src_link = Menu::get_menu_url("../forensics/base_stat_ipaddr.php?clear_allcriteria=1&ip={$s_src_ip}", 'analysis', 'security_events', 'security_events'); $s_dst_link = Menu::get_menu_url("../forensics/base_stat_ipaddr.php?clear_allcriteria=1&ip={$s_dst_ip}", 'analysis', 'security_events', 'security_events'); $s_src_port = $s_src_port != 0 ? ":" . Port::port2service($conn, $s_src_port) : ""; $s_dst_port = $s_dst_port != 0 ? ":" . Port::port2service($conn, $s_dst_port) : ""; // Reputation info $rep_src_icon = Reputation::getrepimg($event_info["rep_prio_src"], $event_info["rep_rel_src"], $event_info["rep_act_src"], $s_src_ip); //$rep_src_bgcolor = Reputation::getrepbgcolor($event_info["rep_prio_src"]); $rep_dst_icon = Reputation::getrepimg($event_info["rep_prio_dst"], $event_info["rep_rel_dst"], $event_info["rep_act_dst"], $s_dst_ip); //$rep_dst_bgcolor = Reputation::getrepbgcolor($event_info["rep_prio_dst"]); $c_src_homelan = $homelan_src ? 'bold alarm_netlookup' : ''; $source_link = $src_img . " <a href='{$s_src_link}' class='{$c_src_homelan}' data-title='{$s_src_ip}-{$ctx_src}' title='{$s_src_ip}'>" . $s_src_name . $s_src_port . "</a> {$rep_src_icon}"; $source_balloon = "<div id='" . $s_src_ip . ";" . $s_src_name . ";" . $event_info["src_host"] . "' ctx='{$ctx}' id2='" . $s_src_ip . ";" . $s_dst_ip . "' class='HostReportMenu'>"; $source_balloon .= $source_link; $source_balloon .= "</div>"; $c_dst_homelan = $homelan_dst ? 'bold alarm_netlookup' : ''; $dest_link = $dst_img . " <a href='{$s_dst_link}' class='{$c_dst_homelan}' data-title='{$s_dst_ip}-{$ctx_dst}' title='{$s_dst_ip}'>" . $s_dst_name . $s_dst_port . "</a> {$rep_dst_icon}"; $dest_balloon = "<div id='" . $s_dst_ip . ";" . $s_dst_name . ";" . $event_info["dst_host"] . "' ctx='{$ctx}' id2='" . $s_dst_ip . ";" . $s_src_ip . "' class='HostReportMenu'>"; $dest_balloon .= $dest_link; $dest_balloon .= "</div>";
//Formatted message $error_msg = '<div>' . _('The following errors occurred') . ":</div>\n <div style='padding: 5px;'>" . implode('<br/>', $validation_errors) . '</div>'; Util::response_bad_request($error_msg); } else { try { $db = new ossim_db(); $conn = $db->connect(); $asset_id = POST('asset_id'); $protocol = POST('s_protocol'); $protocol_name = Protocol::get_protocol_by_number($protocol); $port = POST('s_port'); $service = POST('s_name'); $ctx = Asset_host::get_ctx_by_id($conn, $asset_id); $n_ports = Port::get_list($conn, " AND port_number = {$port} and protocol_name = '{$protocol_name}'"); if (count($n_ports) == 0) { Port::insert($conn, $port, $protocol_name, $service, '', $ctx); } else { $data['status'] = 'warning'; $data['data'] = _('Warning! This port has already been added'); } $db->close(); } catch (Exception $e) { Util::response_bad_request(_('Error! Your changes could not be saved')); } } break; //Asset properties, MAC address, Software and Services //Asset properties, MAC address, Software and Services case 'new_property': case 'new_software': case 'new_service':