Example #1
0
 /**
  * Retrieve a list of directories ignored.
  *
  * Retrieve a list of directory paths that will be ignored during the file
  * system scans, any sub-directory and files inside these folders will be
  * skipped automatically and will not be used to detect malware or modifications
  * in the site.
  *
  * The structure of the array returned by the function will always be composed
  * by four (4) indexes which will facilitate the execution of common conditions
  * in the implementation code.
  *
  * <ul>
  * <li>raw: Will contains the raw data retrieved from the built-in cache system.</li>
  * <li>checksums: Will contains the md5 of all the directory paths.</li>
  * <li>directories: Will contains a list of directory paths.</li>
  * <li>ignored_at_list: Will contains a list of timestamps for when the directories were ignored.</li>
  * </ul>
  *
  * @return array List of ignored directory paths.
  */
 public static function get_ignored_directories()
 {
     $response = array('raw' => array(), 'checksums' => array(), 'directories' => array(), 'ignored_at_list' => array());
     $cache = new SucuriScanCache('ignorescanning');
     $cache_lifetime = 0;
     // It is not necessary to expire this cache.
     $ignored_directories = $cache->get_all($cache_lifetime, 'array');
     if ($ignored_directories) {
         $response['raw'] = $ignored_directories;
         foreach ($ignored_directories as $checksum => $data) {
             if (array_key_exists('directory_path', $data) && array_key_exists('ignored_at', $data)) {
                 $response['checksums'][] = $checksum;
                 $response['directories'][] = $data['directory_path'];
                 $response['ignored_at_list'][] = $data['ignored_at'];
             }
         }
     }
     return $response;
 }
 public static function blockUserLogin()
 {
     if (class_exists('SucuriScanRequest') && class_exists('SucuriScanCache')) {
         $username = SucuriScanRequest::post('log');
         $password = SucuriScanRequest::post('pwd');
         if ($username !== false && $password !== false) {
             $cache = new SucuriScanCache('blockedusers');
             $blocked = $cache->getAll();
             $cache_key = md5($username);
             if (is_array($blocked) && is_string($cache_key) && array_key_exists($cache_key, $blocked)) {
                 $blocked[$cache_key]->last_attempt = time();
                 $cache->set($cache_key, $blocked[$cache_key]);
                 if (!headers_sent()) {
                     header('HTTP/1.1 403 Forbidden');
                 }
                 exit(0);
             }
         }
     }
 }