Changeset 906056
- Timestamp:
- 05/01/2014 04:05:11 AM (12 years ago)
- Location:
- project-force-field
- Files:
-
- 10 added
- 4 edited
-
tags/0.6.0 (added)
-
tags/0.6.0/classes (added)
-
tags/0.6.0/classes/class-base-file-manager.php (added)
-
tags/0.6.0/classes/class-base-system-manager.php (added)
-
tags/0.6.0/classes/class-force-field-rewrite-manager.php (added)
-
tags/0.6.0/classes/class-force-field.php (added)
-
tags/0.6.0/classes/class-wordpress-file-manager.php (added)
-
tags/0.6.0/classes/class-wordpress-system-manager.php (added)
-
tags/0.6.0/project-force-field.php (added)
-
tags/0.6.0/readme.txt (added)
-
trunk/classes/class-force-field-rewrite-manager.php (modified) (8 diffs)
-
trunk/classes/class-force-field.php (modified) (5 diffs)
-
trunk/project-force-field.php (modified) (1 diff)
-
trunk/readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
project-force-field/trunk/classes/class-force-field-rewrite-manager.php
r897390 r906056 49 49 private $new_login; 50 50 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 ) { 52 59 53 60 if ( null == $filename ) { … … 64 71 65 72 $this->new_login = $new_login; 73 74 $this->permalinks_enabled = $permalinks_enabled; 66 75 } 67 76 … … 74 83 * @return bool True if successful. 75 84 */ 76 public function shields_up( ) {85 public function shields_up( $optional_blocks = null ) { 77 86 78 87 $file_contents = $this->file_manager->get_file_contents( $this->filename ); 79 88 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 ); 81 90 82 91 if ( true === $file_contents ) { … … 110 119 111 120 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; 112 146 } 113 147 … … 130 164 $line_position = array_search( $rewrite_line, $force_field_lines ); 131 165 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 ) { 133 173 return true; 134 174 } … … 151 191 } 152 192 153 private function add_force_field_section_to_contents( $contents ) {193 private function add_force_field_section_to_contents( $contents, $optional_blocks = null ) { 154 194 155 195 $section_start = array_search( '# BEGIN ' . self::MARKER, $contents ); … … 159 199 } 160 200 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 163 207 array_splice( $contents, 0, 0, $ogff_sections ); 164 208 … … 193 237 ); 194 238 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 195 248 if ( is_array( $optional_blocks ) && 0 < count( $optional_blocks ) ) { 196 249 $optional_lines = array(); -
project-force-field/trunk/classes/class-force-field.php
r900620 r906056 18 18 class OG_Force_Field { 19 19 20 const VERSION = '0.6.0'; 21 22 const VERSION_OPTION = 'ogff_version'; 23 20 24 const DEFAULT_NEW_LOGIN = 'safe-entrance.php'; 21 25 … … 54 58 55 59 $this->new_login = $new_login; 60 61 // Add action to check for updates 62 add_action( 'plugins_loaded', array( $this, 'update_force_field' ) ); 56 63 57 64 // Add filters to fix the login url … … 69 76 70 77 } 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 ); 71 99 } 72 100 … … 198 226 } 199 227 228 global $wp_rewrite; 229 200 230 $filename = $this->system_manager->get_htaccess_path(); 201 231 $file_manager = $this->system_manager->get_file_manager(); 202 232 $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 ); 205 236 } 206 237 … … 362 393 delete_option( self::REVERSE_POLARITY_OPTION ); 363 394 delete_option( self::OPTIONAL_BLOCKS ); 395 delete_option( self::VERSION_OPTION ); 364 396 365 397 $timestamp = wp_next_scheduled( self::CHECK_ATTACK_TASK ); -
project-force-field/trunk/project-force-field.php
r900620 r906056 5 5 * Author: Faison Zutavern 6 6 * Author URI: http://www.orionweb.net/ 7 * Version: 0. 5.17 * Version: 0.6.0 8 8 */ 9 9 -
project-force-field/trunk/readme.txt
r900620 r906056 4 4 Requires at least: 3.8 5 5 Tested up to: 3.9 6 Stable tag: 0. 5.16 Stable tag: 0.6.0 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 26 26 * **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. 27 27 * **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. 28 29 29 30 = Future Features! = … … 77 78 == Changelog == 78 79 80 = 0.6.0 = 81 * **Enhancement**: Added protection from WordPress User Enumeration. 82 * **Enhancement**: Added code to handle upgrades to Project Force Field. 83 79 84 = 0.5.1 = 80 85 * **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. … … 86 91 87 92 == Upgrade Notice == 93 = 0.6.0 = 94 This version adds protection against WordPress User Enumeration, which hackers tend to use before attempting a brute force attack. 88 95 89 96 = 0.5.1 =
Note: See TracChangeset
for help on using the changeset viewer.