android_parser 2.4.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a338a6e092fc1dc50e3c1688f165109dbb900397e51b968b0397877aa4f6a030
4
- data.tar.gz: 5fbbb6f2630a3a4d2a7b090106c53dd45ac9b8ec6b4be9cb37477d1c5615c594
3
+ metadata.gz: bc3206bde4ce793fb477360fd78062daa372bf5dba443d3521d86b8ffaf0a91f
4
+ data.tar.gz: 15c49cc70cb8ac8c561bdb2f5d6e108c9ff6d095bf82b56996ee1c012c874b37
5
5
  SHA512:
6
- metadata.gz: 7c270a031fc08369c7afa11e274da90c3aa732b86cade0b10066a227de49bafb30b0dd8b14ce7b77a3a347fda85bfefcf5796c55f8b2a5c645309d625030f01c
7
- data.tar.gz: e850a3d98e71801a57686f8b890d45fa1d65d3459805b6855f9451990a960ba6f608ed147c88ea9ded54fb40ab8c49b4d89d19e014172aa24b8a36ba329dc7d9
6
+ metadata.gz: 470a1645dc911bc2f41405ac41beb93d570a4885ab2413f61c7f413ce38477a7bc0c3da7162de40cd48b97799dcfd4eab12f1335a9c48a40e2555720f60a39b4
7
+ data.tar.gz: 55b1870a03b25be087e20e75c2d32a92c15a5a2a1a7d6290970a1ce0af78b44399fe5e9957fb8f111c53d9c2c59e98648b594cf7aad8d16666ff77775a3cfb10
@@ -0,0 +1,9 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "21:00"
8
+ timezone: Asia/Shanghai
9
+ open-pull-requests-limit: 10
@@ -0,0 +1,26 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby: [ ruby-2.5, ruby-2.6, ruby-2.7, ruby-3.0 ]
14
+ os: [ ubuntu-latest, macos-latest ]
15
+ runs-on: ${{ matrix.os }}
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+
20
+ - uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ bundler-cache: true
24
+
25
+ - name: bundle exec rspec
26
+ run: bundle exec rspec --format progress --force-colour
data/.gitignore CHANGED
@@ -10,6 +10,7 @@ doc
10
10
 
11
11
  # bundler
12
12
  .bundle
13
+ Gemfile.lock
13
14
 
14
15
  # rvm
15
16
  .ruby-version
@@ -17,7 +18,7 @@ doc
17
18
  # jeweler generated
18
19
  #pkg # upload gem file to server
19
20
 
20
- # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
21
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
21
22
  #
22
23
  # * Create a file at ~/.gitignore
23
24
  # * Include files you want ignored
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --require spec_helper
2
+ --format documentation
3
+ --color
data/CHANGELOG.md CHANGED
@@ -1,45 +1,60 @@
1
1
  # ChangeLog
2
+
3
+ ## 2.5.0
4
+
5
+ > New begins!
2
6
  ## 0.7.0
7
+
3
8
  * implement Apk#signs, Apk#certificates and Manifest#version_name (#14, #15)
4
9
  * bugfix
5
10
 
6
11
  ## 0.6.0
12
+
7
13
  * implement Android::Apk#layouts(#10), Android::Apk#icon(#11), Android::Apk#label(#12),
