function check_server() { $ossim_conf = $GLOBALS['CONF']; if (!$ossim_conf) { $ossim_conf = new Ossim_conf(); $GLOBALS['CONF'] = $ossim_conf; } /* get the port and IP address of the server */ $address = $ossim_conf->get_conf('server_address'); $port = $ossim_conf->get_conf('server_port'); /* create socket */ $socket = socket_create(AF_INET, SOCK_STREAM, 0); if ($socket < 0) { echo _('socket_create() failed: reason: ') . socket_strerror($socket) . "\n"; } /* connect */ $result = @socket_connect($socket, $address, $port); if (!$result) { return FALSE; } return TRUE; }
function server_get_sensor_plugins($sensor_ip = "") { $ossim_conf = $GLOBALS['CONF']; if (!$ossim_conf) { $ossim_conf = new Ossim_conf(); $GLOBALS['CONF'] = $ossim_conf; } /* get the port and IP address of the server */ $address = $ossim_conf->get_conf('server_address'); $port = $ossim_conf->get_conf('server_port'); /* create socket */ $socket = socket_create(AF_INET, SOCK_STREAM, 0); if ($socket < 0) { echo _("socket_create() failed: reason: ") . socket_strerror($socket) . "\n"; } $list = array(); /* connect */ socket_set_block($socket); socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 5, 'usec' => 0)); socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 5, 'usec' => 0)); $result = @socket_connect($socket, $address, $port); if (!$result) { echo sprintf(_("Unable to connect to %s server. Please, wait until it's available again or check if it's running at %s"), Session::is_pro() ? "USM" : "OSSIM", "{$address}:{$port}"); return $list; } /* first send a connect message to server */ $in = 'connect id="1" type="web"' . "\n"; $out = ''; socket_write($socket, $in, strlen($in)); $out = @socket_read($socket, 2048, PHP_BINARY_READ); if (strncmp($out, "ok id=", 4)) { echo sprintf(_("Bad response from %s server. Please, wait until it's available again or check if it's running at %s"), Session::is_pro() ? "USM" : "OSSIM", "{$address}:{$port}"); return $list; } /* get sensor plugins from server */ $in = 'server-get-sensor-plugins id="2"' . "\n"; $out = ''; socket_write($socket, $in, strlen($in)); $pattern = '/sensor="(' . str_replace(".", "\\.", $sensor_ip) . ')" plugin_id="([^"]*)" ' . 'state="([^"]*)" enabled="([^"]*)"/'; while ($output = socket_read($socket, 2048, PHP_BINARY_READ)) { $lines = explode("\n", $output); foreach ($lines as $out) { if (preg_match($pattern, $out, $regs)) { $s['sensor'] = $regs[1]; $s['plugin_id'] = $regs[2]; $s['state'] = $regs[3]; $s['enabled'] = $regs[4]; if (!in_array($s, $list)) { $list[] = $s; } } elseif (!strncmp($out, "ok id=", 4)) { break; } } } socket_close($socket); return $list; }
} elseif ($what == 'tasks') { Session::logcheck('configuration-menu', 'AlienVaultInventory'); } else { Session::logcheck('configuration-menu', 'PolicyServers'); // Who manage server can reload server conf } // Refresh cache Util::memcacheFlush(); Util::resend_asset_dump($what); $conf = $GLOBALS['CONF']; if (!$conf) { $conf = new Ossim_conf(); $GLOBALS['CONF'] = $conf; } /* Get the port and IP address of the server */ $address = $conf->get_conf('server_address'); $port = $conf->get_conf('server_port'); /* Create socket */ $socket = @socket_create(AF_INET, SOCK_STREAM, 0); if ($socket < 0) { $error = sprintf(_("socket_create() failed: reason: %s\n"), socket_strerror($socket)); echo ossim_error($error); } /* Connect */ $result = @socket_connect($socket, $address, $port); if ($result < 0) { $error = sprintf(_("socket_connect() failed: reason: %s %s\n"), $result, socket_strerror($result)); echo ossim_error($error); } $in = 'connect id="1" type="web"' . "\n"; $out = '';
$client->auth()->logout(); } } Session::logout(); exit; } /**************************************************** **************** Configuration Data **************** ****************************************************/ $conf = $GLOBALS['CONF']; if (!$conf) { $conf = new Ossim_conf(); $GLOBALS['CONF'] = $conf; } //Google Maps Key $map_key = $conf->get_conf('google_maps_key'); if ($map_key == '') { $map_key = 'ABQIAAAAbnvDoAoYOSW2iqoXiGTpYBTIx7cuHpcaq3fYV4NM0BaZl8OxDxS9pQpgJkMv0RxjVl6cDGhDNERjaQ'; } //If user is logged, redirect to home if (Session::get_session_user() != '') { header("Location: /ossim"); exit; } $embed = REQUEST('embed'); $user = REQUEST('user'); $pass = base64_decode(REQUEST('pass')); $pass1 = base64_decode(REQUEST('pass1')); $accepted = POST('first_login'); $email = REQUEST("email"); $mobile = REQUEST("mobile");
function get_json_entities($conn) { require_once 'av_init.php'; $json_entities = NULL; $conf = $GLOBALS["CONF"]; if (!$conf) { $conf = new Ossim_conf(); } $version = $conf->get_conf("ossim_server_version", FALSE); $pro = preg_match("/pro|demo/i", $version) ? TRUE : FALSE; if ($pro) { list($entities_all, $num_entities) = Acl::get_entities($conn, '', '', FALSE, FALSE); if (is_array($entities_all) && !empty($entities_all)) { foreach ($entities_all as $entity_id) { $entity_text = $entity["name"]; $entity_id = $entity["id"]; $json_entities .= '{ txt:"' . $entity_text . '", id:"' . $entity_id . '"},'; } } } return $json_entities; }
if ($_SESSION['_user']) { $user = $_SESSION['_user']; unset($_SESSION); // destroy session to force password change session_destroy(); session_start(); $_SESSION['_backup_user'] = $user; } else { $user = $_SESSION['_backup_user']; } $conf = $GLOBALS['CONF']; if (!$conf) { $conf = new Ossim_conf(); $GLOBALS['CONF'] = $conf; } $first_login = $conf->get_conf('first_login'); $cnd_1 = !isset($user) || empty($user); $cnd_2 = $first_login == 'yes' || $first_login === 1; if ($cnd_1 || $cnd_2) { $ossim_link = $conf->get_conf('ossim_link'); $login_location = $ossim_link . '/session/login.php'; header("Location: {$login_location}"); exit; } $pass_1 = base64_decode(POST('pass1')); $pass_2 = base64_decode(POST('pass2')); $c_pass = base64_decode(POST('current_pass')); $pass_1 = Util::utf8_encode2(trim($pass_1)); $pass_2 = Util::utf8_encode2(trim($pass_2)); $c_pass = Util::utf8_encode2(trim($c_pass)); $flag = POST('flag');
* */ require_once 'av_init.php'; if (!Session::am_i_admin()) { Session::unallowed_section(NULL, 'noback'); } /**************************************************** **************** Configuration Data **************** ****************************************************/ $conf = $GLOBALS['CONF']; if (!$conf) { $conf = new Ossim_conf(); $GLOBALS['CONF'] = $conf; } //Google Maps Key $map_key = $conf->get_conf('google_maps_key'); if ($map_key == '') { $map_key = 'ABQIAAAAbnvDoAoYOSW2iqoXiGTpYBTIx7cuHpcaq3fYV4NM0BaZl8OxDxS9pQpgJkMv0RxjVl6cDGhDNERjaQ'; } $db = new ossim_db(); $conn = $db->connect(); $locations_id = GET('id') != '' ? GET('id') : POST('locations_id'); $action = $locations_id != '' ? 'modifylocations.php' : 'newlocations.php'; $sensor_id = POST('sensor'); $delete_id = POST('delete'); $ip = ''; $name = ''; $status = 1; $zoom = 1; if ($locations_id != '') { ossim_valid($locations_id, OSS_HEX, 'illegal:' . _('Location ID'));
if ($trial_days <= 0) { if (file_exists('/usr/share/ossim/www/session/trial/index.php')) { header("Location: /ossim/session/trial/index.php"); exit; } } } /**************************************************** **************** Configuration Data **************** ****************************************************/ $conf = $GLOBALS['CONF']; if (!$conf) { $conf = new Ossim_conf(); $GLOBALS['CONF'] = $conf; } $first_login = $conf->get_conf('first_login'); $first_login = $first_login == '' || $first_login === 0 || $first_login == 'no' ? 'no' : 'yes'; $disclaimer = $conf->get_conf('disclaimer'); //Password Policy $pass_length_min = $conf->get_conf('pass_length_min'); $pass_length_min = intval($pass_length_min); $pass_length_min = $pass_length_min < 7 || $pass_length_min > 255 ? 7 : $pass_length_min; $pass_length_max = $conf->get_conf('pass_length_max'); $pass_length_max = intval($pass_length_max); $pass_length_max = $pass_length_max > 255 || $pass_length_max < $pass_length_min ? 255 : $pass_length_max; $pass_expire_max = $conf->get_conf('pass_expire'); $pass_expire_max = $pass_expire_max > 0 && $pass_expire_max != 'yes' && $pass_expire_max != 'no' ? $pass_expire_max : 0; $pass_expire_max = intval($pass_expire_max); $pass_complex = $conf->get_conf('pass_complex'); $failed_retries = $conf->get_conf('failed_retries'); //Google Maps Key
Session::logcheck('configuration-menu', 'PolicyPolicy'); } else { Session::logcheck('configuration-menu', 'PolicyServers'); // Who manage server can reload server conf } // Refresh cache Util::memcacheFlush(); Util::resend_asset_dump($what); $conf = $GLOBALS['CONF']; if (!$conf) { $conf = new Ossim_conf(); $GLOBALS['CONF'] = $conf; } /* Get the port and IP address of the server */ $address = '127.0.0.1'; $port = $conf->get_conf('server_port'); /* Create socket */ $socket = @socket_create(AF_INET, SOCK_STREAM, 0); if ($socket < 0) { $error = sprintf(_("socket_create() failed: reason: %s\n"), socket_strerror($socket)); echo ossim_error($error); } /* Connect */ $result = @socket_connect($socket, $address, $port); if ($result < 0) { $error = sprintf(_("socket_connect() failed: reason: %s %s\n"), $result, socket_strerror($result)); echo ossim_error($error); } $in = 'connect id="1" type="web"' . "\n"; $out = ''; @socket_write($socket, $in, strlen($in));