Skip to content

Commit ee41be0

Browse files
committed
Land rapid7#1944, C# byte array payload
2 parents 69c2501 + aced5bb commit ee41be0

File tree

4 files changed

+143
-62
lines changed

4 files changed

+143
-62
lines changed

lib/msf/base/simple/buffer.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def self.transform(buf, fmt = "ruby")
3131
buf = Rex::Text.to_bash(buf)
3232
when 'c'
3333
buf = Rex::Text.to_c(buf)
34+
when 'csharp'
35+
buf = Rex::Text.to_csharp(buf)
3436
when 'js_be'
3537
buf = Rex::Text.to_unescape(buf, ENDIAN_BIG)
3638
when 'js_le'
@@ -59,6 +61,8 @@ def self.comment(buf, fmt = "ruby")
5961
buf = Rex::Text.to_bash_comment(buf)
6062
when 'c'
6163
buf = Rex::Text.to_c_comment(buf)
64+
when 'csharp'
65+
buf = Rex::Text.to_c_comment(buf)
6266
when 'js_be', 'js_le'
6367
buf = Rex::Text.to_js_comment(buf)
6468
when 'java'
@@ -74,7 +78,7 @@ def self.comment(buf, fmt = "ruby")
7478
# Returns the list of supported formats
7579
#
7680
def self.transform_formats
77-
['raw','ruby','rb','perl','pl','bash','sh','c','js_be','js_le','java','python','py']
81+
['raw','ruby','rb','perl','pl','bash','sh','c','csharp','js_be','js_le','java','python','py']
7882
end
7983

8084
end

lib/rex/text.rb

Lines changed: 88 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,55 @@ module Text
5252
DefaultPatternSets = [ Rex::Text::UpperAlpha, Rex::Text::LowerAlpha, Rex::Text::Numerals ]
5353

