Class: Decompiler
- Inherits:
-
Object
- Object
- Decompiler
- Defined in:
- lib/decompiler/decompiler.rb
Class Method Summary collapse
- .convert_apk_to_jar ⇒ Object
- .convert_apkname_to_underscore ⇒ Object
- .execute ⇒ Object
- .exists(data_type, entity) ⇒ Object
- .my_hash ⇒ Object
- .run ⇒ Object
- .run_apktool ⇒ Object
- .run_dex2jar ⇒ Object
-
.set_apk_var(apk_loc = "") ⇒ Object
This method defines the instance variable @apk as the location of the APK file that the user has provided.
- .set_static_vars(opts = {}) ⇒ Object
Class Method Details
.convert_apk_to_jar ⇒ Object
59 60 61 |
# File 'lib/decompiler/decompiler.rb', line 59 def self.convert_apk_to_jar file_name = File.basename(@apk).sub(/.apk/, ".jar") end |
.convert_apkname_to_underscore ⇒ Object
55 56 57 |
# File 'lib/decompiler/decompiler.rb', line 55 def self.convert_apkname_to_underscore file_name = File.basename(@apk).underscore.tr(".", "_") end |
.execute ⇒ Object
50 51 52 53 |
# File 'lib/decompiler/decompiler.rb', line 50 def self.execute run_apktool run_dex2jar end |
.exists(data_type, entity) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/decompiler/decompiler.rb', line 25 def self.exists(data_type, entity) val = instance_variable_get ("@#{entity}".underscore) case data_type when "dir" Dir.exists?(val) when "file" File.exists?(val) end end |
.my_hash ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/decompiler/decompiler.rb', line 3 def self.my_hash { "apk" => "file", "apktool" => "file", "output directory" => "dir", "d2j-dex2jar .sh or .bat" => "file" } end |
.run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/decompiler/decompiler.rb', line 12 def self.run my_hash.each do |k,v| puts "Please specify the absolute location of the #{k}" instance_variable_set("@#{k}".underscore, gets.chomp) unless self.exists(v,k) redo end end execute rescue ::Interrupt puts "\nGoodbye" end |
.run_apktool ⇒ Object
63 64 65 |
# File 'lib/decompiler/decompiler.rb', line 63 def self.run_apktool system "java", "-jar", @apktool, "d", "-f", @apk, "#{@output_directory}/apktool_output/#{self.convert_apkname_to_underscore}" end |
.run_dex2jar ⇒ Object
67 68 69 70 71 |
# File 'lib/decompiler/decompiler.rb', line 67 def self.run_dex2jar path = "#{@output_directory}/dex2jar_output" Dir.mkdir path if not Dir.exist? path system @d2j_dex2jar_sh_or_bat, @apk, "-f", "-o", "#{path}/#{convert_apk_to_jar}" end |
.set_apk_var(apk_loc = "") ⇒ Object
This method defines the instance variable @apk as the location
of the APK file that the user has provided.
44 45 46 47 48 |
# File 'lib/decompiler/decompiler.rb', line 44 def self.set_apk_var(apk_loc = "") raise "NotAValidApkLocationValue" if !(apk_loc.kind_of?(String)) raise "NoAPKProvidedFromConfigFile" if apk_loc.empty? @apk = apk_loc end |
.set_static_vars(opts = {}) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/decompiler/decompiler.rb', line 35 def self.set_static_vars(opts={}) raise "NoOptionsProvidedFromConfigFile" if opts.empty? @apktool = opts[:apktool] @output_directory = opts[:output_directory] @d2j_dex2jar_sh_or_bat = opts[:d2j] end |