Module: Msf::Payload::MalleableC2

Defined in:
lib/msf/core/payload/malleable_c2.rb

Defined Under Namespace

Classes: Lexer, ParsedDirective, ParsedProfile, ParsedSection, ParsedSet, Parser, Token

Constant Summary collapse

MET =
Rex::Post::Meterpreter
MC2 =
Msf::Payload::MalleableC2

Class Method Summary collapse

Class Method Details

.from_c2_string_value(s) ⇒ Object

Handle escape sequences in the strings provided by the c2 profile



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/msf/core/payload/malleable_c2.rb', line 19

def self.from_c2_string_value(s)
  # Support substitution of a subset of escape characters:
  # \r, \t, \n, \\, \x.., \"
  # Not supporting \u at this point.
  # We do in a single regex and parse each as we go, as this avoids the
  # potential for double-encoding.
  s.gsub(/\\(x(..)|r|n|t|"|\\)/) {|b|
    case b[1]
    when 'x'
      [b[2, 2].to_i(16)].pack('C')
    when 'r'
      "\r"
    when 't'
      "\t"
    when 'n'
      "\n"
    when '"'
      '"'
    when '\\'
      "\\"
    end
  }
end