This commit adds support for C# byte arrays for the assembly payloads.
parent
fe32a747a3
commit
d0e1e4df0a
|
@ -31,6 +31,8 @@ module Buffer
|
||||||
buf = Rex::Text.to_bash(buf)
|
buf = Rex::Text.to_bash(buf)
|
||||||
when 'c'
|
when 'c'
|
||||||
buf = Rex::Text.to_c(buf)
|
buf = Rex::Text.to_c(buf)
|
||||||
|
when 'csharp'
|
||||||
|
buf = Rex::Text.to_csharp(buf)
|
||||||
when 'js_be'
|
when 'js_be'
|
||||||
buf = Rex::Text.to_unescape(buf, ENDIAN_BIG)
|
buf = Rex::Text.to_unescape(buf, ENDIAN_BIG)
|
||||||
when 'js_le'
|
when 'js_le'
|
||||||
|
@ -59,6 +61,8 @@ module Buffer
|
||||||
buf = Rex::Text.to_bash_comment(buf)
|
buf = Rex::Text.to_bash_comment(buf)
|
||||||
when 'c'
|
when 'c'
|
||||||
buf = Rex::Text.to_c_comment(buf)
|
buf = Rex::Text.to_c_comment(buf)
|
||||||
|
when 'csharp'
|
||||||
|
buf = Rex::Text.to_c_comment(buf)
|
||||||
when 'js_be', 'js_le'
|
when 'js_be', 'js_le'
|
||||||
buf = Rex::Text.to_js_comment(buf)
|
buf = Rex::Text.to_js_comment(buf)
|
||||||
when 'java'
|
when 'java'
|
||||||
|
@ -74,7 +78,7 @@ module Buffer
|
||||||
# Returns the list of supported formats
|
# Returns the list of supported formats
|
||||||
#
|
#
|
||||||
def self.transform_formats
|
def self.transform_formats
|
||||||
['raw','ruby','rb','perl','pl','bash','sh','c','js_be','js_le','java','python','py']
|
['raw','ruby','rb','perl','pl','bash','sh','c','csharp','js_be','js_le','java','python','py']
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -82,6 +82,17 @@ module Text
|
||||||
return hexify(str, wrap, '"', '"', "unsigned char #{name}[] = \n", '";')
|
return hexify(str, wrap, '"', '"', "unsigned char #{name}[] = \n", '";')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.to_csharp(str, wrap = DefaultWrap, name = "buf")
|
||||||
|
ret = "byte[] #{name} = new byte[#{str.length}] {"
|
||||||
|
i = -1;
|
||||||
|
while (i += 1) < str.length
|
||||||
|
ret << "\n" if i%(wrap/4) == 0
|
||||||
|
ret << "0x" << str[i].unpack("H*")[0] << ","
|
||||||
|
end
|
||||||
|
ret = ret[0..ret.length-2] #cut off last comma
|
||||||
|
ret << " };\n"
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Creates a c-style comment
|
# Creates a c-style comment
|
||||||
#
|
#
|
||||||
|
|
|
@ -125,6 +125,7 @@ if (cmd =~ /^(p|y|r|d|c|j|x|b|v|w|n)/)
|
||||||
fmt = 'raw' if (cmd =~ /^(r|x|d)/)
|
fmt = 'raw' if (cmd =~ /^(r|x|d)/)
|
||||||
fmt = 'raw' if (cmd =~ /^v/)
|
fmt = 'raw' if (cmd =~ /^v/)
|
||||||
fmt = 'c' if (cmd == 'c')
|
fmt = 'c' if (cmd == 'c')
|
||||||
|
fmt = 'csharp' if (cmd == 'csharp')
|
||||||
fmt = 'js_be' if (cmd =~ /^j/ and Rex::Arch.endian(payload.arch) == ENDIAN_BIG)
|
fmt = 'js_be' if (cmd =~ /^j/ and Rex::Arch.endian(payload.arch) == ENDIAN_BIG)
|
||||||
fmt = 'js_le' if (cmd =~ /^j/ and ! fmt)
|
fmt = 'js_le' if (cmd =~ /^j/ and ! fmt)
|
||||||
fmt = 'java' if (cmd =~ /^b/)
|
fmt = 'java' if (cmd =~ /^b/)
|
||||||
|
|
Loading…
Reference in New Issue