Class: BitwiseAntiSkid

Inherits:
Plugin
  • Object
show all
Includes:
CommonRegex, Logging
Defined in:
lib/dex-oracle/plugins/bitwise_antiskid.rb

Overview

Sample: 0e18bbf2a3539e5669be76ed4c468257ecfd3d36

Constant Summary collapse

STRING_DECRYPT =
Regexp.new(
  '^[ \t]*(' +
  CONST_STRING + '\s+' + \
  CONST_NUMBER + '\s+' \
  'invoke-static \{[vp]\d+, [vp]\d+\}, L([^;]+);->(Go_Learn_Something\(Ljava/lang/String;I\))Ljava/lang/String;' \
  '\s+' + \
  MOVE_RESULT_OBJECT + ')'
)
MODIFIER =
-> (_, output, out_reg) { "const-string #{out_reg}, \"#{output.split('').collect { |e| e.inspect[1..-2] }.join}\"" }

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, logger, #logger, logger=

Methods inherited from Plugin

apply_batch, apply_outputs, dumb_replace, init_plugins, plugin_classes, plugins

Constructor Details

#initialize(driver, smali_files, methods) ⇒ BitwiseAntiSkid

Returns a new instance of BitwiseAntiSkid.



22
23
24
25
26
27
# File 'lib/dex-oracle/plugins/bitwise_antiskid.rb', line 22

def initialize(driver, smali_files, methods)
  @driver = driver
  @smali_files = smali_files
  @methods = methods
  @optimizations = Hash.new(0)
end

Instance Attribute Details

#optimizationsObject (readonly)

Returns the value of attribute optimizations.



6
7
8
# File 'lib/dex-oracle/plugins/bitwise_antiskid.rb', line 6

def optimizations
  @optimizations
end

Instance Method Details

#processObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dex-oracle/plugins/bitwise_antiskid.rb', line 29

def process
  method_to_target_to_contexts = {}
  @methods.each do |method|
    logger.info("Decrypting Bitwise Anti-Skid #{method.descriptor}")
    target_to_contexts = {}
    target_to_contexts.merge!(decrypt_strings(method))
    target_to_contexts.map { |_, v| v.uniq! }
    method_to_target_to_contexts[method] = target_to_contexts unless target_to_contexts.empty?
  end

  made_changes = false
  made_changes |= Plugin.apply_batch(@driver, method_to_target_to_contexts, MODIFIER)

  made_changes
end