Module: Msf::Payload::Dalvik

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

Instance Method Summary collapse

Instance Method Details

#fix_dex_header(dexfile) ⇒ Object

Fix the dex header checksum and signature source.android.com/tech/dalvik/dex-format.html


10
11
12
13
14
15
# File 'lib/msf/core/payload/dalvik.rb', line 10

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

#generateObject

Used by stagers to construct the payload jar file as a String


26
27
28
# File 'lib/msf/core/payload/dalvik.rb', line 26

def generate
  generate_jar.pack
end

#generate_stageObject

We could compile the .class files with dx here


20
21
# File 'lib/msf/core/payload/dalvik.rb', line 20

def generate_stage
end

#java_string(str) ⇒ Object


30
31
32
# File 'lib/msf/core/payload/dalvik.rb', line 30

def java_string(str)
  [str.length].pack("N") + str
end