Module: Android::Utils

Defined in:
lib/android/utils.rb

Overview

Utility methods

Class Method Summary collapse

Class Method Details

.apk?(path) ⇒ Boolean

path is apk file or not.

Parameters:

  • path (String)

    target file path

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
# File 'lib/android/utils.rb', line 8

def self.apk?(path)
  begin
    apk = Apk.new(path)
    return true
  rescue => e
    return false
  end
end

.cert?(data) ⇒ Boolean

data is cert file or not.

Parameters:

  • data (String)

    target data

Returns:

  • (Boolean)


29
30
31
32
33
# File 'lib/android/utils.rb', line 29

def self.cert?(data)
  data[0..1] == "\x30\x82"
rescue => e
  false
end

.dex?(data) ⇒ Boolean

data is dex file or not.

Parameters:

  • data (String)

    target data

Returns:

  • (Boolean)


38
39
40
41
42
# File 'lib/android/utils.rb', line 38

def self.dex?(data)
  data[0..7] == "\x64\x65\x78\x0a\x30\x33\x35\x00" # "dex\n035\0"
rescue => e
  false
end

.elf?(data) ⇒ Boolean

data is elf file or not.

Parameters:

  • data (String)

    target data

Returns:

  • (Boolean)


20
21
22
23
24
# File 'lib/android/utils.rb', line 20

def self.elf?(data)
  data[0..3] == "\x7f\x45\x4c\x46"
rescue => e
  false
end

.valid_dex?(data) ⇒ Boolean

data is valid dex file or not.

Parameters:

  • data (String)

    target data

Returns:

  • (Boolean)


47
48
49
50
51
52
# File 'lib/android/utils.rb', line 47

def self.valid_dex?(data)
  Android::Dex.new(data)
  true
rescue => e
  false
end