Changeset 187625
- Timestamp:
- 12/28/2009 03:00:57 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ttc-wordpress-security-plugin/trunk/ttc_security.php
r185499 r187625 3 3 /* 4 4 Plugin Name: TimesToCome Security Plugin 5 Version: 2. 35 Version: 2.4 6 6 Plugin URI: http://herselfswebtools.com/2008/06/wordpress-security-plugin-block-scrapers-hackers-and-more.html 7 7 Description: Security plugin for Wordpress … … 44 44 $request_table_name = $wpdp->prefix . "ttc_request_blacklist"; 45 45 46 47 // Note: was checking to see if tables existed and creating if not, but already check on 48 // install and when user loads admin page - taking it out to streamline things 49 46 ///********************************************* 47 // does this need to be done each time? 48 ///********************************************* 49 /* 50 // create tables if they don't already exist 51 if($wpdb->get_var("SHOW TABLES LIKE '$blacklist_table_name'") != $blacklist_table_name ) { 52 ttc_security_install(); 53 } 54 if($wpdb->get_var("SHOW TABLES LIKE '$ip_table_name'") != $ip_table_name ) { 55 ttc_security_install(); 56 } 57 if($wpdb->get_var("SHOW TABLES LIKE '$agent_table_name'") != $agent_table_name ) { 58 ttc_security_install(); 59 } 60 if($wpdb->get_var("SHOW TABLES LIKE '$request_table_name'") != $request_table_name ) { 61 ttc_security_install(); 62 } 63 */ 64 ////******************************************** 65 66 67 68 50 69 // Note: faster and safer to pull all from db and loop through data using php for matches 51 70 // than it is to prep input, (sanatize and clean up) and use MySql matching 52 71 53 72 // Note: tried === instead of tacking x on front of string but only matches in first position 54 73 // and we want matches any where in the string … … 66 85 //if ( strcasecmp( $http_remote_addr, $bad_ip ) == 0 ){ $blacklisted = 1; } 67 86 68 // checks for partial matches so we can ban blocks of troublesome ip numbers 87 //check for partial matches so we can block blocks of troublesome ip numbers 88 69 89 $hacked_http_remote_addr = "x" . $http_remote_addr; // php reads 0 if no match and 0 if first position, this is a hack around that. 70 90 if ((strpos ( $hacked_http_remote_addr, $bad_ip, 1 )) == 1 ){ 71 91 $blacklisted = 1; 72 92 } 73 93 74 94 75 95 } … … 85 105 $hacked_http_user_agent = "x" . $http_user_agent; //php reads 0 if not found, or if first position matches, this is a hack around that. PHP should return -1 not NULL !!! 86 106 foreach ( $agent_black_list as $blacklisted_agent ){ 107 $bad_agent = $blacklisted_agent->agent; 87 108 88 $bad_agent = $blacklisted_agent->agent;89 109 90 110 if ( strpos ( $hacked_http_user_agent, $bad_agent ) > 0 ){ … … 112 132 } 113 133 } 114 134 115 135 116 136 … … 126 146 // don't ban ourselves.... 127 147 if ( $http_local_addr == $http_remote_addr ){ $blacklisted = 0; 128 }else if ( $http_remote_addr == " 127.0.0.1" ){ $blacklisted = 0; } ////// change 127.0.0.1 to your ip and remove leading // to prevent self banishment148 }else if ( $http_remote_addr == "98.200.58.3" ){ $blacklisted = 0; } ////// change 127.0.0.1 to your ip and remove leading // to prevent self banishment 129 149 130 150 … … 142 162 }else if ( $blacklisted == 1 ){ // already blacklisted ip here so just add to log 143 163 144 ttc_add_to_security_log( $blacklisted ); // add to log 164 // too many to log, log entries growing too fast 165 //ttc_add_to_security_log( $blacklisted ); // add to log 145 166 146 167 $code = "Sorry but you are listed on our ip blacklist"; … … 156 177 header("Location: http://$host$uri"); 157 178 158 // or send them to a rejection notice159 179 /* 160 180 // print error page ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 197 217 header("Location: http://$host$uri"); 198 218 199 // or send them to a rejection notice200 219 /* 201 220 // print error page //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 244 263 245 264 246 // clean input for database to prevent injection attacks265 // clean input for database 247 266 $http_accept = htmlentities($http_accept); 248 267 $http_user_agent = htmlentities($http_user_agent); 249 268 $http_remote_addr = htmlentities($http_remote_addr); 250 269 $http_request_uri = htmlentities($http_request_uri); 251 252 253 270 254 271 // ok now stuff the info into the log files in the db
Note: See TracChangeset
for help on using the changeset viewer.