Ejemplo n.º 1
0
 /**
  * Send a request to recover a previously registered API key.
  *
  * @return boolean true if the API key was sent to the administrator email, false otherwise.
  */
 public static function recover_key()
 {
     $clean_domain = self::get_domain();
     $response = self::api_call_wordpress('GET', array('e' => self::get_site_email(), 's' => $clean_domain, 'a' => 'recover_key'), false);
     if (self::handle_response($response)) {
         SucuriScanEvent::notify_event('plugin_change', 'API key recovered for domain: ' . $clean_domain);
         SucuriScanInterface::info($response['body']->output->message);
         return true;
     }
     return false;
 }
 private function trigger($slug, $message, $level = 'error', $prefix = '')
 {
     if (empty($prefix)) {
         $prefix = $this->prefix;
     }
     // Trigger fail2ban
     $error_msg = sprintf('%s%s %s', $prefix, $slug, $this->esc_log($message));
     $this->enhanced_error_log($error_msg, $level);
     // Report to Sucuri Scan
     if (class_exists('SucuriScanEvent')) {
         if (true !== SucuriScanEvent::report_critical_event($error_msg)) {
             error_log('Sucuri Scan report event failure.');
         }
     }
     // Report to Simple History
     if (function_exists('SimpleLogger')) {
         $simple_level = $this->translate_apache_level($level);
         $context = array('_security' => 'WordPress fail2ban', '_server_request_method' => $this->esc_log($_SERVER['REQUEST_METHOD']));
         if (array_key_exists('HTTP_USER_AGENT', $_SERVER)) {
             $context['_server_http_user_agent'] = $this->esc_log($_SERVER['HTTP_USER_AGENT']);
         }
         if (!class_exists('SimpleLogger')) {
             SimpleHistory::get_instance()->load_loggers();
         }
         SimpleLogger()->log($simple_level, $error_msg, $context);
     }
 }
Ejemplo n.º 3
0
 public static function timeoutPage($nonce)
 {
     $params = array();
     // Update the SiteCheck timeout.
     if ($nonce) {
         $timeout = (int) SucuriScanRequest::post(':sitecheck_timeout', '[0-9]+');
         if ($timeout > 0) {
             if ($timeout <= SUCURISCAN_MAX_SITECHECK_TIMEOUT) {
                 $message = 'SiteCheck timeout set to <code>' . $timeout . '</code> seconds.';
                 SucuriScanOption::update_option(':sitecheck_timeout', $timeout);
                 SucuriScanEvent::report_info_event($message);
                 SucuriScanEvent::notify_event('plugin_change', $message);
                 SucuriScanInterface::info($message);
             } else {
                 SucuriScanInterface::error('SiteCheck timeout in seconds is too high.');
             }
         }
     }
     $params['MaxRequestTimeout'] = SUCURISCAN_MAX_SITECHECK_TIMEOUT;
     $params['RequestTimeout'] = SucuriScanOption::get_option(':sitecheck_timeout') . ' seconds';
     return SucuriScanTemplate::getSection('settings-sitecheck-timeout', $params);
 }
Ejemplo n.º 4
0
 /**
  * Log and report mail sending errors.
  *
  * @return void
  */
 public function handle_error()
 {
     if (!is_null($this->phpmailer) && property_exists($this->phpmailer, 'ErrorInfo') && !empty($this->phpmailer->ErrorInfo)) {
         $error_message = sprintf('SMTP error: %s', $this->esc_log($this->phpmailer->ErrorInfo));
         error_log($error_message);
         if (class_exists('SucuriScanEvent')) {
             if (true !== SucuriScanEvent::report_critical_event($error_message)) {
                 error_log('Sucuri Scan report event failure.');
             }
         }
     }
 }