Plugin Directory

Changeset 906056


Ignore:
Timestamp:
05/01/2014 04:05:11 AM (12 years ago)
Author:
Faison
Message:

Uploading Version 0.6.0

Location:
project-force-field
Files:
10 added
4 edited

Legend:

Unmodified
Added
Removed
  • project-force-field/trunk/classes/class-force-field-rewrite-manager.php

    r897390 r906056  
    4949        private $new_login;
    5050
    51         function __construct( FZ_Base_File_Manager $file_manager, $filename, $new_login ) {
     51        /**
     52         * Are pretty permalinks enabled.
     53         *
     54         * @var boolean
     55         */
     56        private $permalinks_enabled;
     57
     58        function __construct( FZ_Base_File_Manager $file_manager, $filename, $new_login, $permalinks_enabled = true ) {
    5259
    5360            if ( null == $filename ) {
     
    6471
    6572            $this->new_login = $new_login;
     73
     74            $this->permalinks_enabled = $permalinks_enabled;
    6675        }
    6776
     
    7483         * @return bool True if successful.
    7584         */
    76         public function shields_up() {
     85        public function shields_up( $optional_blocks = null ) {
    7786
    7887            $file_contents = $this->file_manager->get_file_contents( $this->filename );
    7988
    80             $file_contents = $this->add_force_field_section_to_contents( $file_contents );
     89            $file_contents = $this->add_force_field_section_to_contents( $file_contents, $optional_blocks );
    8190
    8291            if ( true === $file_contents ) {
     
    110119
    111120            return $results;
     121        }
     122
     123        /**
     124         * An easy way to remove clear out and replace the Force Field lines in the .htaccess file.
     125         *
     126         * This function is particularly useful between version updates.
     127         *
     128         * @since 0.6.0
     129         */
     130        public function reset_shields( $optional_blocks = null ) {
     131
     132            $file_contents = $this->file_manager->get_file_contents( $this->filename );
     133
     134            $result_contents = $this->remove_force_field_section_from_contents( $file_contents );
     135
     136            if ( true === $result_contents ) {
     137                $result_contents = $file_contents;
     138            }
     139            $file_contents = $result_contents;
     140
     141            $file_contents = $this->add_force_field_section_to_contents( $file_contents, $optional_blocks );
     142
     143            $result = $this->file_manager->put_file_contents( $this->filename, $file_contents );
     144
     145            return $result;
    112146        }
    113147
     
    130164            $line_position = array_search( $rewrite_line, $force_field_lines );
    131165
    132             if ( false !== $line_position ) {
     166            $anti_enum_line = 'RewriteCond %{QUERY_STRING} ^/?author=([0-9]*)';
     167            $anti_position  = array_search( $anti_enum_line, $force_field_lines );
     168
     169            $anti_enum_good = ( false !== $anti_position && $this->permalinks_enabled )
     170                           || ( false === $anti_position && ! $this->permalinks_enabled );
     171
     172            if ( false !== $line_position && $anti_enum_good ) {
    133173                return true;
    134174            }
     
    151191        }
    152192
    153         private function add_force_field_section_to_contents( $contents ) {
     193        private function add_force_field_section_to_contents( $contents, $optional_blocks = null ) {
    154194
    155195            $section_start = array_search( '# BEGIN ' . self::MARKER, $contents );
     
    159199            }
    160200
    161             $ogff_sections = $this->generate_force_field_section_content();
    162 
     201            $ogff_sections = $this->generate_force_field_section_content( $optional_blocks );
     202
     203            if ( '' == $contents[0] ) {
     204                array_shift( $contents );
     205            }
     206           
    163207            array_splice( $contents, 0, 0, $ogff_sections );
    164208
     
    193237            );
    194238
     239            if ( $this->permalinks_enabled ) {
     240                $anti_enum = array(
     241                    'RewriteCond %{REQUEST_URI}  ^/$',
     242                    'RewriteCond %{QUERY_STRING} ^/?author=([0-9]*)',
     243                    'RewriteRule ^(.*)$ - [F]'
     244                );
     245                array_splice( $lines, 5, 0, $anti_enum );
     246            }
     247
    195248            if ( is_array( $optional_blocks ) && 0 < count( $optional_blocks ) ) {
    196249                $optional_lines = array();
  • project-force-field/trunk/classes/class-force-field.php

    r900620 r906056  
    1818    class OG_Force_Field {
    1919
     20        const VERSION = '0.6.0';
     21
     22        const VERSION_OPTION = 'ogff_version';
     23
    2024        const DEFAULT_NEW_LOGIN = 'safe-entrance.php';
    2125
     
    5458
    5559                $this->new_login = $new_login;
     60
     61                // Add action to check for updates
     62                add_action( 'plugins_loaded', array( $this, 'update_force_field' ) );
    5663
    5764                // Add filters to fix the login url
     
    6976
    7077            }
     78        }
     79
     80        /**
     81         * Run upgrade scripts if needed.
     82         *
     83         * @since 0.6.0
     84         */
     85        function update_force_field() {
     86            $last_version = get_option( self::VERSION_OPTION );
     87
     88            if ( self::VERSION == $last_version ) {
     89                return;
     90            }
     91
     92            if ( false === $last_version ) {
     93                // Update for versions pre-0.6.0
     94                $this->setup_rewrite_manager();
     95                $this->rewrite_manager->reset_shields();
     96            }
     97
     98            update_option( self::VERSION_OPTION, self::VERSION );
    7199        }
    72100
     
    198226            }
    199227
     228            global $wp_rewrite;
     229
    200230            $filename     = $this->system_manager->get_htaccess_path();
    201231            $file_manager = $this->system_manager->get_file_manager();
    202232            $login        = $this->get_new_login();
    203 
    204             $this->rewrite_manager = new OG_Force_Field_Rewrite_Manager( $file_manager, $filename, $login );
     233            $permalinks   = ( '' !== $wp_rewrite->permalink_structure );
     234
     235            $this->rewrite_manager = new OG_Force_Field_Rewrite_Manager( $file_manager, $filename, $login, $permalinks );
    205236        }
    206237
     
    362393            delete_option( self::REVERSE_POLARITY_OPTION );
    363394            delete_option( self::OPTIONAL_BLOCKS );
     395            delete_option( self::VERSION_OPTION );
    364396
    365397            $timestamp = wp_next_scheduled( self::CHECK_ATTACK_TASK );
  • project-force-field/trunk/project-force-field.php

    r900620 r906056  
    55 * Author: Faison Zutavern
    66 * Author URI: http://www.orionweb.net/
    7  * Version: 0.5.1
     7 * Version: 0.6.0
    88 */
    99
  • project-force-field/trunk/readme.txt

    r900620 r906056  
    44Requires at least: 3.8
    55Tested up to: 3.9
    6 Stable tag: 0.5.1
     6Stable tag: 0.6.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2626* **Unlimited polarity shifts** - If a Brute Force Attacker gets smart and writes a script to check for the new login url, Project Force Field will continue to detect the attack and change the login.
    2727* **Define the login yourself** - By defining `OGFF_LOGIN` in your wp-config.php, you can set the login to be *almost* anything you want.
     28* **Stops WordPress User Enumeration Exploit** - Many brute force attacks use the WordPress User Enumeration exploit to easily figure out valid usernames. We stop that to protect your site, and respond with a 403 to save your server.
    2829
    2930= Future Features! =
     
    7778== Changelog ==
    7879
     80= 0.6.0 =
     81* **Enhancement**: Added protection from WordPress User Enumeration.
     82* **Enhancement**: Added code to handle upgrades to Project Force Field.
     83
    7984= 0.5.1 =
    8085* **Bugfix**: Prefixed the variable `$new_login` in the file `project-force-field.php` with `ogff_` to avoid potential conflicts with other plugins, themes, or custom code.
     
    8691
    8792== Upgrade Notice ==
     93= 0.6.0 =
     94This version adds protection against WordPress User Enumeration, which hackers tend to use before attempting a brute force attack.
    8895
    8996= 0.5.1 =
Note: See TracChangeset for help on using the changeset viewer.