Skip to content

Commit

Permalink
Merge pull request #1 from trufae/master
Browse files Browse the repository at this point in the history
Make zip dependency optional and support passing the AXML file directly
  • Loading branch information
thadd committed Aug 5, 2016
2 parents 99c5212 + 0de6015 commit ca4041d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions axml2xml.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env ruby

require 'zip/zip'

DEBUG = true

Expand Down Expand Up @@ -37,10 +36,23 @@ def get_string(data, sit_offset, st_offset, string_index)
data = nil

# Get just the AndroidManifest.xml from the APK file
Zip::ZipFile.foreach(ARGV[0]) do |f|
if f.name.match(/AndroidManifest.xml/)
data = f.get_input_stream.read
begin
require 'zip/zip'
begin
Zip::ZipFile.foreach(ARGV[0]) do |f|
if f.name.match(/AndroidManifest.xml/)
data = f.get_input_stream.read
end
end
rescue Zip::ZipError
data = File.open(ARGV[0], "rb").read
end
rescue LoadError
data = File.open(ARGV[0], "rb").read
end

if data.length > 1024*1024
abort('Invalid source file')
end

num_strings = read_word(data, 16)
Expand Down

0 comments on commit ca4041d

Please sign in to comment.