PageRenderTime 288ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 1ms

/wp-content/plugins/bulletproof-security/admin/options.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 2318 lines | 2024 code | 150 blank | 144 comment | 274 complexity | a2bd079aa25cc7afa3ded71f8a352628 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, GPL-3.0, LGPL-2.0, AGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. // Direct calls to this file are Forbidden when core files are not present
  3. if ( !function_exists('add_action') ){
  4. header('Status: 403 Forbidden');
  5. header('HTTP/1.1 403 Forbidden');
  6. exit();
  7. }
  8. if ( !current_user_can('manage_options') ){
  9. header('Status: 403 Forbidden');
  10. header('HTTP/1.1 403 Forbidden');
  11. exit();
  12. }
  13. ?>
  14. <div id="message" class="updated" style="border:1px solid #999999; margin-left:70px; margin-top:9px;">
  15. <?php
  16. // HUD - Heads Up Display - Warnings and Error messages
  17. echo bps_check_php_version_error();
  18. echo bps_check_permalinks_error();
  19. echo bps_check_iis_supports_permalinks();
  20. echo bps_hud_check_bpsbackup();
  21. echo bps_check_safemode();
  22. echo @bps_w3tc_htaccess_check($plugin_var);
  23. echo @bps_wpsc_htaccess_check($plugin_var);
  24. // Form - copy and rename htaccess file to root folder
  25. // BulletProof Security and Default Mode
  26. $bpsecureroot = 'unchecked';
  27. $bpdefaultroot = 'unchecked';
  28. if (isset($_POST['submit12']) && current_user_can('manage_options')) {
  29. check_admin_referer( 'bulletproof_security_root_copy' );
  30. $old = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/default.htaccess';
  31. $new = ABSPATH . '/.htaccess';
  32. $old1 = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/secure.htaccess';
  33. $new1 = ABSPATH . '/.htaccess';
  34. $selected_radio = $_POST['selection12'];
  35. if ($selected_radio == 'bpsecureroot') {
  36. $bpsecureroot = 'checked';
  37. @copy($old1, $new1);
  38. chmod($new1, 0644);
  39. if (!copy($old1, $new1)) {
  40. _e('<font color="red"><strong>Failed to Activate BulletProof Security Root Folder Protection! Your Website is NOT protected with BulletProof Security!</strong></font><br>');
  41. } else {
  42. _e('<font color="green"><strong>BulletProof Security Root Folder Protection Activated. Your website Root folder is now protected with BulletProof Security.</strong></font><br><font color="red"><strong>IMPORTANT!</strong></font><strong> BulletProof Mode for the wp-admin folder MUST also be activated when you have BulletProof Mode activated for the Root folder.</strong><br>');
  43. }
  44. }
  45. elseif ($selected_radio == 'bpdefaultroot') {
  46. $bpdefaultroot = 'checked';
  47. copy($old, $new);
  48. chmod($new, 0644);
  49. if (!copy($old, $new)) {
  50. _e('<font color="red"><strong>Failed to Activate Default .htaccess Mode!</strong></font><br>');
  51. } else {
  52. _e('<font color="red"><strong>Warning: Default .htaccess Mode Is Activated In Your Website Root Folder. Your Website Is Not Protected With BulletProof Security.</strong></font>');
  53. }
  54. }
  55. }
  56. // Form - copy and rename htaccess file to wp-admin folder
  57. // BulletProof Security wp-admin
  58. $bpsecurewpadmin = 'unchecked';
  59. $Removebpsecurewpadmin = 'unchecked';
  60. if (isset($_POST['submit13']) && current_user_can('manage_options')) {
  61. check_admin_referer( 'bulletproof_security_wpadmin_copy' );
  62. $oldadmin1 = ABSPATH . 'wp-content/plugins/bulletproof-security/admin/htaccess/wpadmin-secure.htaccess';
  63. $newadmin1 = ABSPATH . 'wp-admin/.htaccess';
  64. $deleteWpadminHtaccess = ABSPATH . 'wp-admin/.htaccess';
  65. $selected_radio = $_POST['selection13'];
  66. if ($selected_radio == 'bpsecurewpadmin') {
  67. $bpsecurewpadmin = 'checked';
  68. copy($oldadmin1, $newadmin1);
  69. chmod($newadmin1, 0644);
  70. if (!copy($oldadmin1, $newadmin1)) {
  71. _e('<font color="red"><strong>Failed to Activate BulletProof Security wp-admin Folder Protection! Your wp-admin folder is NOT protected with BulletProof Security!</strong></font><br>');
  72. } else {
  73. _e('<font color="green"><strong>BulletProof Security wp-admin Folder Protection Activated. Your wp-admin folder is now protected with BulletProof Security.</strong></font>');
  74. }
  75. }
  76. elseif ($selected_radio == 'Removebpsecurewpadmin') {
  77. $Removebpsecurewpadmin = 'checked';
  78. $fh = fopen($deleteWpadminHtaccess, 'a');
  79. fwrite($fh, 'delete');
  80. fclose($fh);
  81. unlink($deleteWpadminHtaccess);
  82. if (file_exists($deleteWpadminHtaccess)) {
  83. _e('<font color="red"><strong>Failed to Delete the wp-admin .htaccess file! The file does not exist. It may have been deleted or renamed already.</strong></font><br>');
  84. } else {
  85. _e('<font color="green"><strong>The wp-admin .htaccess file has been Deleted. </strong></font><font color="red"><strong>Your wp-admin folder is no longer .htaccess protected.</strong></font> If you are testing then be sure to reactivate BulletProof Mode for your wp-admin folder when you are done testing. If you are removing BPS from your website then be sure to also Activate Default Mode for your Root folder. The Root and wp-admin BulletProof Modes must be activated together or removed togeher.</strong></font><br>');
  86. }
  87. }
  88. }
  89. // Form rename Deny All htaccess file to .htaccess for the BPS Master htaccess folder
  90. $bps_rename_htaccess_files = 'unchecked';
  91. if (isset($_POST['submit8']) && current_user_can('manage_options')) {
  92. check_admin_referer( 'bulletproof_security_denyall_master' );
  93. $bps_rename_htaccess = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/deny-all.htaccess';
  94. $bps_rename_htaccess_renamed = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/.htaccess';
  95. $selected_radio = $_POST['selection8'];
  96. if ($selected_radio == 'bps_rename_htaccess_files') {
  97. $bps_rename_htaccess_files = 'checked';
  98. copy($bps_rename_htaccess, $bps_rename_htaccess_renamed);
  99. if (!copy($bps_rename_htaccess, $bps_rename_htaccess_renamed)) {
  100. _e('<font color="red"><strong>Failed to Activate BulletProof Security Deny All Folder Protection! Your BPS Master htaccess folder is NOT Protected with Deny All htaccess folder protection!</strong></font><br>');
  101. } else {
  102. _e('BulletProof Security Deny All Folder Protection <font color="green"><strong>Activated.</strong></font> Your BPS Master htaccess folder is Now Protected with Deny All htaccess folder protection.');
  103. }
  104. }
  105. }
  106. // Form copy and rename the Deny All htaccess file to the BPS backup folder
  107. // /wp-content/bps-backup
  108. $bps_rename_htaccess_files_backup = 'unchecked';
  109. if (isset($_POST['submit14']) && current_user_can('manage_options')) {
  110. check_admin_referer( 'bulletproof_security_denyall_bpsbackup' );
  111. $bps_rename_htaccess_backup = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/deny-all.htaccess';
  112. $bps_rename_htaccess_backup_online = ABSPATH . '/wp-content/bps-backup/.htaccess';
  113. $selected_radio = $_POST['selection14'];
  114. if ($selected_radio == 'bps_rename_htaccess_files_backup') {
  115. $bps_rename_htaccess_files_backup = 'checked';
  116. copy($bps_rename_htaccess_backup, $bps_rename_htaccess_backup_online);
  117. if (!copy($bps_rename_htaccess_backup, $bps_rename_htaccess_backup_online)) {
  118. _e('<font color="red"><strong>Failed to Activate BulletProof Security Deny All Folder Protection! Your BPS /wp-content/bps-backup folder is NOT Protected with Deny All htaccess folder protection!</strong></font><br>');
  119. } else {
  120. _e('BulletProof Security Deny All Folder Protection <font color="green"><strong>Activated.</strong></font> Your BPS /wp-content/bps-backup folder is Now Protected with Deny All htaccess folder protection.');
  121. }
  122. }
  123. }
  124. // Form - Backup and rename existing and / or currently active htaccess files from
  125. // the root and wpadmin folders to /wp-content/bps-backup
  126. $backup_htaccess = 'unchecked';
  127. if (isset($_POST['submit9']) && current_user_can('manage_options')) {
  128. check_admin_referer( 'bulletproof_security_backup_active_htaccess_files' );
  129. $old_backroot = ABSPATH . '/.htaccess';
  130. $new_backroot = ABSPATH . '/wp-content/bps-backup/root.htaccess';
  131. $old_backwpadmin = ABSPATH . '/wp-admin/.htaccess';
  132. $new_backwpadmin = ABSPATH . '/wp-content/bps-backup/wpadmin.htaccess';
  133. $selected_radio = $_POST['selection9'];
  134. if ($selected_radio == 'backup_htaccess') {
  135. $backup_htaccess = 'checked';
  136. if ( !file_exists($old_backroot)) {
  137. _e('<font color="red"><strong>You do not currently have an .htaccess file in your Root folder to backup.</strong></font><br>');
  138. } else {
  139. if (file_exists($old_backroot)) {
  140. copy($old_backroot, $new_backroot);
  141. if (!copy($old_backroot, $new_backroot)) {
  142. _e('<font color="red"><strong>Failed to Backup Your Root .htaccess File! File copy function failed. Check the folder permissions for the /wp-content/bps-backup folder. Folder permissions should be set to 755.</strong></font><br><br>');
  143. } else {
  144. _e('<font color="green"><strong>Your currently active Root .htaccess file has been backed up successfully!</strong></font><br>Use the Restore feature to restore your .htaccess files if you run into a problem at any time. If you make additional changes or install a plugin that writes to the htaccess files then back them up again. This will overwrite the currently backed up htaccess files. Please read the <font color="red"><strong>CAUTION:</strong></font> Read Me ToolTip on the Backup & Restore Page for more detailed information.<br><br>');
  145. if ( !file_exists($old_backwpadmin)) {
  146. _e('<font color="red"><strong>You do not currently have an .htaccess file in your wp-admin folder to backup.</strong></font><br>');
  147. } else {
  148. if (file_exists($old_backwpadmin)) {
  149. copy($old_backwpadmin, $new_backwpadmin);
  150. if (!copy($old_backwpadmin, $new_backwpadmin)) {
  151. _e('<font color="red"><strong>Failed to Backup Your wp-admin .htaccess File! File copy function failed. Check the folder permissions for the /wp-content/bps-backup folder. Folder permissions should be set to 755.</strong></font><br>');
  152. } else {
  153. _e('<font color="green"><strong>Your currently active wp-admin .htaccess file has been backed up successfully!</strong></font><br>');
  154. }
  155. }}}}}}}
  156. // Form - Restore backed up htaccess files
  157. $restore_htaccess = 'unchecked';
  158. if (isset($_POST['submit10']) && current_user_can('manage_options')) {
  159. check_admin_referer( 'bulletproof_security_restore_active_htaccess_files' );
  160. $old_restoreroot = ABSPATH . '/wp-content/bps-backup/root.htaccess';
  161. $new_restoreroot = ABSPATH . '/.htaccess';
  162. $old_restorewpadmin = ABSPATH . '/wp-content/bps-backup/wpadmin.htaccess';
  163. $new_restorewpadmin = ABSPATH . '/wp-admin/.htaccess';
  164. $selected_radio = $_POST['selection10'];
  165. if ($selected_radio == 'restore_htaccess') {
  166. $restore_htaccess = 'checked';
  167. if (file_exists($old_restoreroot)) {
  168. copy($old_restoreroot, $new_restoreroot);
  169. if (!copy($old_restoreroot, $new_restoreroot)) {
  170. _e('<font color="red"><strong>Failed to Restore Your Root .htaccess File! This is most likely because you DO NOT currently have a Backed up Root .htaccess file.</strong></font><br>');
  171. } else {
  172. _e('<font color="green"><strong>Your Root .htaccess file has been Restored successfully!</strong></font><br>');
  173. if (file_exists($old_restorewpadmin)) {
  174. copy($old_restorewpadmin, $new_restorewpadmin);
  175. if (!copy($old_restorewpadmin, $new_restorewpadmin)) {
  176. _e('<font color="red"><strong>Failed to Restore Your wp-admin .htaccess File! This is most likely because you DO NOT currently have a Backed up wp-admin .htaccess file.</strong></font><br>');
  177. } else {
  178. _e('<font color="green"><strong>Your wp-admin .htaccess file has been Restored successfully!</strong></font><br>');
  179. }
  180. }}}}}
  181. // Form - Backup the BPS Master Files to /wp-content/bps-backup/master-backups
  182. $backup_master_htaccess_files = 'unchecked';
  183. if (isset($_POST['submit11']) && current_user_can('manage_options')) {
  184. check_admin_referer( 'bulletproof_security_backup_master_htaccess_files' );
  185. $default_master = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/default.htaccess';
  186. $default_master_backup = ABSPATH . '/wp-content/bps-backup/master-backups/backup_default.htaccess';
  187. $secure_master = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/secure.htaccess';
  188. $secure_master_backup = ABSPATH . '/wp-content/bps-backup/master-backups/backup_secure.htaccess';
  189. $wpadmin_master = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/wpadmin-secure.htaccess';
  190. $wpadmin_master_backup = ABSPATH . '/wp-content/bps-backup/master-backups/backup_wpadmin-secure.htaccess';
  191. $maintenance_master = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/maintenance.htaccess';
  192. $maintenance_master_backup = ABSPATH . '/wp-content/bps-backup/master-backups/backup_maintenance.htaccess';
  193. $bp_maintenance_master = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/bp-maintenance.php';
  194. $bp_maintenance_master_backup = ABSPATH . '/wp-content/bps-backup/master-backups/backup_bp-maintenance.php';
  195. $bps_maintenance_values = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/bps-maintenance-values.php';
  196. $bps_maintenance_values_backup = ABSPATH . '/wp-content/bps-backup/master-backups/backup_bps-maintenance-values.php';
  197. $selected_radio = $_POST['selection11'];
  198. if ($selected_radio == 'backup_master_htaccess_files') {
  199. $backup_master_htaccess_files = 'checked';
  200. if (file_exists($default_master)) {
  201. copy($default_master, $default_master_backup);
  202. if (!copy($default_master, $default_master_backup)) {
  203. _e('<font color="red"><strong>Failed to Backup Your default.htaccess File!</strong></font><br>');
  204. } else {
  205. _e('<font color="green"><strong>The default.htaccess file has been backed up successfully!</strong></font><br>');
  206. }
  207. if (file_exists($secure_master)) {
  208. copy($secure_master, $secure_master_backup);
  209. if (!copy($secure_master, $secure_master_backup)) {
  210. _e('<font color="red"><strong>Failed to Backup Your secure.htaccess File!</strong></font><br>');
  211. } else {
  212. _e('<font color="green"><strong>The secure.htaccess file has been backed up successfully!</strong></font><br>');
  213. }
  214. if (file_exists($wpadmin_master)) {
  215. copy($wpadmin_master, $wpadmin_master_backup);
  216. if (!copy($wpadmin_master, $wpadmin_master_backup)) {
  217. _e('<font color="red"><strong>Failed to Backup Your wpadmin-secure.htaccess File!</strong></font><br>');
  218. } else {
  219. _e('<font color="green"><strong>The wpadmin-secure.htaccess file has been backed up successfully!</strong></font><br>');
  220. }
  221. if (file_exists($maintenance_master)) {
  222. copy($maintenance_master, $maintenance_master_backup);
  223. if (!copy($maintenance_master, $maintenance_master_backup)) {
  224. _e('<font color="red"><strong>Failed to Backup Your maintenance.htaccess File!</strong></font><br>');
  225. } else {
  226. _e('<font color="green"><strong>The maintenance.htaccess file has been backed up successfully!</strong></font><br>');
  227. }
  228. if (file_exists($bp_maintenance_master)) {
  229. copy($bp_maintenance_master, $bp_maintenance_master_backup);
  230. if (!copy($bp_maintenance_master, $bp_maintenance_master_backup)) {
  231. _e('<font color="red"><strong>Failed to Backup Your bp-maintenance.php File!</strong></font><br>');
  232. } else {
  233. _e('<font color="green"><strong>The bp-maintenance.php file has been backed up successfully!</strong></font><br>');
  234. }
  235. if (file_exists($bps_maintenance_values)) {
  236. copy($bps_maintenance_values, $bps_maintenance_values_backup);
  237. if (!copy($bps_maintenance_values, $bps_maintenance_values_backup)) {
  238. _e('<font color="red"><strong>Failed to Backup Your bps-maintenance-values.php File!</strong></font><br>');
  239. } else {
  240. _e('<font color="green"><strong>The bps-maintenance-values.php file has been backed up successfully!</strong></font><br>');
  241. }
  242. }}}}}}}}
  243. // Form - Activate Maintenance Mode copy and rename maintenance htaccess, bp-maintenance.php and bps-maintenance-values.php to root
  244. $bpmaintenance = 'unchecked';
  245. if (isset($_POST['submit15']) && current_user_can('manage_options')) {
  246. check_admin_referer( 'bulletproof_security_maintenance_copy' );
  247. $oldmaint = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/maintenance.htaccess';
  248. $newmaint = ABSPATH . '/.htaccess';
  249. $oldmaint1 = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/bp-maintenance.php';
  250. $newmaint1 = ABSPATH . '/bp-maintenance.php';
  251. $oldmaint_values = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/bps-maintenance-values.php';
  252. $newmaint_values = ABSPATH . '/bps-maintenance-values.php';
  253. $selected_radio = $_POST['selection15'];
  254. if ($selected_radio == 'bpmaintenance') {
  255. $bpmaintenance = 'checked';
  256. copy($oldmaint, $newmaint);
  257. copy($oldmaint1, $newmaint1);
  258. copy($oldmaint_values, $newmaint_values);
  259. if (!copy($oldmaint, $newmaint)) {
  260. _e('<p><font color="red"><strong>Failed to Activate Maintenance Mode! Your Website is NOT in Maintenance Mode!<br>If your Root .htaccess file is locked you must unlock it first before activating Maintenance Mode.</strong></font></p>');
  261. } else {
  262. _e('<font color="red"><strong>Warning: </strong></font>Maintenance Mode Is Activated. Your website is now displaying the Website Under Maintenance page to everyone except you. To switch out of Maintenance mode activate BulletProof Security Mode. You can log in and out of your Dashboard / WordPress website in Maintenance Mode as long as your current IP address does not change. If your current IP address changes you will have to FTP to your website and delete the .htaccess file in your website root folder (or download the .htaccess file and add your new IP address and upload it back to your root website folder) to be able to log back into your WordPress Dashboard. Your ISP provides your current Public IP address. If you reboot your computer or disconnect from the Internet there is a good chance that you will get a new Public IP address from your ISP.');
  263. }
  264. }
  265. }
  266. // Create maintenance htaccess file
  267. if (isset($_POST['bps-auto-write-maint']) && current_user_can('manage_options')) {
  268. check_admin_referer( 'bulletproof_security_auto_write_maint' );
  269. $bps_string_replace_maint = array(".");
  270. $bps_get_IP_maint = str_replace($bps_string_replace_maint, "\.", $_SERVER['REMOTE_ADDR']) . "$";
  271. $bps_get_wp_root_maint = bps_wp_get_root_folder();
  272. $bps_auto_write_maint_file = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/maintenance.htaccess';
  273. $bps_maint_content = "# BULLETPROOF .46.6 MAINTENANCE .HTACCESS \n
  274. RewriteEngine On
  275. RewriteBase $bps_get_wp_root_maint\n
  276. RewriteCond %{REQUEST_METHOD} ^(HEAD|TRACE|DELETE|TRACK|DEBUG) [NC]
  277. RewriteRule ^(.*)$ - [F,L]\n
  278. # ALLOW THUMBNAILER SCRIPTS TO DISPLAY IMAGES
  279. RewriteCond %{REQUEST_FILENAME} thumb.php [NC,OR]
  280. RewriteCond %{REQUEST_FILENAME} thumbs.php [NC,OR]
  281. RewriteCond %{REQUEST_FILENAME} timthumb.php [NC,OR]
  282. RewriteCond %{REQUEST_FILENAME} phpthumb.php [NC]
  283. RewriteRule . - [F,L]\n
  284. # BPSQSE BPS QUERY STRING EXPLOITS
  285. RewriteCond %{HTTP_USER_AGENT} (libwww-perl|wget|python|nikto|curl|scan|java|winhttp|clshttp|loader) [NC,OR]
  286. RewriteCond %{HTTP_USER_AGENT} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
  287. RewriteCond %{HTTP_USER_AGENT} (;|<|>|'|".'"'."|\)|\(|%0A|%0D|%22|%27|%28|%3C|%3E|%00).*(libwww-perl|wget|python|nikto|curl|scan|java|winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner) [NC,OR]
  288. RewriteCond %{THE_REQUEST} \?\ HTTP/ [NC,OR]
  289. RewriteCond %{THE_REQUEST} \/\*\ HTTP/ [NC,OR]
  290. RewriteCond %{THE_REQUEST} etc/passwd [NC,OR]
  291. RewriteCond %{THE_REQUEST} cgi-bin [NC,OR]
  292. RewriteCond %{THE_REQUEST} (\\r|\\n|%0A|%0D) [NC,OR]
  293. RewriteCond %{REQUEST_URI} owssvr\.dll [NC,OR]
  294. RewriteCond %{HTTP_REFERER} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
  295. RewriteCond %{HTTP_REFERER} \.opendirviewer\. [NC,OR]
  296. RewriteCond %{HTTP_REFERER} users\.skynet\.be.* [NC,OR]
  297. RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR]
  298. RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR]
  299. RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=/([a-z0-9_.]//?)+ [NC,OR]
  300. RewriteCond %{QUERY_STRING} \=PHP[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} [NC,OR]
  301. RewriteCond %{QUERY_STRING} \.\./\.\. [OR]
  302. RewriteCond %{QUERY_STRING} ftp\: [NC,OR]
  303. RewriteCond %{QUERY_STRING} http\: [NC,OR]
  304. RewriteCond %{QUERY_STRING} https\: [NC,OR]
  305. RewriteCond %{QUERY_STRING} \=\|w\| [NC,OR]
  306. RewriteCond %{QUERY_STRING} ^(.*)/self/(.*)$ [NC,OR]
  307. RewriteCond %{QUERY_STRING} ^(.*)cPath=http://(.*)$ [NC,OR]
  308. RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
  309. RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
  310. RewriteCond %{QUERY_STRING} (\<|%3C).*iframe.*(\>|%3E) [NC,OR]
  311. RewriteCond %{QUERY_STRING} (<|%3C)([^i]*i)+frame.*(>|%3E) [NC,OR]
  312. RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [NC,OR]
  313. RewriteCond %{QUERY_STRING} base64_(en|de)code[^(]*\([^)]*\) [NC,OR]
  314. RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
  315. RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) [OR]
  316. RewriteCond %{QUERY_STRING} ^.*(\[|\]|\(|\)|<|>).* [NC,OR]
  317. RewriteCond %{QUERY_STRING} (NULL|OUTFILE|LOAD_FILE) [OR]
  318. RewriteCond %{QUERY_STRING} (\./|\../|\.../)+(motd|etc|bin) [NC,OR]
  319. RewriteCond %{QUERY_STRING} (localhost|loopback|127\.0\.0\.1) [NC,OR]
  320. RewriteCond %{QUERY_STRING} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
  321. RewriteCond %{QUERY_STRING} concat[^\(]*\( [NC,OR]
  322. RewriteCond %{QUERY_STRING} union([^s]*s)+elect [NC,OR]
  323. RewriteCond %{QUERY_STRING} union([^a]*a)+ll([^s]*s)+elect [NC,OR]
  324. RewriteCond %{QUERY_STRING} (;|<|>|'|".'"'."|\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\*|union|select|insert|drop|delete|update|cast|create|char|convert|alter|declare|order|script|set|md5|benchmark|encode) [NC,OR]
  325. RewriteCond %{QUERY_STRING} (sp_executesql) [NC]
  326. RewriteRule ^(.*)$ - [F,L]\n
  327. RewriteCond %{REMOTE_ADDR} !^$bps_get_IP_maint
  328. RewriteCond %{REQUEST_URI} !^$bps_get_wp_root_maint"."bp-maintenance\.php$
  329. RewriteCond %{REQUEST_URI} !^$bps_get_wp_root_maint"."wp-content/plugins/bulletproof-security/abstract-blue-bg\.png$
  330. RewriteRule ^(.*)$ $bps_get_wp_root_maint"."bp-maintenance.php [L]
  331. RewriteCond %{REQUEST_FILENAME} !-f
  332. RewriteCond %{REQUEST_FILENAME} !-d
  333. RewriteRule . $bps_get_wp_root_maint"."index.php [L]";
  334. if (is_writable($bps_auto_write_maint_file)) {
  335. if (!$handle = fopen($bps_auto_write_maint_file, 'w+b')) {
  336. _e('<font color="red"><strong>Cannot open file' . "$bps_auto_write_maint_file" . '</strong></font>');
  337. exit;
  338. }
  339. if (fwrite($handle, $bps_maint_content) === FALSE) {
  340. _e('<font color="red"><strong>Cannot write to file' . "$bps_auto_write_maint_file" . '</strong></font>');
  341. exit;
  342. }
  343. _e('<font color="green"><strong>Success! Your Maintenance Mode htaccess file was created successfully! Select the Maintenance Mode radio button and click Activate to put your website in Maintenance Mode.</strong></font>');
  344. fclose($handle);
  345. } else {
  346. _e('<font color="red"><strong>The file ' . "$bps_auto_write_maint_file" . ' is not writable or does not exist.</strong></font><br><strong>Check that the file is named maintenance.htaccess and that the file exists in the /bulletproof-security/admin/htaccess master folder. If this is not the problem click <a href="http://www.ait-pro.com/aitpro-blog/2566/bulletproof-security-plugin-support/bulletproof-security-error-messages" target="_blank">here</a> for more help info.</strong><br>');
  347. }
  348. }
  349. // default.htaccess and secure.htaccess fwrite content for all WP site types
  350. $bps_get_wp_root_default = bps_wp_get_root_folder();
  351. $bps_auto_write_default_file = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/default.htaccess';
  352. $bpsSuccessMessageDef = '<font color="green"><strong>Success! Your Default Mode Master htaccess file was created successfully!</strong></font><br><font color="red"><strong>CAUTION: Default Mode should only be activated for testing or troubleshooting purposes. Default Mode does not protect your website with any security protection.</strong></font><br><font color="black"><strong>To activate Default Mode select the Default Mode radio button and click Activate to put your website in Default Mode.</strong></font>';
  353. $bpsFailMessageDef = '<font color="red"><strong>The file ' . "$bps_auto_write_default_file" . ' is not writable or does not exist.</strong></font><br><strong>Check that the file is named default.htaccess and that the file exists in the /bulletproof-security/admin/htaccess master folder. If this is not the problem click <a href="http://www.ait-pro.com/aitpro-blog/2566/bulletproof-security-plugin-support/bulletproof-security-error-messages" target="_blank">here</a> for more help info.</strong><br>';
  354. $bpsTopMU = "\nRewriteEngine On
  355. RewriteBase $bps_get_wp_root_default
  356. RewriteRule ^index\.php$ - [L]\n\n";
  357. $bps_default_content_top = "# BULLETPROOF .46.D >>>>>>> DEFAULT .HTACCESS \n
  358. # If you edit the line of code above you will see error messages on the BPS status page
  359. # WARNING!!! THE default.htaccess FILE DOES NOT PROTECT YOUR WEBSITE AGAINST HACKERS
  360. # This is a standard generic htaccess file that does NOT provide any website security
  361. # The DEFAULT .HTACCESS file should be used for testing and troubleshooting purposes only\n
  362. # BEGIN WordPress";
  363. $bps_default_content_bottom = "\n<IfModule mod_rewrite.c>
  364. RewriteEngine On
  365. RewriteBase $bps_get_wp_root_default
  366. RewriteRule ^index\.php$ - [L]
  367. RewriteCond %{REQUEST_FILENAME} !-f
  368. RewriteCond %{REQUEST_FILENAME} !-d
  369. RewriteRule . $bps_get_wp_root_default"."index.php [L]
  370. </IfModule>\n
  371. # END WordPress";
  372. $bpsMUEndWP = "# END WordPress";
  373. $bpsMUSDirTop = "# uploaded files
  374. RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]\n
  375. # add a trailing slash to /wp-admin
  376. RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]\n\n";
  377. $bpsMUSDomTop = "# uploaded files
  378. RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]\n\n";
  379. $bpsMUSDirBottom = "RewriteCond %{REQUEST_FILENAME} -f [OR]
  380. RewriteCond %{REQUEST_FILENAME} -d
  381. RewriteRule ^ - [L]
  382. RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
  383. RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
  384. RewriteRule . index.php [L]\n\n";
  385. $bpsMUSDomBottom = "RewriteCond %{REQUEST_FILENAME} -f [OR]
  386. RewriteCond %{REQUEST_FILENAME} -d
  387. RewriteRule ^ - [L]
  388. RewriteRule . index.php [L]\n\n";
  389. // Create Default htaccess file - Single Site
  390. if (isset($_POST['bps-auto-write-default']) && current_user_can('manage_options')) {
  391. check_admin_referer( 'bulletproof_security_auto_write_default' );
  392. if (is_writable($bps_auto_write_default_file)) {
  393. if (!$handle = fopen($bps_auto_write_default_file, 'w+b')) {
  394. _e('<font color="red"><strong>Cannot open file' . "$bps_auto_write_default_file" . '</strong></font>');
  395. exit;
  396. }
  397. if (fwrite($handle, $bps_default_content_top.$bps_default_content_bottom) === FALSE) {
  398. _e('<font color="red"><strong>Cannot write to file' . "$bps_auto_write_default_file" . '</strong></font>');
  399. exit;
  400. }
  401. _e($bpsSuccessMessageDef);
  402. fclose($handle);
  403. } else {
  404. _e($bpsFailMessageDef);
  405. }
  406. }
  407. // Create Default htaccess file - MU Subdirectory
  408. if (isset($_POST['bps-auto-write-default-MUSDir']) && current_user_can('manage_options')) {
  409. check_admin_referer( 'bulletproof_security_auto_write_default_MUSDir' );
  410. if (is_writable($bps_auto_write_default_file)) {
  411. if (!$handle = fopen($bps_auto_write_default_file, 'w+b')) {
  412. _e('<font color="red"><strong>Cannot open file' . "$bps_auto_write_default_file" . '</strong></font>');
  413. exit;
  414. }
  415. if (fwrite($handle, $bps_default_content_top.$bpsTopMU.$bpsMUSDirTop.$bpsMUSDirBottom.$bpsMUEndWP) === FALSE) {
  416. _e('<font color="red"><strong>Cannot write to file' . "$bps_auto_write_default_file" . '</strong></font>');
  417. exit;
  418. }
  419. _e($bpsSuccessMessageDef);
  420. fclose($handle);
  421. } else {
  422. _e($bpsFailMessageDef);
  423. }
  424. }
  425. // Create Default htaccess file - MU Subdomain
  426. if (isset($_POST['bps-auto-write-default-MUSDom']) && current_user_can('manage_options')) {
  427. check_admin_referer( 'bulletproof_security_auto_write_default_MUSDom' );
  428. if (is_writable($bps_auto_write_default_file)) {
  429. if (!$handle = fopen($bps_auto_write_default_file, 'w+b')) {
  430. _e('<font color="red"><strong>Cannot open file' . "$bps_auto_write_default_file" . '</strong></font>');
  431. exit;
  432. }
  433. if (fwrite($handle, $bps_default_content_top.$bpsTopMU.$bpsMUSDomTop.$bpsMUSDomBottom.$bpsMUEndWP) === FALSE) {
  434. _e('<font color="red"><strong>Cannot write to file' . "$bps_auto_write_default_file" . '</strong></font>');
  435. exit;
  436. }
  437. _e($bpsSuccessMessageDef);
  438. fclose($handle);
  439. } else {
  440. _e($bpsFailMessageDef);
  441. }
  442. }
  443. // secure.htaccess fwrite content for all WP site types
  444. $bps_get_wp_root_secure = bps_wp_get_root_folder();
  445. $bps_auto_write_secure_file = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/secure.htaccess';
  446. $bpsSuccessMessageSec = '<font color="green"><strong>Success! Your BulletProof Security Root Master htaccess file was created successfully!</strong></font><br><font color="black"><strong>You can now Activate BulletProof Mode for your Root folder. Select the BulletProof Mode radio button and click Activate to put your website in BulletProof Mode.</strong></font>';
  447. $bpsFailMessageSec = '<font color="red"><strong>The file ' . "$bps_auto_write_secure_file" . ' is not writable or does not exist.</strong></font><br><strong>Check that the file is named secure.htaccess and that the file exists in the /bulletproof-security/admin/htaccess master folder. If this is not the problem click <a href="http://www.ait-pro.com/aitpro-blog/2566/bulletproof-security-plugin-support/bulletproof-security-error-messages" target="_blank">here</a> for more help info.</strong><br>';
  448. $bps_secure_content_top = "# BULLETPROOF .46.6 >>>>>>> SECURE .HTACCESS \n
  449. # If you edit the BULLETPROOF .46.6 >>>>>>> SECURE .HTACCESS text above
  450. # you will see error messages on the BPS status page
  451. # BPS is reading the version number in the htaccess file to validate checks
  452. # If you would like to change what is displayed above you
  453. # will need to edit the BPS /includes/functions.php file to match your changes
  454. # If you update your WordPress Permalinks the code between BEGIN WordPress and
  455. # END WordPress is replaced by WP htaccess code.
  456. # This removes all of the BPS security code and replaces it with just the default WP htaccess code
  457. # To restore this file use BPS Restore or activate BulletProof Mode for your Root folder again.\n
  458. # BEGIN WordPress
  459. # IMPORTANT!!! DO NOT DELETE!!! - BEGIN Wordpress above or END WordPress - text in this file
  460. # They are reference points for WP, BPS and other plugins to write to this htaccess file.
  461. # IMPORTANT!!! DO NOT DELETE!!! - BPSQSE BPS QUERY STRING EXPLOITS - text
  462. # BPS needs to find the - BPSQSE - text string in this file to validate that your security filters exist\n
  463. # TURN OFF YOUR SERVER SIGNATURE
  464. ServerSignature Off\n
  465. # ADD PHP HANDLER - Add your hosts php Handler below if you are using a php handler
  466. # Example GoDaddy PHP 5.2.x php handler is shown commented out directly below
  467. #AddHandler x-httpd-php5 .php\n
  468. # CUSTOM PHP.INI FILES - handlers and mod_suphp htaccess code for Web Hosts
  469. # If you are using either a BPS Pro custom php.ini file or one that you created yourself
  470. # If your host is GoDaddy and you have a custom php.ini file
  471. # uncomment the 1 line of code directly below
  472. #AddHandler x-httpd-php5 .php
  473. # If your host is BlueHost, HostMonster FastDomain and you have a custom php.ini file
  474. # uncomment the 1 line of code directly below
  475. #AddHandler application/x-httpd-php5s .php
  476. # If your host is HostGator and you have a custom php.ini file
  477. # uncomment the 3 lines of code below and replace xxxxx with your account/username
  478. #<IfModule mod_suphp.c>
  479. #suPHP_ConfigPath /home/xxxxx/public_html/php.ini
  480. #</IfModule>\n
  481. # DO NOT SHOW DIRECTORY LISTING
  482. # If you are getting 500 Errors when activating BPS then comment out Options -Indexes
  483. # by adding a # sign in front of it. If there is a typo anywhere in this file you will also see 500 errors.
  484. Options -Indexes\n
  485. # DIRECTORY INDEX FORCE INDEX.PHP
  486. # Use index.php as default directory index file
  487. # index.html will be ignored will not load.
  488. DirectoryIndex index.php index.html /index.php\n
  489. # BPS PRO ERROR LOGGING AND TRACKING - Available in BPS Pro only
  490. # BPS Pro has premade 403 Forbidden, 400 Bad Request and 404 Not Found files that are used
  491. # to track and log 403, 400 and 404 errors that occur on your website. When a hacker attempts to
  492. # hack your website the hackers IP address, Host name, Request Method, Referering link, the file name or
  493. # requested resource, the user agent of the hacker and the query string used in the hack attempt are logged.
  494. # BPS Pro Log files are added to the P-Security All Purpose File Manager to view them.
  495. # All BPS Pro log files are htaccess protected so that only you can view them.
  496. # The 400.php, 403.php and 404.php files are located in /wp-content/plugins/bulletproof-security/
  497. # The 400 and 403 Error logging files are already set up and will automatically start logging errors
  498. # after you install BPS Pro and have activated BulletProof Mode for your Root folder.
  499. # If you would like to log 404 errors you will need to copy the logging code in the BPS Pro 404.php file
  500. # to your Theme's 404.php template file. Simple instructions are included in the BPS Pro 404.php file.
  501. # You can open the BPS Pro 404.php file using the WP Plugins Editor or by using the BPS Pro File Manager.
  502. # NOTE: By default WordPress automatically looks in your Theme's folder for a 404.php template file.\n
  503. #ErrorDocument 400 $bps_get_wp_root_secure"."wp-content/plugins/bulletproof-security/400.php
  504. #ErrorDocument 403 $bps_get_wp_root_secure"."wp-content/plugins/bulletproof-security/403.php
  505. ErrorDocument 404 $bps_get_wp_root_secure"."404.php\n
  506. # DENY ACCESS TO PROTECTED SERVER FILES - .htaccess, .htpasswd and all file names starting with dot
  507. RedirectMatch 403 /\..*$\n
  508. RewriteEngine On
  509. RewriteBase $bps_get_wp_root_secure
  510. RewriteRule ^wp-admin/includes/ - [F,L]
  511. RewriteRule !^wp-includes/ - [S=3]
  512. RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
  513. RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
  514. RewriteRule ^wp-includes/theme-compat/ - [F,L]\n
  515. RewriteEngine On
  516. RewriteBase $bps_get_wp_root_secure
  517. RewriteRule ^index\.php$ - [L]\n\n";
  518. $bps_secure_content_mid_top = "# REQUEST METHODS FILTERED
  519. # This filter is for blocking junk bots and spam bots from making a HEAD request, but may also block some
  520. # HEAD request from bots that you want to allow in certains cases. This is not a security filter and is just
  521. # a nuisance filter. This filter will not block any important bots like the google bot. If you want to allow
  522. # all bots to make a HEAD request then remove HEAD from the Request Method filter.
  523. # The TRACE, DELETE, TRACK and DEBUG request methods should never be allowed against your website.
  524. RewriteEngine On
  525. RewriteCond %{REQUEST_METHOD} ^(HEAD|TRACE|DELETE|TRACK|DEBUG) [NC]
  526. RewriteRule ^(.*)$ - [F,L]\n
  527. # PLUGINS AND VARIOUS EXPLOIT FILTER SKIP RULES
  528. # IMPORTANT!!! If you add or remove a skip rule you must change S= to the new skip number
  529. # Example: If RewriteRule S=5 is deleted than change S=6 to S=5, S=7 to S=6, etc.
  530. # Adminer MySQL management tool data populate
  531. RewriteCond %{REQUEST_URI} ^$bps_get_wp_root_secure"."wp-content/plugins/adminer/ [NC]
  532. RewriteRule . - [S=11]
  533. # Comment Spam Pack MU Plugin - CAPTCHA images not displaying
  534. RewriteCond %{REQUEST_URI} ^$bps_get_wp_root_secure"."wp-content/mu-plugins/custom-anti-spam/ [NC]
  535. RewriteRule . - [S=10]
  536. # Peters Custom Anti-Spam display CAPTCHA Image
  537. RewriteCond %{REQUEST_URI} ^$bps_get_wp_root_secure"."wp-content/plugins/peters-custom-anti-spam-image/ [NC]
  538. RewriteRule . - [S=9]
  539. # Status Updater plugin fb connect
  540. RewriteCond %{REQUEST_URI} ^$bps_get_wp_root_secure"."wp-content/plugins/fb-status-updater/ [NC]
  541. RewriteRule . - [S=8]
  542. # Stream Video Player - Adding FLV Videos Blocked
  543. RewriteCond %{REQUEST_URI} ^$bps_get_wp_root_secure"."wp-content/plugins/stream-video-player/ [NC]
  544. RewriteRule . - [S=7]
  545. # XCloner 404 or 403 error when updating settings
  546. RewriteCond %{REQUEST_URI} ^$bps_get_wp_root_secure"."wp-content/plugins/xcloner-backup-and-restore/ [NC]
  547. RewriteRule . - [S=6]
  548. # BuddyPress Logout Redirect
  549. RewriteCond %{QUERY_STRING} action=logout&redirect_to=http%3A%2F%2F(.*) [NC]
  550. RewriteRule . - [S=5]
  551. # redirect_to=
  552. RewriteCond %{QUERY_STRING} redirect_to=(.*) [NC]
  553. RewriteRule . - [S=4]
  554. # Login Plugins Password Reset And Redirect 1
  555. RewriteCond %{QUERY_STRING} action=resetpass&key=(.*) [NC]
  556. RewriteRule . - [S=3]
  557. # Login Plugins Password Reset And Redirect 2
  558. RewriteCond %{QUERY_STRING} action=rp&key=(.*) [NC]
  559. RewriteRule . - [S=2]\n
  560. # ALLOW THUMBNAILER SCRIPTS TO DISPLAY IMAGES
  561. # By default BPS is forbidding allowing these thumbnailer scripts filename requests
  562. # This will Log lots of hacking attempts on your website in your BPS Pro Error Log
  563. # If you are using one of these thumbnailer scripts on your website and you want to allow
  564. # your thumbnailer script images to display then change [F,L] to [S=1]
  565. # Make sure that you have a security patched version or recent versions of these scripts
  566. # before changing [F,L] to [S=1] and allowing these files to be requested on your website
  567. # If you delete or remove the RewriteRule below you will need to change the above skip rules
  568. # Example: RewriteRule S=2 above will need to be changed to S=1, change S=3 to S=2, etc.
  569. RewriteCond %{REQUEST_FILENAME} thumb.php [NC,OR]
  570. RewriteCond %{REQUEST_FILENAME} thumbs.php [NC,OR]
  571. RewriteCond %{REQUEST_FILENAME} timthumb.php [NC,OR]
  572. RewriteCond %{REQUEST_FILENAME} phpthumb.php [NC]
  573. RewriteRule . - [F,L]\n
  574. # BPSQSE BPS QUERY STRING EXPLOITS
  575. # The libwww-perl User Agent is forbidden - Many bad bots use libwww-perl modules, but some good bots use it too.
  576. # Good sites such as W3C use it for their W3C-LinkChecker.
  577. # Add or remove user agents temporarily or permanently from the first User Agent filter below.
  578. # If you want a list of bad bots / User Agents to block then scroll to the end of this file.
  579. RewriteCond %{HTTP_USER_AGENT} (libwww-perl|wget|python|nikto|curl|scan|java|winhttp|clshttp|loader) [NC,OR]
  580. RewriteCond %{HTTP_USER_AGENT} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
  581. RewriteCond %{HTTP_USER_AGENT} (;|<|>|'|".'"'."|\)|\(|%0A|%0D|%22|%27|%28|%3C|%3E|%00).*(libwww-perl|wget|python|nikto|curl|scan|java|winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner) [NC,OR]
  582. RewriteCond %{THE_REQUEST} \?\ HTTP/ [NC,OR]
  583. RewriteCond %{THE_REQUEST} \/\*\ HTTP/ [NC,OR]
  584. RewriteCond %{THE_REQUEST} etc/passwd [NC,OR]
  585. RewriteCond %{THE_REQUEST} cgi-bin [NC,OR]
  586. RewriteCond %{THE_REQUEST} (\\r|\\n|%0A|%0D) [NC,OR]
  587. RewriteCond %{REQUEST_URI} owssvr\.dll [NC,OR]
  588. RewriteCond %{HTTP_REFERER} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
  589. RewriteCond %{HTTP_REFERER} \.opendirviewer\. [NC,OR]
  590. RewriteCond %{HTTP_REFERER} users\.skynet\.be.* [NC,OR]
  591. RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR]
  592. RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR]
  593. RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=/([a-z0-9_.]//?)+ [NC,OR]
  594. RewriteCond %{QUERY_STRING} \=PHP[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} [NC,OR]
  595. RewriteCond %{QUERY_STRING} \.\./\.\. [OR]
  596. RewriteCond %{QUERY_STRING} ftp\: [NC,OR]
  597. RewriteCond %{QUERY_STRING} http\: [NC,OR]
  598. RewriteCond %{QUERY_STRING} https\: [NC,OR]
  599. RewriteCond %{QUERY_STRING} \=\|w\| [NC,OR]
  600. RewriteCond %{QUERY_STRING} ^(.*)/self/(.*)$ [NC,OR]
  601. RewriteCond %{QUERY_STRING} ^(.*)cPath=http://(.*)$ [NC,OR]
  602. RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
  603. RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
  604. RewriteCond %{QUERY_STRING} (\<|%3C).*iframe.*(\>|%3E) [NC,OR]
  605. RewriteCond %{QUERY_STRING} (<|%3C)([^i]*i)+frame.*(>|%3E) [NC,OR]
  606. RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [NC,OR]
  607. RewriteCond %{QUERY_STRING} base64_(en|de)code[^(]*\([^)]*\) [NC,OR]
  608. RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
  609. RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) [OR]
  610. RewriteCond %{QUERY_STRING} ^.*(\[|\]|\(|\)|<|>).* [NC,OR]
  611. RewriteCond %{QUERY_STRING} (NULL|OUTFILE|LOAD_FILE) [OR]
  612. RewriteCond %{QUERY_STRING} (\./|\../|\.../)+(motd|etc|bin) [NC,OR]
  613. RewriteCond %{QUERY_STRING} (localhost|loopback|127\.0\.0\.1) [NC,OR]
  614. RewriteCond %{QUERY_STRING} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR]
  615. RewriteCond %{QUERY_STRING} concat[^\(]*\( [NC,OR]
  616. RewriteCond %{QUERY_STRING} union([^s]*s)+elect [NC,OR]
  617. RewriteCond %{QUERY_STRING} union([^a]*a)+ll([^s]*s)+elect [NC,OR]
  618. RewriteCond %{QUERY_STRING} (;|<|>|'|".'"'."|\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\*|union|select|insert|drop|delete|update|cast|create|char|convert|alter|declare|order|script|set|md5|benchmark|encode) [NC,OR]
  619. RewriteCond %{QUERY_STRING} (sp_executesql) [NC]
  620. RewriteRule ^(.*)$ - [F,L]\n";
  621. $bps_secure_content_mid_bottom = "RewriteCond %{REQUEST_FILENAME} !-f
  622. RewriteCond %{REQUEST_FILENAME} !-d
  623. RewriteRule . $bps_get_wp_root_secure"."index.php [L]\n\n";
  624. $bps_secure_content_bottom = "# DENY BROWSER ACCESS TO THESE FILES
  625. # wp-config.php, bb-config.php, php.ini, php5.ini, readme.html
  626. # Replace Allow from 88.77.66.55 with your current IP address and remove the
  627. # pound sign # from in front of the Allow from line of code below to access these
  628. # files directly from your browser.\n
  629. <FilesMatch ".'"'."^(wp-config\.php|php\.ini|php5\.ini|readme\.html|bb-config\.php)".'"'.">
  630. Order allow,deny
  631. Deny from all
  632. #Allow from 88.77.66.55
  633. </FilesMatch>\n
  634. # IMPORTANT!!! DO NOT DELETE!!! the END WordPress text below
  635. # END WordPress\n
  636. # BLOCK HOTLINKING TO IMAGES
  637. # To Test that your Hotlinking protection is working visit http://altlab.com/htaccess_tutorial.html
  638. #RewriteEngine On
  639. #RewriteCond %{HTTP_REFERER} !^https?://(www\.)?add-your-domain-here\.com [NC]
  640. #RewriteCond %{HTTP_REFERER} !^$
  641. #RewriteRule .*\.(jpeg|jpg|gif|bmp|png)$ - [F]\n
  642. # BLOCK MORE BAD BOTS RIPPERS AND OFFLINE BROWSERS
  643. # If you would like to block more bad bots you can get a blacklist from
  644. # http://perishablepress.com/press/2007/06/28/ultimate-htaccess-blacklist/
  645. # You should monitor your site very closely for at least a week if you add a bad bots list
  646. # to see if any website traffic problems or other problems occur.
  647. # Copy and paste your bad bots user agent code list directly below.";
  648. // Create Secure htaccess master Root file - Single Site
  649. if (isset($_POST['bps-auto-write-secure-root']) && current_user_can('manage_options')) {
  650. check_admin_referer( 'bulletproof_security_auto_write_secure_root' );
  651. if (is_writable($bps_auto_write_secure_file)) {
  652. if (!$handle = fopen($bps_auto_write_secure_file, 'w+b')) {
  653. _e('<font color="red"><strong>Cannot open file' . "$bps_auto_write_secure_file" . '</strong></font>');
  654. exit;
  655. }
  656. if (fwrite($handle, $bps_secure_content_top.$bps_secure_content_mid_top.$bps_secure_content_mid_bottom.$bps_secure_content_bottom) === FALSE) {
  657. _e('<font color="red"><strong>Cannot write to file' . "$bps_auto_write_secure_file" . '</strong></font>');
  658. exit;
  659. }
  660. _e($bpsSuccessMessageSec);
  661. fclose($handle);
  662. } else {
  663. _e($bpsFailMessageSec);
  664. }
  665. }
  666. // Create Secure htaccess master Root file - MU Subdirectory
  667. if (isset($_POST['bps-auto-write-secure-root-MUSDir']) && current_user_can('manage_options')) {
  668. check_admin_referer( 'bulletproof_security_auto_write_secure_root_MUSDir' );
  669. if (is_writable($bps_auto_write_secure_file)) {
  670. if (!$handle = fopen($bps_auto_write_secure_file, 'w+b')) {
  671. _e('<font color="red"><strong>Cannot open file' . "$bps_auto_write_secure_file" . '</strong></font>');
  672. exit;
  673. }
  674. if (fwrite($handle, $bps_secure_content_top.$bpsMUSDirTop.$bps_secure_content_mid_top.$bpsMUSDirBottom.$bps_secure_content_bottom) === FALSE) {
  675. _e('<font color="red"><strong>Cannot write to file' . "$bps_auto_write_secure_file" . '</strong></font>');
  676. exit;
  677. }
  678. _e($bpsSuccessMessageSec);
  679. fclose($handle);
  680. } else {
  681. _e($bpsFailMessageSec);
  682. }
  683. }
  684. // Create Secure htaccess master Root file - MU Subdomain
  685. if (isset($_POST['bps-auto-write-secure-root-MUSDom']) && current_user_can('manage_options')) {
  686. check_admin_referer( 'bulletproof_security_auto_write_secure_MUSDom' );
  687. if (is_writable($bps_auto_write_secure_file)) {
  688. if (!$handle = fopen($bps_auto_write_secure_file, 'w+b')) {
  689. _e('<font color="red"><strong>Cannot open file' . "$bps_auto_write_secure_file" . '</strong></font>');
  690. exit;
  691. }
  692. if (fwrite($handle, $bps_secure_content_top.$bpsMUSDomTop.$bps_secure_content_mid_top.$bpsMUSDomBottom.$bps_secure_content_bottom) === FALSE) {
  693. _e('<font color="red"><strong>Cannot write to file' . "$bps_auto_write_secure_file" . '</strong></font>');
  694. exit;
  695. }
  696. _e($bpsSuccessMessageSec);
  697. fclose($handle);
  698. } else {
  699. _e($bpsFailMessageSec);
  700. }
  701. }
  702. // Create the Maintenance Mode Settings Values Form File - values from DB
  703. if (isset($_POST['bps-maintenance-create-values_submit']) && current_user_can('manage_options')) {
  704. check_admin_referer( 'bulletproof_security_create_values_form' );
  705. $options = get_option('bulletproof_security_options_maint');
  706. $bps_retry_after_write = $options['bps-retry-after'];
  707. $bps_site_title_write = $options['bps-site-title'];
  708. $bps_message1_write = $options['bps-message-1'];
  709. $bps_message2_write = $options['bps-message-2'];
  710. $bps_body_background_image_write = $options['bps-background-image'];
  711. $bps_auto_write_maint_file_form = ABSPATH . 'wp-content/plugins/bulletproof-security/admin/htaccess/bps-maintenance-values.php';
  712. $bps_maint_content_form = "<?php".'
  713. $bps_retry_after'." = '$bps_retry_after_write';\n"
  714. .'$bps_site_title'." = '$bps_site_title_write';\n"
  715. .'$bps_message1'." = '$bps_message1_write';\n"
  716. .'$bps_message2'." = '$bps_message2_write';\n"
  717. .'$bps_body_background_image'." = '$bps_body_background_image_write';
  718. ?>";
  719. if (is_writable($bps_auto_write_maint_file_form)) {
  720. if (!$handle = fopen($bps_auto_write_maint_file_form, 'w+b')) {
  721. _e('<font color="red"><strong>Cannot open file' . "$bps_auto_write_maint_file_form" . '</strong></font>');
  722. exit;
  723. }
  724. if (fwrite($handle, $bps_maint_content_form) === FALSE) {
  725. _e('<font color="red"><strong>Cannot write to file' . "$bps_auto_write_maint_file_form" . '</strong></font>');
  726. exit;
  727. }
  728. _e('<font color="green"><strong>Success! Your Maintenance Mode Form has been created successfully! Click the Preview button to preview your Website Under Maintenance page.</strong></font>');
  729. fclose($handle);
  730. } else {
  731. _e('<font color="red"><strong>The file ' . "$bps_auto_write_maint_file_form" . ' is not writable or does not exist.</strong></font><br><strong>Check that the bps-maintenance-values.php file exists in the /bulletproof-security/admin/htaccess master folder. If this is not the problem click <a href="http://www.ait-pro.com/aitpro-blog/2566/bulletproof-security-plugin-support/bulletproof-security-error-messages" target="_blank">here</a> for more help info.</strong><br>');
  732. }
  733. }
  734. // Simple Secure Old School PHP file upload
  735. if (isset($_POST['submit-bps-upload']) && current_user_can('manage_options')) {
  736. check_admin_referer( 'bulletproof_security_upload' );
  737. $tmp_file = $_FILES['bps_file_upload']['tmp_name'];
  738. $folder_path = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/';
  739. $bps_uploaded_file = str_replace('//','/',$folder_path) . $_FILES['bps_file_upload']['name'];
  740. if (!empty($_FILES)) {
  741. move_uploaded_file($tmp_file,$bps_uploaded_file);
  742. _e('<font color="black"><strong>File Upload Path and File Name: </strong></font><br>');
  743. echo "$bps_uploaded_file";
  744. } else {
  745. _e('<font color="red"><strong>File upload error. File was not successfully uploaded.</strong></font><br>');
  746. }
  747. }
  748. // Enable File Downloading for Master Files - writes a new denyall htaccess file with the current IP address
  749. if (isset($_POST['bps-enable-download']) && current_user_can('manage_options')) {
  750. check_admin_referer( 'bulletproof_security_enable_download' );
  751. $bps_get_IP = $_SERVER['REMOTE_ADDR'];
  752. $denyall_htaccess_file = ABSPATH . '/wp-content/plugins/bulletproof-security/admin/htaccess/.htaccess';
  753. $bps_denyall_content = "order deny,allow\ndeny from all\nallow from $bps_get_IP";
  754. if (is_writable($denyall_htaccess_file)) {
  755. if (!$handle = fopen($denyall_htaccess_file, 'w+b')) {
  756. _e('<font color="red"><strong>Cannot open file' . "$denyall_htaccess_file" . '</strong></font>');
  757. exit;
  758. }
  759. if (fwrite($handle, $bps_denyall_content) === FALSE) {
  760. _e('<font color="red"><strong>Cannot write to file' . "$denyall_htaccess_file" . '</strong></font>');
  761. exit;
  762. }
  763. _e('<font color="green"><strong>Success! File open, preview and downloading for your BPS Master Files is enabled for your IP address only ===' . "$bps_get_IP." .'</strong></font>');
  764. fclose($handle);
  765. } else {
  766. _e('<font color="red"><strong>The file ' . "$denyall_htaccess_file" . ' is not writable or does not exist yet.</strong></font><br><strong>Check the BPS Status page to see if Deny All protection has been activated. Activate Deny All htaccess Folder Protection For The BPS Master htaccess Folder on the BPS Security Modes page. If this is not the problem click <a href="http://www.ait-pro.com/aitpro-blog/2566/bulletproof-security-plugin-support/bulletproof-security-error-messages" target="_blank">here</a> for more help info.</strong><br>');
  767. }
  768. }
  769. // Enable File Downloading for BPS Backup Folder - writes a new denyall htaccess file with the current IP address
  770. if (isset($_POST['bps-enable-download-backup']) && current_user_can('manage_options')) {
  771. check_admin_referer( 'bulletproof_security_enable_download-backup' );
  772. $bps_get_IP2 = $_SERVER['REMOTE_ADDR'];
  773. $denyall_htaccess_file_backup = ABSPATH . '/wp-content/b…

Large files files are truncated, but you can click here to view the full file