8
14
  * fix bug (#13)
9
15
 
10
16
  ## 0.5.1
17
+
11
18
  * [#8] add Android::Manifest#label
12
19
  * [#7] fix wrong boolean value in manifest parser
13
20
  * [#6] add accessor Android::Manifest#doc
14
21
 
15
22
  ## 0.5.0
23
+
16
24
  * [issue #1] implement Android::Resource#find, #res_readable_id, #res_hex_id methods
17
25
 
18
26
  ## 0.4.2
27
+
19
28
  * fix bugs(#2, #3)
20
29
  * divide change log from readme
21
30
 
22
31
  ## 0.4.1
32
+
23
33
  * fix typo
24
34
  * add document
25
35
 
26
36
  ## 0.4.0
37
+
27
38
  * add resource parser
28
39
  * enhance dex parser
29
40
 
30
41
  ## 0.3.0
42
+
31
43
  * add and change name space
32
44
  * add Android::Utils module and some util methods
33
45
  * add Apk#entry, Apk#each_entry, and Apk#time methods,
34
46
 
35
47
  ## 0.2.0
48
+
36
49
  * update documents
37
50
  * add Apk::Dex#each_strings, Apk::Dex#each_class_names
38
51
 
39
52
  ## 0.1.2
53
+
40
54
  * fix bug(improve android binary xml parser)
41
55
 
42
56
  ## 0.1.1
57
+
43
58
  * fix bug(failed to initialize Apk::Manifest::Meta class)
44
59
  * replace iconv to String#encode(for ruby1.9)
45
60
 
data/Gemfile CHANGED
@@ -1,18 +1,10 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
- gem "rubyzip", ">=1.0.0"
1
+ source 'http://rubygems.org'
6
2
 
7
- # Add dependencies to develop your gem here.
8
- # Include everything needed to run rake, tests, features, etc.
9
- group :development do
10
- gem "rspec-its", ">= 1.2.0"
11
- gem "rspec-collection_matchers", ">= 1.1.0"
12
- gem "rspec-mocks", ">= 3.6.0"
13
- gem "bundler", ">= 1.1.5"
14
- gem "jeweler"
15
- gem "yard", require: false
16
- gem "redcarpet"
17
- gem "simplecov", require: false
18
- end
3
+ # Specify your gem's dependencies in android_parser.gemspec
4
+ gemspec
5
+
6
+ # group :development do
7
+ # gem 'awesome_print'
8
+ # gem 'debase'
9
+ # gem 'ruby-debug-ide'
10
+ # end
data/README.md CHANGED
@@ -1,25 +1,30 @@
1
- # ruby_apk
2
- Android Apk static analysis library for Ruby.
1
+ # android_parser
3
2
 
4
- [![Gem Version](https://badge.fury.io/rb/ruby_apk.png)](http://badge.fury.io/rb/ruby_apk)
5
- [![Build Status](https://travis-ci.org/playtestcloud/ruby_apk.svg?branch=master)](https://travis-ci.org/playtestcloud/ruby_apk)
6
- [![Dependency Status](https://gemnasium.com/badges/github.com/playtestcloud/ruby_apk.png)](https://gemnasium.com/github.com/playtestcloud/ruby_apk)
3
+ Android Apk static analysis parser library for Ruby, forked from [playtestcloud/ruby_apk](https://github.com/playtestcloud/ruby_apk).
7
4
 
8
5
  ## Requirements
9
- - ruby(>=2.2.2)
6
+
7
+ - ruby (>= 2.5)
10
8
 
11
9
  ## Install
12
- $ gem install ruby_apk
10
+
11
+ ```bash
12
+ gem install android_parser
13
+ ```
13
14
 
14
15
  ## Usage
16
+
15
17
  ### Initialize
18
+
16
19
  ```ruby
17
- require 'ruby_apk'
18
- apk = Android::Apk.new('sample.apk') # set apk file path
20
+ require 'android_parser'
21
+
22
+ apk = Android::Apk.new('sample.apk') # set apk file path
19
23
  ```
20
24
 
21
25
  ### Apk
22
26
  #### Listing files in Apk
27
+
23
28
  ```ruby
24
29
  # listing files in apk
25
30
  apk = Android::Apk.new('sample.apk')
@@ -29,126 +34,139 @@ end
29
34
  ```
30
35
 
31
36
  #### Find files in Apk
37
+
32
38
  ```ruby
33
- apk = Android::Apk.new('sample.apk')
34
- elf_files = apk.find{|name, data| data[0..3] == [0x7f, 0x45, 0x4c, 0x46] } # ELF magic number
39
+ apk = Android::Apk.new('sample.apk')
40
+ elf_files = apk.find{|name, data| data[0..3] == [0x7f, 0x45, 0x4c, 0x46] } # ELF magic number
35
41
  ```
36
42
 
37
43
  #### Extract icon data in Apk (since 0.6.0)
44
+
38
45
  ```ruby
39
- apk = Android::Apk.new('sample.apk')
40
- icons = apk.icon # { "res/drawable-hdpi/ic_launcher.png" => "\x89PNG\x0D\x0A...", ... }
41
- icons.each do |name, data|
42
- File.open(File.basename(name), 'wb') {|f| f.write data } # save to file.
43
- end
46
+ apk = Android::Apk.new('sample.apk')
47
+ icons = apk.icon # { "res/drawable-hdpi/ic_launcher.png" => "\x89PNG\x0D\x0A...", ... }
48
+ icons.each do |name, data|
49
+ File.open(File.basename(name), 'wb') {|f| f.write data } # save to file.
50
+ end
44
51
  ```
45
52
 
46
53
  #### Extract signature and certificate information from Apk (since v0.7.0)
54
+
47
55
  ```ruby
48
- apk = Android::Apk.new('sample.apk')
49
- signs = apk.signs # retrun Hash(key: signature file path, value: OpenSSL::PKCS7)
50
- signs.each do |path, sign|
51
- puts path # => "MATA-INF/CERT.RSA" or ...
52
- puts sign # => "-----BEGIN PKCS7-----\n..." PKCS7 object
53
- end
56
+ apk = Android::Apk.new('sample.apk')
57
+ signs = apk.signs # retrun Hash(key: signature file path, value: OpenSSL::PKCS7)
58
+ signs.each do |path, sign|
59
+ puts path # => "MATA-INF/CERT.RSA" or ...
60
+ puts sign # => "-----BEGIN PKCS7-----\n..." PKCS7 object
61
+ end
54
62
 
55
- certs = apk.certificates # retrun Hash(key: signature file path, value: OpenSSL::X509::Certificate)
56
- certs.each do |path, cert|
57
- puts path # => "MATA-INF/CERT.RSA" or ...
58
- puts cert # => "-----BEGIN CERTIFICATE-----\n..." # X509::Certificate object
59
- end
63
+ certs = apk.certificates # retrun Hash(key: signature file path, value: OpenSSL::X509::Certificate)
64
+ certs.each do |path, cert|
65
+ puts path # => "MATA-INF/CERT.RSA" or ...
66
+ puts cert # => "-----BEGIN CERTIFICATE-----\n..." # X509::Certificate object
67
+ end
60
68
  ```
61
69
  Note: Most apks have only one signature and cerficate.
62
70
 
63
71
  ### Manifest
72
+
64
73
  #### Get readable xml
74
+
65
75
  ```ruby
66
- apk = Android::Apk.new('sample.apk')
67
- manifest = apk.manifest
68
- puts manifest.to_xml
76
+ apk = Android::Apk.new('sample.apk')
77
+ manifest = apk.manifest
78
+ puts manifest.to_xml
69
79
  ```
70
80
 
71
81
  #### Listing components and permissions
82
+
72
83
  ```ruby
73
- apk = Android::Apk.new('sample.apk')
74
- manifest = apk.manifest
75
- # listing components
76
- manifest.components.each do |c| # 'c' is Android::Manifest::Component object
77
- puts "#{c.type}: #{c.name}"
78
- c.intent_filters.each do |filter|
79
- puts "\t#{filter.type}"
80
- end
84
+ apk = Android::Apk.new('sample.apk')
85
+ manifest = apk.manifest
86
+ # listing components
87
+ manifest.components.each do |c| # 'c' is Android::Manifest::Component object
88
+ puts "#{c.type}: #{c.name}"
89
+ c.intent_filters.each do |filter|
90
+ puts "\t#{filter.type}"
81
91
  end
92
+ end
82
93
 
83
- # listing use-permission tag
84
- manifest.use_permissions.each do |permission|
85
- puts permission
86
- end
94
+ # listing use-permission tag
95
+ manifest.use_permissions.each do |permission|
96
+ puts permission
97
+ end
87
98
  ```
88
99
 
89
100
  #### Extract application label string
101
+
90
102
  ```ruby
91
- apk = Android::Apk.new('sample.apk')
92
- puts apk.manifest.label
103
+ apk = Android::Apk.new('sample.apk')
104
+ puts apk.manifest.label
93
105
  ```
94
106
 
95
107
  ### Resource
108
+
96
109
  #### Extract resource strings from apk
110
+
97
111
  ```ruby
98
- apk = Android::Apk.new('sample.apk')
99
- rsc = apk.resource
100
- rsc.strings.each do |str|
101
- puts str
102
- end
112
+ apk = Android::Apk.new('sample.apk')
113
+ rsc = apk.resource
114
+ rsc.strings.each do |str|
115
+ puts str
116
+ end
103
117
  ```
104
118
 
105
119
  #### Parse resource file directly
120
+
106
121
  ```ruby
107
- rsc_data = File.open('resources.arsc', 'rb').read{|f| f.read }
108
- rsc = Android::Resource.new(rsc_data)
122
+ rsc_data = File.open('resources.arsc', 'rb').read{|f| f.read }
123
+ rsc = Android::Resource.new(rsc_data)
109
124
  ```
110
125
 
111
126
  ### Resolve resource id
127
+
112
128
  This feature supports only srting resources for now.
113
129
 
114
130
  ```ruby
115
- apk = Android::Apk.new('sample.apk')
116
- rsc = apk.resource
117
-
118
- # assigns readable resource id
119
- puts rsc.find('@string/app_name') # => 'application name'
131
+ apk = Android::Apk.new('sample.apk')
132
+ rsc = apk.resource
120
133
 
121
- # assigns hex resource id
122
- puts rsc.find('@0x7f040000') # => 'application name'
134
+ # assigns readable resource id
135
+ puts rsc.find('@string/app_name') # => 'application name'
123
136
 
124
- # you can set lang attribute.
125
- puts rsc.find('@0x7f040000', :lang => 'ja')
126
- ```
137
+ # assigns hex resource id
138
+ puts rsc.find('@0x7f040000') # => 'application name'
127
139
 
140
+ # you can set lang attribute.
141
+ puts rsc.find('@0x7f040000', :lang => 'ja')
142
+ ```
128
143
 
129
144
  ### Dex
145
+
130
146
  #### Extract dex information
147
+
131
148
  ```ruby
132
- apk = Android::Apk.new('sample.apk')
133
- dex = apk.dex
134
- # listing string table in dex
135
- dex.strings.each do |str|
136
- puts str
137
- end
149
+ apk = Android::Apk.new('sample.apk')
150
+ dex = apk.dex
151
+ # listing string table in dex
152
+ dex.strings.each do |str|
153
+ puts str
154
+ end
138
155
 
139
- # listing all class names
140
- dex.classes.each do |cls| # cls is Android::Dex::ClassInfo
141
- puts "class: #{cls.name}"
142
- cls.virtual_methods.each do |m| # Android::Dex::MethodInfo
143
- puts "\t#{m.definition}" # puts method definition
144
- end
156
+ # listing all class names
157
+ dex.classes.each do |cls| # cls is Android::Dex::ClassInfo
158
+ puts "class: #{cls.name}"
159
+ cls.virtual_methods.each do |m| # Android::Dex::MethodInfo
160
+ puts "\t#{m.definition}" # puts method definition
145
161
  end
162
+ end
146
163
  ```
147
164
 
148
165
  #### Parse dex file directly
166
+
149
167
  ```ruby
150
- dex_data = File.open('classes.dex','rb').read{|f| f.read }
151
- dex = Android::Dex.new(dex_data)
168
+ dex_data = File.open('classes.dex','rb').read{|f| f.read }
169
+ dex = Android::Dex.new(dex_data)
152
170
  ```
153
171
 
154
172
 
data/Rakefile CHANGED
@@ -1,44 +1,10 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
3
+ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
4
+ require 'android_parser'
13
5
  require 'bundler/gem_tasks'
14
-
15
- # require 'jeweler'
16
- # Jeweler::Tasks.new do |gem|
17
- # # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
18
- # gem.name = "android_parser"
19
- # gem.homepage = "https://github.com/icyleaf/ruby_apk"
20
- # gem.license = "MIT"
21
- # gem.summary = %Q{static analysis tool for android apk}
22
- # gem.description = %Q{static analysis tool for android apk}
23
- # gem.email = "info@securebrain.co.jp"
24
- # gem.authors = ["SecureBrain"]
25
- # # dependencies defined in Gemfile
26
- # end
27
- # Jeweler::RubygemsDotOrgTasks.new
28
-
29
- require 'rspec/core'
30
6
  require 'rspec/core/rake_task'
31
- RSpec::Core::RakeTask.new(:spec) do |spec|
32
- spec.pattern = FileList['spec/**/*_spec.rb']
33
- end
34
-
35
7
 
36
- task :default => :spec
8
+ RSpec::Core::RakeTask.new(:spec)
37
9
 
38
- # require 'yard'
39
- # require 'yard/rake/yardoc_task'
40
- # YARD::Rake::YardocTask.new do |t|
41
- # t.files = ['lib/**/*.rb']
42
- # t.options = []
43
- # t.options << '--debug' << '--verbose' if $trace
44
- # end
10
+ task default: :spec
@@ -1,64 +1,35 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: ruby_apk 2.3.0 ruby lib
1
+ # frozen_string_literal: true
6
2
 
7
- Gem::Specification.new do |s|
8
- s.name = "android_parser".freeze
9
- s.version = "2.4.1"
3
+ # frozen_string_literal: true
10
4
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib".freeze]
13
- s.authors = ["SecureBrain".freeze]
14
- s.date = "2021-08-04"
15
- s.description = "static analysis tool for android apk".freeze
16
- s.email = "info@securebrain.co.jp".freeze
17
- s.extra_rdoc_files = [
18
- "CHANGELOG.md",
19
- "LICENSE.txt",
20
- "README.md"
21
- ]
22
- s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
- s.homepage = "https://github.com/icyleaf/ruby_apk".freeze
24
- s.licenses = ["MIT".freeze]
25
- s.rubygems_version = "3.0.3".freeze
26
- s.summary = "static analysis tool for android apk".freeze
5
+ lib = File.expand_path('../lib', __FILE__)
6
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
7
+ # require 'android_parser/version'
27
8
 
28
- if s.respond_to? :specification_version then
29
- s.specification_version = 4
9
+ Gem::Specification.new do |spec|
10
+ spec.name = 'android_parser'
11
+ spec.version = '2.5.0'
12
+ spec.authors = ['SecureBrain', 'icyleaf']
13
+ spec.email = ['info@securebrain.co.jp', 'icyleaf.cn@gmail.com']
14
+ spec.platform = Gem::Platform::RUBY
15
+ spec.summary = 'Static analysis tool for android apk since 2021'
16
+ spec.description = 'Static analysis tool for android apk since 2021'
17
+ spec.homepage = 'https://github.com/icyleaf/android_parser'
18
+ spec.license = 'MIT'
19
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ spec.require_paths = ['lib']
21
+ spec.required_ruby_version = '>= 2.5'
30
22
 
31
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
32
- s.add_runtime_dependency(%q<rubyzip>.freeze, [">= 1.0.0"])
33
- s.add_development_dependency(%q<rspec-its>.freeze, [">= 1.2.0"])
34
- s.add_development_dependency(%q<rspec-collection_matchers>.freeze, [">= 1.1.0"])
35
- s.add_development_dependency(%q<rspec-mocks>.freeze, [">= 3.6.0"])
36
- s.add_development_dependency(%q<bundler>.freeze, [">= 1.1.5"])
37
- s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
38
- s.add_development_dependency(%q<yard>.freeze, [">= 0"])
39
- s.add_development_dependency(%q<redcarpet>.freeze, [">= 0"])
40
- s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
41
- else
42
- s.add_dependency(%q<rubyzip>.freeze, [">= 1.0.0"])
43
- s.add_dependency(%q<rspec-its>.freeze, [">= 1.2.0"])
44
- s.add_dependency(%q<rspec-collection_matchers>.freeze, [">= 1.1.0"])
45
- s.add_dependency(%q<rspec-mocks>.freeze, [">= 3.6.0"])
46
- s.add_dependency(%q<bundler>.freeze, [">= 1.1.5"])
47
- s.add_dependency(%q<jeweler>.freeze, [">= 0"])
48
- s.add_dependency(%q<yard>.freeze, [">= 0"])
49
- s.add_dependency(%q<redcarpet>.freeze, [">= 0"])
50
- s.add_dependency(%q<simplecov>.freeze, [">= 0"])
51
- end
52
- else
53
- s.add_dependency(%q<rubyzip>.freeze, [">= 1.0.0"])
54
- s.add_dependency(%q<rspec-its>.freeze, [">= 1.2.0"])
55
- s.add_dependency(%q<rspec-collection_matchers>.freeze, [">= 1.1.0"])
56
- s.add_dependency(%q<rspec-mocks>.freeze, [">= 3.6.0"])
57
- s.add_dependency(%q<bundler>.freeze, [">= 1.1.5"])
58
- s.add_dependency(%q<jeweler>.freeze, [">= 0"])
59
- s.add_dependency(%q<yard>.freeze, [">= 0"])
60
- s.add_dependency(%q<redcarpet>.freeze, [">= 0"])
61
- s.add_dependency(%q<simplecov>.freeze, [">= 0"])
23
+ spec.add_dependency 'rubyzip', '>= 1.0', '< 3.0'
24
+
25
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') then
26
+ spec.add_dependency 'rexml', '> 3.0'
62
27
  end
63
- end
64
28
 
29
+ spec.add_development_dependency 'rspec-its', '>= 1.2.0'
30
+ spec.add_development_dependency 'rspec-collection_matchers', '>= 1.1.0'
31
+ spec.add_development_dependency 'rspec-mocks', '>= 3.6.0'
32
+ spec.add_development_dependency 'bundler', '>= 1.12'
33
+ spec.add_development_dependency 'rake', '>= 10.0'
34
+ # spec.add_development_dependency 'rspec', '~> 3.0'
35
+ end
data/lib/android/apk.rb CHANGED
@@ -1,8 +1,10 @@
1
- require 'zip' # need rubyzip gem -> doc: http://rubyzip.sourceforge.net/
1
+ # frozen_string_literal: true
2
+
2
3
  require 'digest/md5'
3
4
  require 'digest/sha1'
4
5
  require 'digest/sha2'
5
6
  require 'openssl'
7
+ require 'zip'
6
8
 
7
9
  module Android
8
10
  class NotApkFileError < StandardError; end
@@ -37,12 +39,14 @@ module Android
37
39
  # @raise [Android::NotFoundError] path file does'nt exist
38
40
  # @raise [Android::NotApkFileError] path file is not Apk file.
39
41
  def initialize(filepath)
42
+ Zip.warn_invalid_date = false
43
+
40
44
  @path = filepath
41
45
  raise NotFoundError, "'#{filepath}'" unless File.exist? @path
42
46
  begin
43
47
  @zip = Zip::File.open(@path)
44
48
  rescue Zip::Error => e
45
- raise NotApkFileError, e.message
49
+ raise NotApkFileError, e.message
46
50
  end
47
51
 
48
52
  @bindata = File.open(@path, 'rb') {|f| f.read }
@@ -51,7 +55,7 @@ module Android
51
55
  begin
52
56
  @resource = Android::Resource.new(self.file(RESOURCE))
53
57
  rescue => e
54
- $stderr.puts "failed to parse resource:#{e}"
58
+ $stderr.puts "failed to parse resource: #{e}"
55
59
  #$stderr.puts e.backtrace
56
60
  end
57
61
  begin
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rexml/document'
2
4
  require 'stringio'
3
5
 
4
-
5
6
  module Android
6
7
  # binary AXML parser
7
8
  # @see https://android.googlesource.com/platform/frameworks/base.git Android OS frameworks source
@@ -12,8 +13,10 @@ module Android
12
13
  #
13
14
  # /frameworks/base/libs/androidfw/ResourceTypes.cpp
14
15
  class AXMLParser
16
+ HEADER = "\x03\x00\x08\x00"
17
+
15
18
  def self.axml?(data)
16
- (data[0..3] == "\x03\x00\x08\x00")
19
+ (data[0..3] == HEADER)
17
20
  end
18
21
 
19
22
  # axml parse error
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rexml/document'
2
4
  require 'stringio'
3
5
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Android
3
4
  class Dex
@@ -39,7 +40,7 @@ module Android
39
40
  ACCESSORS.select{|e| ((e[:value] & @flag) != 0) }.map{|e| e[:name] }.join(' ')
40
41
  end
41
42
  end
42
-
43
+
43
44
  # access flag object for method in dex
44
45
  class MethodAccessFlag < AccessFlag
45
46
  ACCESSORS = [