android_parser 2.4.1 → 2.5.1

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: 8360af54a4093e8cc95844b8b7419e3190aed92f5aa6c832f0fd4f7e8ccd2f53
4
+ data.tar.gz: 1b8a9172fdf2b4f18c43cb0a342aa5244f7ad109cbfc8b8995d74d6de9fc34a9
5
5
  SHA512:
6
- metadata.gz: 7c270a031fc08369c7afa11e274da90c3aa732b86cade0b10066a227de49bafb30b0dd8b14ce7b77a3a347fda85bfefcf5796c55f8b2a5c645309d625030f01c
7
- data.tar.gz: e850a3d98e71801a57686f8b890d45fa1d65d3459805b6855f9451990a960ba6f608ed147c88ea9ded54fb40ab8c49b4d89d19e014172aa24b8a36ba329dc7d9
6
+ metadata.gz: 393956811a1cfcb6bd043cdc8c6494a1760a0558d6d12ce157ee9e08b67035499f702e15cf8d6baa7971572eb616c0de28ebc92003a4e9a32c18541eb82b7f7b
7
+ data.tar.gz: a7998f5d5e71b889c083f6b1d73f4d277bd7aecd6c412a5d4b14dc10bccf1104472dffde03c2a2280071f88c846906f15c80991d73689f2dd957a46270ac3fbf
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
7
+
8
+ - package-ecosystem: "github-actions"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "daily"
@@ -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, ruby-3.1, ruby-3.2 ]
14
+ os: [ ubuntu-latest, macos-latest ]
15
+ runs-on: ${{ matrix.os }}
16
+
17
+ steps:
18
+ - uses: actions/checkout@v3
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,65 @@
1
1
  # ChangeLog
2
+
3
+ ## 2.5.1
4
+
5
+ * Bugfix: Handle string resources referencing other resources.
6
+
7
+ ## 2.5.0
8
+
9
+ > New begins!
10
+
2
11
  ## 0.7.0
12
+
3
13
  * implement Apk#signs, Apk#certificates and Manifest#version_name (#14, #15)
4
14
  * bugfix
5
15
 
6
16
  ## 0.6.0
17
+
7
18
  * implement Android::Apk#layouts(#10), Android::Apk#icon(#11), Android::Apk#label(#12),
