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 +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/ci.yml +26 -0
- data/.gitignore +2 -1
- data/.rspec +3 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +9 -17
- data/README.md +98 -75
- data/Rakefile +5 -39
- data/android_parser.gemspec +26 -58
- data/lib/android/apk.rb +7 -3
- data/lib/android/axml_parser.rb +5 -2
- data/lib/android/axml_writer.rb +2 -0
- data/lib/android/dex/access_flag.rb +2 -1
- data/lib/android/dex/dex_object.rb +6 -5
- data/lib/android/dex/info.rb +3 -1
- data/lib/android/dex/utils.rb +5 -3
- data/lib/android/dex.rb +3 -1
- data/lib/android/layout.rb +5 -4
- data/lib/android/manifest.rb +213 -47
- data/lib/android/resource.rb +18 -6
- data/lib/android/utils.rb +1 -0
- data/lib/android_parser.rb +10 -0
- data/lib/ruby_apk.rb +4 -8
- metadata +49 -55
- data/.travis.yml +0 -5
- data/Gemfile.lock +0 -92
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8360af54a4093e8cc95844b8b7419e3190aed92f5aa6c832f0fd4f7e8ccd2f53
|
4
|
+
data.tar.gz: 1b8a9172fdf2b4f18c43cb0a342aa5244f7ad109cbfc8b8995d74d6de9fc34a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 393956811a1cfcb6bd043cdc8c6494a1760a0558d6d12ce157ee9e08b67035499f702e15cf8d6baa7971572eb616c0de28ebc92003a4e9a32c18541eb82b7f7b
|
7
|
+
data.tar.gz: a7998f5d5e71b889c083f6b1d73f4d277bd7aecd6c412a5d4b14dc10bccf1104472dffde03c2a2280071f88c846906f15c80991d73689f2dd957a46270ac3fbf
|
@@ -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
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
|
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
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
#
|
2
|
-
Android Apk static analysis library for Ruby.
|
1
|
+
# android_parser
|
3
2
|
|
4
|
-
[![
|
5
|
-
[![Build Status](https://
|
6
|
-
[![
|
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
|
-
|
11
|
+
|
12
|
+
- ruby (>= 2.5)
|
10
13
|
|
11
14
|
## Install
|
12
|
-
|
15
|
+
|
16
|
+
```bash
|
17
|
+
gem install android_parser
|
18
|
+
```
|
13
19
|
|
14
20
|
## Usage
|
21
|
+
|
15
22
|
### Initialize
|
23
|
+
|
16
24
|
```ruby
|
17
|
-
|
18
|
-
|
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
|
-
|
34
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
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
|
-
|
92
|
-
|
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
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
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
|
-
|
108
|
-
|
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
|
-
|
116
|
-
|
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
|
-
|
122
|
-
|
139
|
+
# assigns readable resource id
|
140
|
+
puts rsc.find('@string/app_name') # => 'application name'
|
123
141
|
|
124
|
-
|
125
|
-
|
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
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
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
|
-
|
151
|
-
|
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
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require '
|
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
|
-
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
37
9
|
|
38
|
-
|
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
|
data/android_parser.gemspec
CHANGED
@@ -1,64 +1,32 @@
|
|
1
|
-
#
|
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
|
-
|
8
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
29
|
-
s.specification_version = 4
|
20
|
+
spec.add_dependency 'rubyzip', '>= 1.0', '< 3.0'
|
30
21
|
|
31
|
-
|
32
|
-
|
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
|
-
|
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
|
58
|
+
$stderr.puts "failed to parse resource: #{e}"
|
55
59
|
#$stderr.puts e.backtrace
|
56
60
|
end
|
57
61
|
begin
|
data/lib/android/axml_parser.rb
CHANGED
@@ -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] ==
|
19
|
+
(data[0..3] == HEADER)
|
17
20
|
end
|
18
21
|
|
19
22
|
# axml parse error
|
data/lib/android/axml_writer.rb
CHANGED
@@ -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 = [
|