5454
# In case Iconv isn't loaded
55-
Iconv_EBCDIC = ["\x00", "\x01", "\x02", "\x03", "7", "-", ".", "/", "\x16", "\x05", "%", "\v", "\f", "\r", "\x0E", "\x0F", "\x10", "\x11", "\x12", "\x13", "<", "=", "2", "&", "\x18", "\x19", "?", "'", "\x1C", "\x1D", "\x1E", "\x1F", "@", "Z", "\x7F", "{", "[", "l", "P", "}", "M", "]", "\\", "N", "k", "`", "K", "a", "\xF0", "\xF1", "\xF2", "\xF3", "\xF4", "\xF5", "\xF6", "\xF7", "\xF8", "\xF9", "z", "^", "L", "~", "n", "o", "|", "\xC1", "\xC2", "\xC3", "\xC4", "\xC5", "\xC6", "\xC7", "\xC8", "\xC9", "\xD1", "\xD2", "\xD3", "\xD4", "\xD5", "\xD6", "\xD7", "\xD8", "\xD9", "\xE2", "\xE3", "\xE4", "\xE5", "\xE6", "\xE7", "\xE8", "\xE9", nil, "\xE0", nil, nil, "m", "y", "\x81", "\x82", "\x83", "\x84", "\x85", "\x86", "\x87", "\x88", "\x89", "\x91", "\x92", "\x93", "\x94", "\x95", "\x96", "\x97", "\x98", "\x99", "\xA2", "\xA3", "\xA4", "\xA5", "\xA6", "\xA7", "\xA8", "\xA9", "\xC0", "O", "\xD0", "\xA1", "\a", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
56-
Iconv_ASCII = ["\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\a", "\b", "\t", "\n", "\v", "\f", "\r", "\x0E", "\x0F", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1A", "\e", "\x1C", "\x1D", "\x1E", "\x1F", " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", nil, "\\", nil, nil, "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "\x7F", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
55+
Iconv_EBCDIC = [
56+
"\x00", "\x01", "\x02", "\x03", "7", "-", ".", "/", "\x16", "\x05",
57+
"%", "\v", "\f", "\r", "\x0E", "\x0F", "\x10", "\x11", "\x12", "\x13",
58+
"<", "=", "2", "&", "\x18", "\x19", "?", "'", "\x1C", "\x1D", "\x1E",
59+
"\x1F", "@", "Z", "\x7F", "{", "[", "l", "P", "}", "M", "]", "\\",
60+
"N", "k", "`", "K", "a", "\xF0", "\xF1", "\xF2", "\xF3", "\xF4",
61+
"\xF5", "\xF6", "\xF7", "\xF8", "\xF9", "z", "^", "L", "~", "n", "o",
62+
"|", "\xC1", "\xC2", "\xC3", "\xC4", "\xC5", "\xC6", "\xC7", "\xC8",
63+
"\xC9", "\xD1", "\xD2", "\xD3", "\xD4", "\xD5", "\xD6", "\xD7",
64+
"\xD8", "\xD9", "\xE2", "\xE3", "\xE4", "\xE5", "\xE6", "\xE7",
65+
"\xE8", "\xE9", nil, "\xE0", nil, nil, "m", "y", "\x81", "\x82",
66+
"\x83", "\x84", "\x85", "\x86", "\x87", "\x88", "\x89", "\x91",
67+
"\x92", "\x93", "\x94", "\x95", "\x96", "\x97", "\x98", "\x99",
68+
"\xA2", "\xA3", "\xA4", "\xA5", "\xA6", "\xA7", "\xA8", "\xA9",
69+
"\xC0", "O", "\xD0", "\xA1", "\a", nil, nil, nil, nil, nil, nil,
70+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
71+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
72+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
73+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
74+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
75+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
76+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
77+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
78+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
79+
nil, nil, nil, nil, nil
80+
]
81+
82+
Iconv_ASCII = [
83+
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\a", "\b",
84+
"\t", "\n", "\v", "\f", "\r", "\x0E", "\x0F", "\x10", "\x11", "\x12",
85+
"\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1A", "\e",
86+
"\x1C", "\x1D", "\x1E", "\x1F", " ", "!", "\"", "#", "$", "%", "&",
87+
"'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4",
88+
"5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@", "A", "B",
89+
"C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
90+
"Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", nil, "\\", nil,
91+
nil, "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
92+
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y",
93+
"z", "{", "|", "}", "~", "\x7F", nil, nil, nil, nil, nil, nil, nil,
94+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
95+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
96+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
97+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
98+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
99+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
100+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
101+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
102+
nil, nil, nil, nil, nil, nil, nil, nil, nil
103+
]
57104

58105
##
59106
#
@@ -82,6 +129,17 @@ def self.to_c(str, wrap = DefaultWrap, name = "buf")
82129
return hexify(str, wrap, '"', '"', "unsigned char #{name}[] = \n", '";')
83130
end
84131

132+
def self.to_csharp(str, wrap = DefaultWrap, name = "buf")
133+
ret = "byte[] #{name} = new byte[#{str.length}] {"
134+
i = -1;
135+
while (i += 1) < str.length
136+
ret << "\n" if i%(wrap/4) == 0
137+
ret << "0x" << str[i].unpack("H*")[0] << ","
138+
end
139+
ret = ret[0..ret.length-2] #cut off last comma
140+
ret << " };\n"
141+
end
142+
85143
#
86144
# Creates a c-style comment
87145
#
@@ -344,22 +402,40 @@ def self.to_hex_ascii(str, prefix = "\\x", count = 1, suffix=nil)
344402
#
345403
# Converts standard ASCII text to a unicode string.
346404
#
347-
# Supported unicode types include: utf-16le, utf16-be, utf32-le, utf32-be, utf-7, and utf-8
405+
# Supported unicode types include: utf-16le, utf16-be, utf32-le,
406+
# utf32-be, utf-7, and utf-8
407+
#
408+
# Providing 'mode' provides hints to the actual encoder as to how it
409+
# should encode the string.
348410
#
349-
# Providing 'mode' provides hints to the actual encoder as to how it should encode the string. Only UTF-7 and UTF-8 use "mode".
411+
# Only UTF-7 and UTF-8 use "mode".
350412
#
351-
# utf-7 by default does not encode alphanumeric and a few other characters. By specifying the mode of "all", then all of the characters are encoded, not just the non-alphanumeric set.
352-
# to_unicode(str, 'utf-7', 'all')
413+
# utf-7 by default does not encode alphanumeric and a few other
414+
# characters. By specifying the mode of "all", then all of the
415+
# characters are encoded, not just the non-alphanumeric set.
416+
# to_unicode(str, 'utf-7', 'all')
353417
#
354-
# utf-8 specifies that alphanumeric characters are used directly, eg "a" is just "a". However, there exist 6 different overlong encodings of "a" that are technically not valid, but parse just fine in most utf-8 parsers. (0xC1A1, 0xE081A1, 0xF08081A1, 0xF8808081A1, 0xFC80808081A1, 0xFE8080808081A1). How many bytes to use for the overlong enocding is specified providing 'size'.
355-
# to_unicode(str, 'utf-8', 'overlong', 2)
418+
# utf-8 specifies that alphanumeric characters are used directly, eg
419+
# "a" is just "a". However, there exist 6 different overlong
420+
# encodings of "a" that are technically not valid, but parse just fine
421+
# in most utf-8 parsers. (0xC1A1, 0xE081A1, 0xF08081A1, 0xF8808081A1,
422+
# 0xFC80808081A1, 0xFE8080808081A1). How many bytes to use for the
423+
# overlong enocding is specified providing 'size'. to_unicode(str,
424+
# 'utf-8', 'overlong', 2)
356425
#
357-
# Many utf-8 parsers also allow invalid overlong encodings, where bits that are unused when encoding a single byte are modified. Many parsers will ignore these bits, rendering simple string matching to be ineffective for dealing with UTF-8 strings. There are many more invalid overlong encodings possible for "a". For example, three encodings are available for an invalid 2 byte encoding of "a". (0xC1E1 0xC161 0xC121). By specifying "invalid", a random invalid encoding is chosen for the given byte size.
358-
# to_unicode(str, 'utf-8', 'invalid', 2)
426+
# Many utf-8 parsers also allow invalid overlong encodings, where bits
427+
# that are unused when encoding a single byte are modified. Many
428+
# parsers will ignore these bits, rendering simple string matching to
429+
# be ineffective for dealing with UTF-8 strings. There are many more
430+
# invalid overlong encodings possible for "a". For example, three
431+
# encodings are available for an invalid 2 byte encoding of "a".
432+
# (0xC1E1 0xC161 0xC121).
359433
#
360-
# utf-7 defaults to 'normal' utf-7 encoding
361-
# utf-8 defaults to 2 byte 'normal' encoding
434+
# By specifying "invalid", a random invalid encoding is chosen for the
435+
# given byte size. to_unicode(str, 'utf-8', 'invalid', 2)
362436
#
437+
# utf-7 defaults to 'normal' utf-7 encoding utf-8 defaults to 2 byte
438+
# 'normal' encoding
363439
def self.to_unicode(str='', type = 'utf-16le', mode = '', size = '')
364440
return '' if not str
365441
case type

msfpayload

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $args = Rex::Parser::Arguments.new(
3030
#
3131
def usage
3232
$stderr.puts("\n" +
33-
" Usage: #{$0} [<options>] <payload> [var=val] <[S]ummary|C|[P]erl|Rub[y]|[R]aw|[J]s|e[X]e|[D]ll|[V]BA|[W]ar|Pytho[N]>\n" +
33+
" Usage: #{$0} [<options>] <payload> [var=val] <[S]ummary|C|Cs[H]arp|[P]erl|Rub[Y]|[R]aw|[J]s|e[X]e|[D]ll|[V]BA|[W]ar|Pytho[N]>\n" +
3434
$args.usage)
3535
exit
3636
end
@@ -119,17 +119,18 @@ end
119119

120120
payload.datastore.merge! options
121121

122-
if (cmd =~ /^(p|y|r|d|c|j|x|b|v|w|n)/)
123-
fmt = 'perl' if (cmd =~ /^p/)
124-
fmt = 'ruby' if (cmd =~ /^y/)
125-
fmt = 'raw' if (cmd =~ /^(r|x|d)/)
126-
fmt = 'raw' if (cmd =~ /^v/)
127-
fmt = 'c' if (cmd == 'c')
128-
fmt = 'js_be' if (cmd =~ /^j/ and Rex::Arch.endian(payload.arch) == ENDIAN_BIG)
129-
fmt = 'js_le' if (cmd =~ /^j/ and ! fmt)
130-
fmt = 'java' if (cmd =~ /^b/)
131-
fmt = 'raw' if (cmd =~ /^w/)
132-
fmt = 'python' if (cmd =~ /^n/)
122+
if (cmd =~ /^(p|y|r|d|c|h|j|x|b|v|w|n)$/)
123+
fmt = 'perl' if (cmd =~ /^p$/)
124+
fmt = 'ruby' if (cmd =~ /^y$/)
125+
fmt = 'raw' if (cmd =~ /^(r|x|d)$/)
126+
fmt = 'raw' if (cmd =~ /^v$/)
127+
fmt = 'c' if (cmd =~ /^c$/)
128+
fmt = 'csharp' if (cmd =~ /^h$/)
129+
fmt = 'js_be' if (cmd =~ /^j$/ and Rex::Arch.endian(payload.arch) == ENDIAN_BIG)
130+
fmt = 'js_le' if (cmd =~ /^j$/ and ! fmt)
131+
fmt = 'java' if (cmd =~ /^b$/)
132+
fmt = 'raw' if (cmd =~ /^w$/)
133+
fmt = 'python' if (cmd =~ /^n$/)
133134
enc = options['ENCODER']
134135

135136
begin
@@ -144,7 +145,7 @@ if (cmd =~ /^(p|y|r|d|c|j|x|b|v|w|n)/)
144145

145146
$stdout.binmode
146147

147-
if (cmd =~ /^x/)
148+
if (cmd =~ /^x$/)
148149
note =
149150
"Created by msfpayload (http://www.metasploit.com).\n" +
150151
"Payload: " + payload.refname + "\n" +
@@ -170,7 +171,7 @@ if (cmd =~ /^(p|y|r|d|c|j|x|b|v|w|n)/)
170171
exit(-1)
171172
end
172173

173-
if(cmd =~ /^v/)
174+
if(cmd =~ /^v$/)
174175
exe = Msf::Util::EXE.to_win32pe($framework, buf)
175176
note =
176177
"'Created by msfpayload (http://www.metasploit.com).\r\n" +
@@ -183,7 +184,7 @@ if (cmd =~ /^(p|y|r|d|c|j|x|b|v|w|n)/)
183184
exit(0)
184185
end
185186

186-
if(cmd =~ /^d/)
187+
if(cmd =~ /^d$/)
187188
dll = Msf::Util::EXE.to_win32pe_dll($framework, buf)
188189
note =
189190
"Created by msfpayload (http://www.metasploit.com).\r\n" +
@@ -201,7 +202,7 @@ if (cmd =~ /^(p|y|r|d|c|j|x|b|v|w|n)/)
201202
exit(-1)
202203
end
203204

204-
if(cmd =~ /^w/)
205+
if(cmd =~ /^w$/)
205206
note =
206207
"Created by msfpayload (http://www.metasploit.com).\n" +
207208
"Payload: " + payload.refname + "\n" +
@@ -231,7 +232,7 @@ if (cmd =~ /^(p|y|r|d|c|j|x|b|v|w|n)/)
231232

232233
$stdout.write(buf)
233234

234-
elsif (cmd =~ /^(s|o)/)
235+
elsif (cmd =~ /^(s|o)$/)
235236
payload.datastore.import_options_from_s(rest.join('_|_'), '_|_')
236237
puts Msf::Serializer::ReadableText.dump_module(payload)
237238

msfvenom

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ $framework ||= Msf::Simple::Framework.create(
265265
if opts[:list]
266266
opts[:list].each do |mod|
267267
case mod
268-
when /payloads/i
268+
when /^payloads$/i
269269
$stderr.puts dump_payloads
270-
when /encoders/i
270+
when /^encoders$/i
271271
$stderr.puts dump_encoders(opts[:arch])
272-
when /nops/i
272+
when /^nops$/i
273273
$stderr.puts dump_nops
274-
when /all/i
274+
when /^all$/i
275275
$stderr.puts dump_payloads
276276
$stderr.puts dump_encoders
277277
$stderr.puts dump_nops
@@ -422,26 +422,26 @@ end
422422

423423
$stdout.binmode
424424

425-
if opts[:format] !~/ruby|rb|perl|pl|bash|sh|c|js|dll|elf/i
425+
if opts[:format] !~/^(ruby|rb|perl|pl|bash|sh|c|csharp|js|dll|elf)$/i
426426
exe = Msf::Util::EXE.to_executable_fmt($framework, opts[:arch], opts[:platform], payload_raw, opts[:format], exeopts)
427427
end
428428

429429
case opts[:format]
430-
when /ruby|rb|perl|pl|bash|^sh$|^c$|js_le|raw|^py/i
430+
when /^(ruby|rb|perl|pl|bash|sh|c|csharp|js_le|raw|py)$/i
431431
$stdout.write Msf::Simple::Buffer.transform(payload_raw, opts[:format])
432-
when /asp$/
432+
when /^asp$/
433433
asp = Msf::Util::EXE.to_win32pe_asp($framework, payload_raw, exeopts)
434434
$stdout.puts asp
435-
when /aspx/
435+
when /^aspx$/
436436
aspx = Msf::Util::EXE.to_win32pe_aspx($framework, payload_raw, exeopts)
437437
$stdout.puts aspx
438-
when /js_be/i
438+
when /^js_be$/i
439439
if Rex::Arch.endian(payload.arch) != ENDIAN_BIG
440440
print_error("Big endian format selected for a non big endian payload")
441441
exit
442442
end
443443
$stdout.puts Msf::Simple::Buffer.transform(payload_raw, opts[:format])
444-
when /java/i
444+
when /^java$/i
445445
if(!exe and payload.platform.platforms.index(Msf::Module::Platform::Java))
446446
exe = payload.generate_jar.pack
447447
end
@@ -451,75 +451,75 @@ when /java/i
451451
else
452452
print_error("Could not generate payload format")
453453
end
454-
when /elf/i
454+
when /^elf$/i
455455
if (opts[:platform].index(Msf::Module::Platform::Linux))
456456
elf = case opts[:arch]
457-
when /x64/; Msf::Util::EXE.to_linux_x64_elf($framework, payload_raw, exeopts)
458-
when /x86/; Msf::Util::EXE.to_linux_x86_elf($framework, payload_raw, exeopts)
459-
when /arm/; Msf::Util::EXE.to_linux_armle_elf($framework, payload_raw, exeopts)
457+
when /^x64$/; Msf::Util::EXE.to_linux_x64_elf($framework, payload_raw, exeopts)
458+
when /^x86$/; Msf::Util::EXE.to_linux_x86_elf($framework, payload_raw, exeopts)
459+
when /^arm$/; Msf::Util::EXE.to_linux_armle_elf($framework, payload_raw, exeopts)
460460
end
461461
elsif(opts[:platform].index(Msf::Module::Platform::BSD))
462462
elf = case opts[:arch]
463-
when /x86/; Msf::Util::EXE.to_bsd_x86_elf($framework, payload_raw, exeopts)
463+
when /^x86$/; Msf::Util::EXE.to_bsd_x86_elf($framework, payload_raw, exeopts)
464464
end
465465
elsif(opts[:platform].index(Msf::Module::Platform::Solaris))
466466
elf = case opts[:arch]
467-
when /x86/; Msf::Util::EXE.to_solaris_x86_elf($framework, payload_raw, exeopts)
467+
when /^x86$/; Msf::Util::EXE.to_solaris_x86_elf($framework, payload_raw, exeopts)
468468
end
469469
end
470470
if elf.nil?
471471
print_error("This format does not support that architecture")
472472
exit
473473
end
474474
$stdout.write elf
475-
when /macho/i
475+
when /^macho$/i
476476
bin = case opts[:arch]
477-
when /x64/; Msf::Util::EXE.to_osx_x64_macho($framework, payload_raw, exeopts)
478-
when /x86/; Msf::Util::EXE.to_osx_x86_macho($framework, payload_raw, exeopts)
479-
when /arm/; Msf::Util::EXE.to_osx_arm_macho($framework, payload_raw, exeopts)
480-
when /ppc/; Msf::Util::EXE.to_osx_ppc_macho($framework, payload_raw, exeopts)
477+
when /^x64$/; Msf::Util::EXE.to_osx_x64_macho($framework, payload_raw, exeopts)
478+
when /^x86$/; Msf::Util::EXE.to_osx_x86_macho($framework, payload_raw, exeopts)
479+
when /^arm$/; Msf::Util::EXE.to_osx_arm_macho($framework, payload_raw, exeopts)
480+
when /^ppc$/; Msf::Util::EXE.to_osx_ppc_macho($framework, payload_raw, exeopts)
481481
end
482482
if bin.nil?
483483
print_error("This format does not support that architecture")
484484
exit
485485
end
486486
$stdout.write bin
487-
when /dll/i
487+
when /^dll$/i
488488
dll = case opts[:arch]
489-
when /x86/; Msf::Util::EXE.to_win32pe_dll($framework, payload_raw)
490-
when /x64|x86_64/; Msf::Util::EXE.to_win64pe_dll($framework, payload_raw)
489+
when /^x86$/; Msf::Util::EXE.to_win32pe_dll($framework, payload_raw)
490+
when /^(x64|x86_64)$/; Msf::Util::EXE.to_win64pe_dll($framework, payload_raw)
491491
end
492492
if dll.nil?
493493
print_error("This format does not support that architecture")
494494
exit
495495
end
496496

497497
$stdout.write dll
498-
when /exe/i
498+
when /^exe$/i
499499
$stdout.write exe
500-
when /exe-small/i
501-
when /vba/i
500+
when /^exe-small$/i
501+
when /^vba$/i
502502
vba = Msf::Util::EXE.to_vba($framework, payload_raw)
503503
$stdout.puts vba
504-
when /vba-exe/i
504+
when /^vba-exe$/i
505505
exe = Msf::Util::EXE.to_win32pe($framework, payload_raw)
506506
vba = Msf::Util::EXE.to_exe_vba(exe)
507507
$stdout.puts vba
508-
when /vbs/i
508+
when /^vbs$/i
509509
exe = Msf::Util::EXE.to_win32pe($framework, payload_raw)
510510
vbs = Msf::Util::EXE.to_exe_vbs(exe)
511511
$stdout.puts vbs
512-
when /war/i
512+
when /^war$/i
513513
if (!exe and payload.platform.platforms.index(Msf::Module::Platform::Java))
514514
exe = payload.generate_war.pack
515515
else
516516
exe = Msf::Util::EXE.to_jsp_war(exe)
517517
end
518518
$stdout.write exe
519-
when /psh/i
519+
when /^psh$/i
520520
psh = Msf::Util::EXE.to_win32pe_psh($framework, payload_raw, exeopts)
521521
$stdout.write psh
522-
when /psh-net/i
522+
when /^psh-net$/i
523523
psh = Msf::Util::EXE.to_win32pe_psh_net($framework, payload_raw, exeopts)
524524
$stdout.write psh
525525
else

0 commit comments

Comments
 (0)