Plugin Directory

Changeset 2635941


Ignore:
Timestamp:
11/26/2021 05:45:44 PM (3 years ago)
Author:
threatpointuk
Message:

version 2.6

Location:
threatpoint-api/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • threatpoint-api/trunk/Threatpoint-api.php

    r2584085 r2635941  
    55    Description: Protect your WordPress Site from unwanted access attempts, by leveraging IP reputation data provided by the ThreatPoint IP reputation service. Malicious IP, High Risk IP, TOR, VPN, Geo IP. Use to stop brute force attacks - XMLRPC, WP-login and protect contact pages.
    66    Author: ThreatPoint
    7     Version: 2.5
     7    Version: 2.6
    88    Author URI: https://threatpoint.co.uk
    99    License: GPL-2.0+
     
    125125        'tp_api_tpPlugin_section'
    126126    );
     127   
     128    add_settings_field(
     129        'tp_api_select_field_12',
     130        __( 'Allow specific bots', 'wordpress' ),
     131        'tp_api_select_field_12_render',
     132        'tpPlugin',
     133        'tp_api_tpPlugin_section'
     134    );
     135   
     136    add_settings_field(
     137        'tp_api_select_field_13',
     138        __( 'Bots to allow (Comma separated list)', 'wordpress' ),
     139        'tp_api_select_field_13_render',
     140        'tpPlugin',
     141        'tp_api_tpPlugin_section'
     142    );
    127143
    128144}
     
    244260}
    245261
     262function tp_api_select_field_12_render(  ) {
     263    $options = get_option( 'tp_api_settings' );
     264    ?>
     265    <select name='tp_api_settings[tp_api_select_field_12]'>
     266        <option value='1' <?php selected( $options['tp_api_select_field_12'], 1 ); ?>>No</option>
     267        <option value='2' <?php selected( $options['tp_api_select_field_12'], 2 ); ?>>Yes</option>
     268    </select>
     269    <?php echo '<b>&#8505 Allow specific bots that might be otherwise blocked if using country controls. Enter bot names (csv) in the option below</b>'; ?>
     270    <?php
     271}
     272
     273function tp_api_select_field_13_render(  ) {
     274    $options = get_option( 'tp_api_settings' );
     275    ?>
     276    <input type='text' size=50 name='tp_api_settings[tp_api_text_field_13]' value='<?php echo $options['tp_api_text_field_13']; ?>'>
     277    <?php echo '<b>&#8505 Accepts name for bots and is not case sensitive. i.e. googlebot, search.msn.com (bing)</b>'; ?>
     278    <?php
     279}
    246280
    247281function tp_api_settings_section_callback(  ) {
     
    490524           
    491525           
    492             if ($ipriskn == 'High' and (strpos($risk, $ipriskn) !==false and (strpos($risk, $isTor) !==false or strpos($risk, $isVpn) !==false))) {
     526            if ($ipriskn == 'High' and (strpos($risk, $ipriskn) !==false and (strpos($risk, $isTor) ===false and strpos($risk, $isVpn) ===false))) {
    493527              if ($tor == '1' or $vpn == '1'){
    494528                if ($mailon =='1'){
     
    504538              }
    505539            }
    506             if ($ipriskn == 'Consider' and (strpos($risk, 'High') !==false or strpos($risk, 'Consider') !==false and (strpos($risk, $isTor) !==false or strpos($risk, $isVpn) !==false))) {
     540            if ($ipriskn == 'Consider' and (strpos($risk, 'High') !==false or strpos($risk, 'Consider') !==false and (strpos($risk, $isTor) ===false and strpos($risk, $isVpn) ===false))) {
    507541              if ($tor == '1' or $vpn == '1'){
    508542                if ($mailon =='1'){
     
    518552              }
    519553            }
    520             if ($ipriskn == 'Low' and (strpos($risk, 'High') !==false or strpos($risk, 'Consider') !==false or strpos($risk, 'Low') !==false and (strpos($risk, $isTor) !==false or strpos($risk, $isVpn) !==false))) {
     554            if ($ipriskn == 'Low' and (strpos($risk, 'High') !==false or strpos($risk, 'Consider') !==false or strpos($risk, 'Low') !==false and (strpos($risk, $isTor) ===false and strpos($risk, $isVpn) ===false))) {
    521555              if ($tor == '1' or $vpn == '1'){
    522556                if ($mailon =='1'){
     
    597631    $mailon = esc_attr( get_option('tp_api_settings')['tp_api_select_field_9']);
    598632    $emailaddress = esc_attr( get_option('tp_api_settings')['tp_api_text_field_10']);
     633    $botYes = esc_attr( get_option('tp_api_settings')['tp_api_select_field_12']);
     634    $botList = esc_attr( get_option('tp_api_settings')['tp_api_text_field_13']);
    599635    $isVpn = 'Vpn';
    600636    $isTor = 'Tor';
     
    610646    }
    611647     
    612  
     648    if ($botYes == '2'){
    613649   
     650        $botURL = 'https://verify.threatpoint.co.uk:443/api/v1/resources/iptoname?ipaddress=';
     651        $botArgs = array ('sslverify' => false,
     652                'headers' => array('X-Api-Key' => $key));
     653        $newip = $_SERVER['REMOTE_ADDR'];
     654
     655        if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
     656            $newip = $_SERVER['HTTP_X_FORWARDED_FOR'];
     657        }
     658       
     659        $botNewUrl = $botURL . $newip;
     660        $botResponse = wp_remote_get( $botNewUrl, $botArgs);
     661       
     662        if (is_wp_error( $botResponse ) ) {
     663     
     664        echo 'Errors detected!';
     665       
     666        } else {
     667            $botBody = wp_remote_retrieve_body ($botResponse);
     668            $botData = json_decode($botBody);
     669           
     670               
     671            $botMatch = $botData->isMatch;
     672            $botFdns = $botData->forwarddns;
     673            $botRdns = $botData->reversedns;
     674            $botip = $botData->original_ip;
     675                   
     676            }
     677       
     678    }
     679    if ($botYes == '1'){
     680       
     681        $botMatch = false;
     682        $botFdns =  null;
     683        $botRdns = null;
     684        $botip = null;
     685    }
     686    $botArray =explode(',', $botList);
     687    $botNameMatch = false;
     688    foreach ($botArray as $value){
     689        $pos = strpos($botFdns, $value);
     690        if ($pos === false)
     691        {
     692            //echo "Holy moly there is no match";
     693        }else{
     694           
     695            $botNameMatch = true;
     696           
     697        }
     698        if ($botMatch == "False"){
     699            $botNameMatch = false;
     700        }
     701    }
     702        //echo "<p>bot name match value =".$botNameMatch."</p>";
     703    //exit;
     704   
    614705    $url = 'https://verify.threatpoint.co.uk:443/api/v1/resources/ip?ipaddress=';
    615706    $arguments = array ('sslverify' => false,
     
    643734           
    644735           
    645             if ($ipriskn == 'High' and (strpos($risk, $ipriskn) !==false and (strpos($risk, $isTor) !==false or strpos($risk, $isVpn) !==false))) {
     736            if ($ipriskn == 'High' and (strpos($risk, $ipriskn) !==false and (strpos($risk, $isTor) ===false and strpos($risk, $isVpn) ===false))) {
    646737              if ($tor == '1' or $vpn == '1'){
    647738                if ($mailon =='1'){
     
    652743                $sent = @wp_mail($to,$subject,$body,$headers);
    653744                }
     745               
    654746                wp_redirect( $redirect);
    655747                exit;
    656748              }
    657749            }
    658             if ($ipriskn == 'Consider' and (strpos($risk, 'High') !==false or strpos($risk, 'Consider') !==false and (strpos($risk, $isTor) !==false or strpos($risk, $isVpn) !==false))) {
     750            if ($ipriskn == 'Consider' and (strpos($risk, 'High') !==false or strpos($risk, 'Consider') !==false and (strpos($risk, $isTor) ===false and strpos($risk, $isVpn) ===false))) {
    659751              if ($tor == '1' or $vpn == '1'){
    660752                if ($mailon =='1'){
     
    665757                $sent = @wp_mail($to,$subject,$body,$headers);
    666758                }
    667                
     759             
    668760                wp_redirect( $redirect);
    669761                exit;
    670762              }
    671763            }
    672             if ($ipriskn == 'Low' and (strpos($risk, 'High') !==false or strpos($risk, 'Consider') !==false or strpos($risk, 'Low') !==false and (strpos($risk, $isTor) !==false or strpos($risk, $isVpn) !==false))) {
     764            if ($ipriskn == 'Low' and (strpos($risk, 'High') !==false or strpos($risk, 'Consider') !==false or strpos($risk, 'Low') !==false and (strpos($risk, $isTor) ===false and strpos($risk, $isVpn) ===false))) {
    673765              if ($tor == '1' or $vpn == '1'){
    674766                if ($mailon =='1'){
     
    679771                $sent = @wp_mail($to,$subject,$body,$headers);
    680772                }
    681                
     773                   
    682774                wp_redirect( $redirect);
    683775                exit;
     
    708800                exit;
    709801            }
    710             if ($countryconfig !='' and strpos($countryconfig, $country) !==false) {
     802            if ($countryconfig !='' and strpos($countryconfig, $country) !==false and $botNameMatch ==false ) {
    711803                if ($mailon =='1'){
    712804                $to = $emailaddress;
     
    716808                $sent = @wp_mail($to,$subject,$body,$headers);
    717809                }
    718                
     810             
    719811                wp_redirect( $redirect);
    720812                exit;
    721813            }
    722             if ($countrywhite !='' and strpos($countrywhite, $country) ===false) {
     814            if ($countrywhite !='' and strpos($countrywhite, $country) ===false and $botNameMatch !=true) {
    723815                if ($mailon =='1'){
    724816                $to = $emailaddress;
     
    729821                }
    730822               
    731                    
     823               
    732824                wp_redirect( $redirect);
    733825                exit;
  • threatpoint-api/trunk/readme.txt

    r2584085 r2635941  
    44Tags: wp-admin,xmlrpc,ip,reputation,tor,vpn,proxy,malicious,requests,protection,risk,score,fraud,identity
    55Requires at least: 3.5.2
    6 Tested up to: 5.8
     6Tested up to: 5.8.2
    77Requires PHP: 5.4
    8 Stable tag: 2.5
     8Stable tag: 2.6
    99
    1010== Description ==
     
    8888 
    8989== Changelog ==
     90= 2.6 =
     91Added support to allow bots past country blacklist rules
    9092= 2.5 =
    9193* tested on 5.8
     
    131133 
    132134== Upgrade Notice ==
     135= 2.6 =
     136Allow bots that could have been blocked by country blacklists
    133137= 2.4 =
    134138IP History Table
Note: See TracChangeset for help on using the changeset viewer.