metasploit-framework/lib/msf/core/payload/dalvik.rb

36 lines
678 B
Ruby
Raw Normal View History

2013-04-12 17:35:03 +00:00
# -*- coding: binary -*-
require 'msf/core'
module Msf::Payload::Dalvik
2013-08-30 21:28:33 +00:00
#
# Fix the dex header checksum and signature
# http://source.android.com/tech/dalvik/dex-format.html
#
def fix_dex_header(dexfile)
dexfile = dexfile.unpack('a8LH40a*')
dexfile[2] = Digest::SHA1.hexdigest(dexfile[3])
dexfile[1] = Zlib.adler32(dexfile[2..-1].pack('H40a*'))
dexfile.pack('a8LH40a*')
end
2013-08-30 21:28:33 +00:00
#
# We could compile the .class files with dx here
#
def generate_stage
end
2013-04-12 17:35:03 +00:00
2013-08-30 21:28:33 +00:00
#
# Used by stagers to construct the payload jar file as a String
#
def generate
generate_jar.pack
end
2013-08-30 21:28:33 +00:00
def java_string(str)
[str.length].pack("N") + str
end
2013-04-12 17:35:03 +00:00
end