Changeset 2635941
- Timestamp:
- 11/26/2021 05:45:44 PM (3 years ago)
- Location:
- threatpoint-api/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
threatpoint-api/trunk/Threatpoint-api.php
r2584085 r2635941 5 5 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. 6 6 Author: ThreatPoint 7 Version: 2. 57 Version: 2.6 8 8 Author URI: https://threatpoint.co.uk 9 9 License: GPL-2.0+ … … 125 125 'tp_api_tpPlugin_section' 126 126 ); 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 ); 127 143 128 144 } … … 244 260 } 245 261 262 function 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>ℹ 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 273 function 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>ℹ Accepts name for bots and is not case sensitive. i.e. googlebot, search.msn.com (bing)</b>'; ?> 278 <?php 279 } 246 280 247 281 function tp_api_settings_section_callback( ) { … … 490 524 491 525 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))) { 493 527 if ($tor == '1' or $vpn == '1'){ 494 528 if ($mailon =='1'){ … … 504 538 } 505 539 } 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))) { 507 541 if ($tor == '1' or $vpn == '1'){ 508 542 if ($mailon =='1'){ … … 518 552 } 519 553 } 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))) { 521 555 if ($tor == '1' or $vpn == '1'){ 522 556 if ($mailon =='1'){ … … 597 631 $mailon = esc_attr( get_option('tp_api_settings')['tp_api_select_field_9']); 598 632 $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']); 599 635 $isVpn = 'Vpn'; 600 636 $isTor = 'Tor'; … … 610 646 } 611 647 612 648 if ($botYes == '2'){ 613 649 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 614 705 $url = 'https://verify.threatpoint.co.uk:443/api/v1/resources/ip?ipaddress='; 615 706 $arguments = array ('sslverify' => false, … … 643 734 644 735 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))) { 646 737 if ($tor == '1' or $vpn == '1'){ 647 738 if ($mailon =='1'){ … … 652 743 $sent = @wp_mail($to,$subject,$body,$headers); 653 744 } 745 654 746 wp_redirect( $redirect); 655 747 exit; 656 748 } 657 749 } 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))) { 659 751 if ($tor == '1' or $vpn == '1'){ 660 752 if ($mailon =='1'){ … … 665 757 $sent = @wp_mail($to,$subject,$body,$headers); 666 758 } 667 759 668 760 wp_redirect( $redirect); 669 761 exit; 670 762 } 671 763 } 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))) { 673 765 if ($tor == '1' or $vpn == '1'){ 674 766 if ($mailon =='1'){ … … 679 771 $sent = @wp_mail($to,$subject,$body,$headers); 680 772 } 681 773 682 774 wp_redirect( $redirect); 683 775 exit; … … 708 800 exit; 709 801 } 710 if ($countryconfig !='' and strpos($countryconfig, $country) !==false ) {802 if ($countryconfig !='' and strpos($countryconfig, $country) !==false and $botNameMatch ==false ) { 711 803 if ($mailon =='1'){ 712 804 $to = $emailaddress; … … 716 808 $sent = @wp_mail($to,$subject,$body,$headers); 717 809 } 718 810 719 811 wp_redirect( $redirect); 720 812 exit; 721 813 } 722 if ($countrywhite !='' and strpos($countrywhite, $country) ===false ) {814 if ($countrywhite !='' and strpos($countrywhite, $country) ===false and $botNameMatch !=true) { 723 815 if ($mailon =='1'){ 724 816 $to = $emailaddress; … … 729 821 } 730 822 731 823 732 824 wp_redirect( $redirect); 733 825 exit; -
threatpoint-api/trunk/readme.txt
r2584085 r2635941 4 4 Tags: wp-admin,xmlrpc,ip,reputation,tor,vpn,proxy,malicious,requests,protection,risk,score,fraud,identity 5 5 Requires at least: 3.5.2 6 Tested up to: 5.8 6 Tested up to: 5.8.2 7 7 Requires PHP: 5.4 8 Stable tag: 2. 58 Stable tag: 2.6 9 9 10 10 == Description == … … 88 88 89 89 == Changelog == 90 = 2.6 = 91 Added support to allow bots past country blacklist rules 90 92 = 2.5 = 91 93 * tested on 5.8 … … 131 133 132 134 == Upgrade Notice == 135 = 2.6 = 136 Allow bots that could have been blocked by country blacklists 133 137 = 2.4 = 134 138 IP History Table
Note: See TracChangeset
for help on using the changeset viewer.