Plugin Directory

Changeset 187625


Ignore:
Timestamp:
12/28/2009 03:00:57 PM (16 years ago)
Author:
ljmacphee
Message:

No longer logs ip violations to improve speed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ttc-wordpress-security-plugin/trunk/ttc_security.php

    r185499 r187625  
    33    /*
    44     Plugin Name: TimesToCome Security Plugin
    5      Version: 2.3
     5     Version: 2.4
    66     Plugin URI:  http://herselfswebtools.com/2008/06/wordpress-security-plugin-block-scrapers-hackers-and-more.html
    77     Description: Security plugin for Wordpress
     
    4444        $request_table_name = $wpdp->prefix . "ttc_request_blacklist";
    4545       
    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       
    5069        // Note: faster and safer to pull all from db and loop through data using php for matches
    5170        // than it is to prep input, (sanatize and clean up) and use MySql matching
    52    
     71       
    5372        // Note: tried === instead of tacking x on front of string but only matches in first position
    5473        // and we want matches any where in the string
     
    6685                //if ( strcasecmp( $http_remote_addr, $bad_ip ) == 0 ){  $blacklisted = 1;  }
    6786               
    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               
    6989                $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.
    7090                if ((strpos ( $hacked_http_remote_addr, $bad_ip, 1 )) == 1 ){
    7191                    $blacklisted = 1;
    7292                }
    73                  
     93               
    7494               
    7595            }
     
    85105            $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 !!!       
    86106            foreach ( $agent_black_list as $blacklisted_agent ){
     107                $bad_agent = $blacklisted_agent->agent;         
    87108               
    88                 $bad_agent = $blacklisted_agent->agent;         
    89109               
    90110                if ( strpos ( $hacked_http_user_agent, $bad_agent ) > 0  ){
     
    112132            }
    113133        }
    114    
     134       
    115135       
    116136       
     
    126146        // don't ban ourselves....
    127147        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 banishment
     148        }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
    129149       
    130150       
     
    142162        }else if ( $blacklisted == 1 ){                         // already blacklisted ip here so just add to log
    143163           
    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
    145166           
    146167            $code = "Sorry but you are listed on our ip blacklist";
     
    156177            header("Location: http://$host$uri");
    157178           
    158             // or send them to a rejection notice
    159179            /*
    160180             // print error page //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    197217            header("Location: http://$host$uri");
    198218           
    199             // or send them to a rejection notice
    200219            /*
    201220             // print error page  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    244263       
    245264       
    246         // clean input for database to prevent injection attacks
     265        // clean input for database
    247266        $http_accept = htmlentities($http_accept);
    248267        $http_user_agent = htmlentities($http_user_agent);
    249268        $http_remote_addr = htmlentities($http_remote_addr);
    250269        $http_request_uri = htmlentities($http_request_uri);
    251        
    252    
    253270       
    254271        // ok now stuff the info into the log files in the db
Note: See TracChangeset for help on using the changeset viewer.