mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-11-12 11:52:01 +01:00
This patch adds support for java byte array output (useful for sticking shellcode into java applets).
git-svn-id: file:///home/svn/framework3/trunk@4880 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
ebb84d5b32
commit
793048c879
@ -29,6 +29,8 @@ module Buffer
|
||||
buf = Rex::Text.to_unescape(buf, ENDIAN_BIG)
|
||||
when 'js_le'
|
||||
buf = Rex::Text.to_unescape(buf, ENDIAN_LITTLE)
|
||||
when 'java'
|
||||
buf = Rex::Text.to_java(buf)
|
||||
else
|
||||
raise ArgumentError, "Unsupported buffer format: #{fmt}", caller
|
||||
end
|
||||
@ -51,6 +53,8 @@ module Buffer
|
||||
buf = Rex::Text.to_c_comment(buf)
|
||||
when 'js_be', 'js_le'
|
||||
buf = Rex::Text.to_js_comment(buf)
|
||||
when 'java'
|
||||
buf = Rex::Text.to_c_comment(buf)
|
||||
else
|
||||
raise ArgumentError, "Unsupported buffer format: #{fmt}", caller
|
||||
end
|
||||
|
@ -106,6 +106,29 @@ module Text
|
||||
return hexify(str, wrap, '"', '" .', '', '";')
|
||||
end
|
||||
|
||||
#
|
||||
# Converts a raw string into a java byte array
|
||||
#
|
||||
def self.to_java(str)
|
||||
buff = "byte shell[] = new byte[]\n{\n"
|
||||
cnt = 0
|
||||
max = 0
|
||||
str.unpack('C*').each do |c|
|
||||
buff << ", " if max > 0
|
||||
buff << "\t" if max == 0
|
||||
buff << sprintf('(byte) 0x%.2x', c)
|
||||
max +=1
|
||||
cnt +=1
|
||||
|
||||
if (max > 7)
|
||||
buff << ",\n" if cnt != str.length
|
||||
max = 0
|
||||
end
|
||||
end
|
||||
buff << "\n};\n"
|
||||
return buff
|
||||
end
|
||||
|
||||
#
|
||||
# Creates a perl-style comment
|
||||
#
|
||||
|
@ -56,12 +56,13 @@ cmd = ARGV.pop.downcase
|
||||
# Populate the framework datastore
|
||||
options = ARGV.join(',')
|
||||
|
||||
if (cmd =~ /^(p|r|c|j|x)/)
|
||||
if (cmd =~ /^(p|r|c|j|x|b)/)
|
||||
fmt = 'perl' if (cmd =~ /^p/)
|
||||
fmt = 'raw' if (cmd =~ /^(r|x)/)
|
||||
fmt = 'c' if (cmd == 'c')
|
||||
fmt = 'js_be' if (cmd =~ /^j/ and Rex::Arch.endian(payload.arch) == ENDIAN_BIG)
|
||||
fmt = 'js_le' if (cmd =~ /^j/ and ! fmt)
|
||||
fmt = 'java' if (cmd =~ /^b/)
|
||||
|
||||
begin
|
||||
buf = payload.generate_simple(
|
||||
|
Loading…
Reference in New Issue
Block a user