Exemple #1
0
function sucuriscan_settings_general_ipdiscoverer($nonce)
{
    $params = array('TopLevelDomain' => 'Unknown', 'WebsiteHostName' => 'Unknown', 'WebsiteHostAddress' => 'Unknown', 'IsUsingCloudProxy' => 'Unknown', 'WebsiteURL' => 'Unknown', 'RemoteAddress' => '127.0.0.1', 'RemoteAddressHeader' => 'INVALID', 'DnsLookupsStatus' => 'Enabled', 'DnsLookupsSwitchText' => 'Disable', 'DnsLookupsSwitchValue' => 'disable', 'DnsLookupsSwitchCssClass' => 'button-danger');
    // Configure the DNS lookups option for reverse proxy detection.
    if ($nonce) {
        $dns_lookups = SucuriScanRequest::post(':dns_lookups', '(en|dis)able');
        if ($dns_lookups) {
            $action_d = $dns_lookups . 'd';
            $message = 'DNS lookups for reverse proxy detection <code>' . $action_d . '</code>';
            SucuriScanOption::update_option(':dns_lookups', $action_d);
            SucuriScanEvent::report_info_event($message);
            SucuriScanEvent::notify_event('plugin_change', $message);
            SucuriScanInterface::info($message);
        }
    }
    if (SucuriScanOption::is_disabled(':dns_lookups')) {
        $params['DnsLookupsStatus'] = 'Disabled';
        $params['DnsLookupsSwitchText'] = 'Enable';
        $params['DnsLookupsSwitchValue'] = 'enable';
        $params['DnsLookupsSwitchCssClass'] = 'button-success';
    }
    $proxy_info = SucuriScan::is_behind_cloudproxy(true);
    $base_domain = SucuriScan::get_domain(true);
    $params['TopLevelDomain'] = $proxy_info['http_host'];
    $params['WebsiteHostName'] = $proxy_info['host_name'];
    $params['WebsiteHostAddress'] = $proxy_info['host_addr'];
    $params['IsUsingCloudProxy'] = $proxy_info['status'] ? 'Active' : 'Not Active';
    $params['RemoteAddressHeader'] = SucuriScan::get_remote_addr_header();
    $params['RemoteAddress'] = SucuriScan::get_remote_addr();
    $params['WebsiteURL'] = SucuriScan::get_domain();
    if ($base_domain !== $proxy_info['http_host']) {
        $params['TopLevelDomain'] = sprintf('%s (%s)', $params['TopLevelDomain'], $base_domain);
    }
    return SucuriScanTemplate::get_section('settings-general-ipdiscoverer', $params);
}
Exemple #2
0
/**
 * Gather information from the server, database engine, and PHP interpreter.
 *
 * @return array A list of pseudo-variables and values that will replace them in the HTML template.
 */
function sucuriscan_server_info()
{
    global $wpdb;
    $template_variables = array('ServerInfo.Variables' => '');
    $info_vars = array('Plugin_version' => SUCURISCAN_VERSION, 'Plugin_checksum' => SUCURISCAN_PLUGIN_CHECKSUM, 'Last_filesystem_scan' => SucuriScanFSScanner::get_filesystem_runtime(true), 'Using_CloudProxy' => 'Unknown', 'Support_Reverse_Proxy' => 'Unknown', 'Host_Address' => 'Unknown', 'HTTP_Host' => 'Unknown', 'Host_Name' => 'Unknown', 'Site_URL' => 'Unknown', 'Top_Level_Domain' => 'Unknown', 'Remote_Address' => SucuriScan::get_remote_addr(), 'Remote_Address_Header' => SucuriScan::get_remote_addr_header(), 'Operating_system' => sprintf('%s (%d Bit)', PHP_OS, PHP_INT_SIZE * 8), 'Server' => 'Unknown', 'Developer_mode' => 'OFF', 'Memory_usage' => 'N/A', 'MySQL_version' => '0.0', 'SQL_mode' => 'Not set', 'PHP_version' => PHP_VERSION);
    $proxy_info = SucuriScan::is_behind_cloudproxy(true);
    $reverse_proxy = SucuriScan::support_reverse_proxy();
    $info_vars['HTTP_Host'] = $proxy_info['http_host'];
    $info_vars['Host_Name'] = $proxy_info['host_name'];
    $info_vars['Host_Address'] = $proxy_info['host_addr'];
    $info_vars['Site_URL'] = SucuriScan::get_domain();
    $info_vars['Top_Level_Domain'] = SucuriScan::get_domain(true);
    $info_vars['Using_CloudProxy'] = $proxy_info['status'] ? 'Yes' : 'No';
    $info_vars['Support_Reverse_Proxy'] = $reverse_proxy ? 'Yes' : 'No';
    if (defined('WP_DEBUG') && WP_DEBUG) {
        $info_vars['Developer_mode'] = 'ON';
    }
    if (function_exists('memory_get_usage')) {
        $info_vars['Memory_usage'] = round(memory_get_usage() / 1024 / 1024, 2) . ' MB';
    }
    if (isset($_SERVER['SERVER_SOFTWARE'])) {
        $info_vars['Server'] = SucuriScan::escape($_SERVER['SERVER_SOFTWARE']);
    }
    if ($wpdb) {
        $info_vars['MySQL_version'] = $wpdb->get_var('SELECT VERSION() AS version');
        $mysql_info = $wpdb->get_results('SHOW VARIABLES LIKE "sql_mode"');
        if (is_array($mysql_info) && !empty($mysql_info[0]->Value)) {
            $info_vars['SQL_mode'] = $mysql_info[0]->Value;
        }
    }
    $field_names = array('safe_mode', 'expose_php', 'allow_url_fopen', 'memory_limit', 'upload_max_filesize', 'post_max_size', 'max_execution_time', 'max_input_time');
    foreach ($field_names as $php_flag) {
        $php_flag_value = SucuriScan::ini_get($php_flag);
        $php_flag_name = 'PHP_' . $php_flag;
        $info_vars[$php_flag_name] = $php_flag_value ? $php_flag_value : 'N/A';
    }
    $counter = 0;
    foreach ($info_vars as $var_name => $var_value) {
        $css_class = $counter % 2 == 0 ? '' : 'alternate';
        $var_name = str_replace('_', chr(32), $var_name);
        $template_variables['ServerInfo.Variables'] .= SucuriScanTemplate::get_snippet('infosys-serverinfo', array('ServerInfo.CssClass' => $css_class, 'ServerInfo.Title' => $var_name, 'ServerInfo.Value' => $var_value));
        $counter += 1;
    }
    return SucuriScanTemplate::get_section('infosys-serverinfo', $template_variables);
}