8
19
  * fix bug (#13)
9
20
 
10
21
  ## 0.5.1
22
+
11
23
  * [#8] add Android::Manifest#label
12
24
  * [#7] fix wrong boolean value in manifest parser
13
25
  * [#6] add accessor Android::Manifest#doc
14
26
 
15
27
  ## 0.5.0
28
+
16
29
  * [issue #1] implement Android::Resource#find, #res_readable_id, #res_hex_id methods
17
30
 
18
31
  ## 0.4.2
32
+
19
33
  * fix bugs(#2, #3)
20
34
  * divide change log from readme
21
35
 
22
36
  ## 0.4.1
37
+
23
38
  * fix typo
24
39
  * add document
25
40
 
26
41
  ## 0.4.0
42
+
27
43
  * add resource parser
28
44
  * enhance dex parser
29
45
 
30
46
  ## 0.3.0
47
+
31
48
  * add and change name space
32
49
  * add Android::Utils module and some util methods
33
50
  * add Apk#entry, Apk#each_entry, and Apk#time methods,
34
51
 
35
52
  ## 0.2.0
53
+
36
54
  * update documents
37
55
  * add Apk::Dex#each_strings, Apk::Dex#each_class_names
38
56
 
39
57
  ## 0.1.2
58
+
40
59
  * fix bug(improve android binary xml parser)
41
60
 
42
61
  ## 0.1.1
62
+
43
63
  * fix bug(failed to initialize Apk::Manifest::Meta class)
44
64
  * replace iconv to String#encode(for ruby1.9)
45
65
 
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,35 @@
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
+ [![Language](https://img.shields.io/badge/ruby-2.5+-701516.svg)](.github/workflows/ci.yml)
4
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/icyleaf/android_parser/ci.yml)](https://github.com/icyleaf/android_parser/actions/workflows/ci.yml)
5
+ [![Gem version](https://img.shields.io/gem/v/android_parser.svg?style=flat)](https://rubygems.org/gems/android_parser)
6
+ [![License](https://img.shields.io/badge/license-MIT-red.svg?style=flat)](LICENSE.txt)
7
+
8
+ Android Apk static analysis parser library for Ruby, forked from [playtestcloud/ruby_apk](https://github.com/playtestcloud/ruby_apk).
7
9
 
8
10
  ## Requirements
9
- - ruby(>=2.2.2)
11
+
12
+ - ruby (>= 2.5)
10
13
 
11
14
  ## Install
12
- $ gem install ruby_apk
15
+
16
+ ```bash
17
+ gem install android_parser
18
+ ```
13
19
 
14
20
  ## Usage
21
+
15
22
  ### Initialize
23
+
16
24
  ```ruby
17
- require 'ruby_apk'
18
- apk = Android::Apk.new('sample.apk') # set apk file path
25
+ require 'android_parser'
26
+
27
+ apk = Android::Apk.new('sample.apk') # set apk file path
19
28
  ```
20
29
 
21
30
  ### Apk
22
31
  #### Listing files in Apk
32
+
23
33
  ```ruby
24
34
  # listing files in apk
25
35
  apk = Android::Apk.new('sample.apk')
@@ -29,126 +39,139 @@ end
29
39
  ```
30
40
 
31
41
  #### Find files in Apk
42
+
32
43
  ```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
44
+ apk = Android::Apk.new('sample.apk')
45
+ elf_files = apk.find{|name, data| data[0..3] == [0x7f, 0x45, 0x4c, 0x46] } # ELF magic number
35
46
  ```
36
47
 
37
48
  #### Extract icon data in Apk (since 0.6.0)
49
+
38
50
  ```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
51
+ apk = Android::Apk.new('sample.apk')
52
+ icons = apk.icon # { "res/drawable-hdpi/ic_launcher.png" => "\x89PNG\x0D\x0A...", ... }
53
+ icons.each do |name, data|
54
+ File.open(File.basename(name), 'wb') {|f| f.write data } # save to file.
55
+ end
44
56
  ```
45
57
 
46
58
  #### Extract signature and certificate information from Apk (since v0.7.0)
59
+
47
60
  ```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
61
+ apk = Android::Apk.new('sample.apk')
62
+ signs = apk.signs # retrun Hash(key: signature file path, value: OpenSSL::PKCS7)
63
+ signs.each do |path, sign|
64
+ puts path # => "MATA-INF/CERT.RSA" or ...
65
+ puts sign # => "-----BEGIN PKCS7-----\n..." PKCS7 object
66
+ end
54
67
 
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
68
+ certs = apk.certificates # retrun Hash(key: signature file path, value: OpenSSL::X509::Certificate)
69
+ certs.each do |path, cert|
70
+ puts path # => "MATA-INF/CERT.RSA" or ...
71
+ puts cert # => "-----BEGIN CERTIFICATE-----\n..." # X509::Certificate object
72
+ end
60
73
  ```
61
74
  Note: Most apks have only one signature and cerficate.
62
75
 
63
76
  ### Manifest
77
+
64
78
  #### Get readable xml
79
+
65
80
  ```ruby
66
- apk = Android::Apk.new('sample.apk')
67
- manifest = apk.manifest
68
- puts manifest.to_xml
81
+ apk = Android::Apk.new('sample.apk')
82
+ manifest = apk.manifest
83
+ puts manifest.to_xml
69
84
  ```
70
85
 
71
86
  #### Listing components and permissions
87
+
72
88
  ```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
89
+ apk = Android::Apk.new('sample.apk')
90
+ manifest = apk.manifest
91
+ # listing components
92
+ manifest.components.each do |c| # 'c' is Android::Manifest::Component object
93
+ puts "#{c.type}: #{c.name}"
94
+ c.intent_filters.each do |filter|
95
+ puts "\t#{filter.type}"
81
96
  end
97
+ end
82
98
 
83
- # listing use-permission tag
84
- manifest.use_permissions.each do |permission|
85
- puts permission
86
- end
99
+ # listing use-permission tag
100
+ manifest.use_permissions.each do |permission|
101
+ puts permission
102
+ end
87
103
  ```
88
104
 
89
105
  #### Extract application label string
106
+
90
107
  ```ruby
91
- apk = Android::Apk.new('sample.apk')
92
- puts apk.manifest.label
108
+ apk = Android::Apk.new('sample.apk')
109
+ puts apk.manifest.label
93
110
  ```
94
111
 
95
112
  ### Resource
113
+
96
114
  #### Extract resource strings from apk
115
+
97
116
  ```ruby
98
- apk = Android::Apk.new('sample.apk')
99
- rsc = apk.resource
100
- rsc.strings.each do |str|
101
- puts str
102
- end
117
+ apk = Android::Apk.new('sample.apk')
118
+ rsc = apk.resource
119
+ rsc.strings.each do |str|
120
+ puts str
121
+ end
103
122
  ```
104
123
 
105
124
  #### Parse resource file directly
125
+
106
126
  ```ruby
107
- rsc_data = File.open('resources.arsc', 'rb').read{|f| f.read }
108
- rsc = Android::Resource.new(rsc_data)
127
+ rsc_data = File.open('resources.arsc', 'rb').read{|f| f.read }
128
+ rsc = Android::Resource.new(rsc_data)
109
129
  ```
110
130
 
111
131
  ### Resolve resource id
132
+
112
133
  This feature supports only srting resources for now.
113
134
 
114
135
  ```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'
136
+ apk = Android::Apk.new('sample.apk')
137
+ rsc = apk.resource
120
138
 
121
- # assigns hex resource id
122
- puts rsc.find('@0x7f040000') # => 'application name'
139
+ # assigns readable resource id
140
+ puts rsc.find('@string/app_name') # => 'application name'
123
141
 
124
- # you can set lang attribute.
125
- puts rsc.find('@0x7f040000', :lang => 'ja')
126
- ```
142
+ # assigns hex resource id
143
+ puts rsc.find('@0x7f040000') # => 'application name'
127
144
 
145
+ # you can set lang attribute.
146
+ puts rsc.find('@0x7f040000', :lang => 'ja')
147
+ ```
128
148
 
129
149
  ### Dex
150
+
130
151
  #### Extract dex information
152
+
131
153
  ```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
154
+ apk = Android::Apk.new('sample.apk')
155
+ dex = apk.dex
156
+ # listing string table in dex
157
+ dex.strings.each do |str|
158
+ puts str
159
+ end
138
160
 
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
161
+ # listing all class names
162
+ dex.classes.each do |cls| # cls is Android::Dex::ClassInfo
163
+ puts "class: #{cls.name}"
164
+ cls.virtual_methods.each do |m| # Android::Dex::MethodInfo
165
+ puts "\t#{m.definition}" # puts method definition
145
166
  end
167
+ end
146
168
  ```
147
169
 
148
170
  #### Parse dex file directly
171
+
149
172
  ```ruby
150
- dex_data = File.open('classes.dex','rb').read{|f| f.read }
151
- dex = Android::Dex.new(dex_data)
173
+ dex_data = File.open('classes.dex','rb').read{|f| f.read }
174
+ dex = Android::Dex.new(dex_data)
152
175
  ```
153
176
 
154
177
 
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,32 @@
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
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
10
5
 
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
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'android_parser'
8
+ spec.version = '2.5.1'
9
+ spec.authors = ['SecureBrain', 'icyleaf']
10
+ spec.email = ['info@securebrain.co.jp', 'icyleaf.cn@gmail.com']
11
+ spec.platform = Gem::Platform::RUBY
12
+ spec.summary = 'Static analysis tool for android apk since 2021'
13
+ spec.description = 'Static analysis tool for android apk since 2021'
14
+ spec.homepage = 'https://github.com/icyleaf/android_parser'
15
+ spec.license = 'MIT'
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.require_paths = ['lib']
18
+ spec.required_ruby_version = '>= 2.5'
27
19
 
28
- if s.respond_to? :specification_version then
29
- s.specification_version = 4
20
+ spec.add_dependency 'rubyzip', '>= 1.0', '< 3.0'
30
21
 
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"])
22
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') then
23
+ spec.add_dependency 'rexml', '> 3.0'
62
24
  end
63
- end
64
25
 
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ spec.add_development_dependency 'rspec-its', '>= 1.2.0'
28
+ spec.add_development_dependency 'rspec-collection_matchers', '>= 1.1.0'
29
+ spec.add_development_dependency 'rspec-mocks', '>= 3.6.0'
30
+ spec.add_development_dependency 'bundler', '>= 1.12'
31
+ spec.add_development_dependency 'rake', '>= 10.0'
32
+ 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 = [