ruby_android 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fe73a8f68f7248be41068390eeccec9585be30a3
4
+ data.tar.gz: 64a58cd7d87045f196edf7b7076b1421dbed4c60
5
+ SHA512:
6
+ metadata.gz: 47098964ac436834ef6397b784b5d55f6fe7251b617dc5a0cc5d6759ea386601e2e11f99eb040629bc5f9a457527af314b59f1ec2ac277e08995485ff2ee7fbf
7
+ data.tar.gz: 33d604fa41a935d67019a47559082fd3d74b275bfb06975e1f6af96368bfce15cbe4af5571fbc7849a1777aba4c2c9c8f09568638bb2cf73c867967817227c6f
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,16 @@
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.1.6"
6
+
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", ">= 2.11.0"
11
+ gem "bundler", ">= 1.5.2"
12
+ gem "jeweler", ">= 2.0.0"
13
+ gem "yard", require: false
14
+ gem "redcarpet"
15
+ gem "simplecov", require: false
16
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Michal Tajchert
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # ruby_apk
2
+ Android Apk static analysis library for Ruby.
3
+
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/SecureBrain/ruby_apk.png)](https://travis-ci.org/SecureBrain/ruby_apk)
6
+
7
+ ## Requirements
8
+ - ruby(>=1.9.x)
9
+
10
+ ## Install
11
+ $ gem install ruby_apk
12
+
13
+ ## Usage
14
+ ### Initialize
15
+ ```ruby
16
+ require 'ruby_apk'
17
+ apk = Android::Apk.new('sample.apk') # set apk file path
18
+ ```
19
+
20
+ ### Apk
21
+ #### Listing files in Apk
22
+ ```ruby
23
+ # listing files in apk
24
+ apk = Android::Apk.new('sample.apk')
25
+ apk.each_file do |name, data|
26
+ puts "#{name}: #{data.size}bytes" # puts file name and data size
27
+ end
28
+ ```
29
+
30
+ #### Find files in Apk
31
+ ```ruby
32
+ apk = Android::Apk.new('sample.apk')
33
+ elf_files = apk.find{|name, data| data[0..3] == [0x7f, 0x45, 0x4c, 0x46] } # ELF magic number
34
+ ```
35
+
36
+ #### Extract icon data in Apk (since 0.6.0)
37
+ ```ruby
38
+ apk = Android::Apk.new('sample.apk')
39
+ icons = apk.icon # { "res/drawable-hdpi/ic_launcher.png" => "\x89PNG\x0D\x0A...", ... }
40
+ icons.each do |name, data|
41
+ File.open(File.basename(name), 'wb') {|f| f.write data } # save to file.
42
+ end
43
+ ```
44
+
45
+ #### Extract signature and certificate information from Apk (since v0.7.0)
46
+ ```ruby
47
+ apk = Android::Apk.new('sample.apk')
48
+ signs = apk.signs # retrun Hash(key: signature file path, value: OpenSSL::PKCS7)
49
+ signs.each do |path, sign|
50
+ puts path # => "MATA-INF/CERT.RSA" or ...
51
+ puts sign # => "-----BEGIN PKCS7-----\n..." PKCS7 object
52
+ end
53
+
54
+ certs = apk.certificates # retrun Hash(key: signature file path, value: OpenSSL::X509::Certificate)
55
+ certs.each do |path, cert|
56
+ puts path # => "MATA-INF/CERT.RSA" or ...
57
+ puts cert # => "-----BEGIN CERTIFICATE-----\n..." # X509::Certificate object
58
+ end
59
+ ```
60
+ Note: Most apks have only one signature and cerficate.
61
+
62
+ ### Manifest
63
+ #### Get readable xml
64
+ ```ruby
65
+ apk = Android::Apk.new('sample.apk')
66
+ manifest = apk.manifest
67
+ puts manifest.to_xml
68
+ ```
69
+
70
+ #### Listing components and permissions
71
+ ```ruby
72
+ apk = Android::Apk.new('sample.apk')
73
+ manifest = apk.manifest
74
+ # listing components
75
+ manifest.components.each do |c| # 'c' is Android::Manifest::Component object
76
+ puts "#{c.type}: #{c.name}"
77
+ c.intent_filters.each do |filter|
78
+ puts "\t#{filter.type}"
79
+ end
80
+ end
81
+
82
+ # listing use-permission tag
83
+ manifest.use_permissions.each do |permission|
84
+ puts permission
85
+ end
86
+ ```
87
+
88
+ #### Extract application label string
89
+ ```ruby
90
+ apk = Android::Apk.new('sample.apk')
91
+ puts apk.manifest.label
92
+ ```
93
+
94
+ ### Resource
95
+ #### Extract resource strings from apk
96
+ ```ruby
97
+ apk = Android::Apk.new('sample.apk')
98
+ rsc = apk.resource
99
+ rsc.strings.each do |str|
100
+ puts str
101
+ end
102
+ ```
103
+
104
+ #### Parse resource file directly
105
+ ```ruby
106
+ rsc_data = File.open('resources.arsc', 'rb').read{|f| f.read }
107
+ rsc = Android::Resource.new(rsc_data)
108
+ ```
109
+
110
+ ### Resolve resource id
111
+ This feature supports only srting resources for now.
112
+
113
+ ```ruby
114
+ apk = Android::Apk.new('sample.apk')
115
+ rsc = apk.resource
116
+
117
+ # assigns readable resource id
118
+ puts rsc.find('@string/app_name') # => 'application name'
119
+
120
+ # assigns hex resource id
121
+ puts rsc.find('@0x7f040000') # => 'application name'
122
+
123
+ # you can set lang attribute.
124
+ puts rsc.find('@0x7f040000', :lang => 'ja')
125
+ ```
126
+
127
+
128
+ ### Dex
129
+ #### Extract dex information
130
+ ```ruby
131
+ apk = Android::Apk.new('sample.apk')
132
+ dex = apk.dex
133
+ # listing string table in dex
134
+ dex.strings.each do |str|
135
+ puts str
136
+ end
137
+
138
+ # listing all class names
139
+ dex.classes.each do |cls| # cls is Android::Dex::ClassInfo
140
+ puts "class: #{cls.name}"
141
+ cls.virtual_methods.each do |m| # Android::Dex::MethodInfo
142
+ puts "\t#{m.definition}" # puts method definition
143
+ end
144
+ end
145
+ ```
146
+
147
+ #### Parse dex file directly
148
+ ```ruby
149
+ dex_data = File.open('classes.dex','rb').read{|f| f.read }
150
+ dex = Android::Dex.new(dex_data)
151
+ ```
152
+
153
+
154
+ ## Copyright
155
+
156
+ Copyright (c) 2012 SecureBrain. See LICENSE.txt for further details.
157
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,3 @@
1
+ module RubyAndroid
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ require_relative 'ruby_android/apk'
2
+ require_relative 'ruby_android/manifest'
3
+ require_relative 'ruby_android/axml_parser'
4
+ require_relative 'ruby_android/dex'
5
+ require_relative 'ruby_android/resource'
6
+ require_relative 'ruby_android/utils'
7
+ require_relative 'ruby_android/layout'
@@ -0,0 +1,21 @@
1
+
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "ruby_android"
4
+ spec.version = '0.0.2'
5
+ spec.authors = ["Michal Tajchert"]
6
+ spec.email = ["thetajchert@gmail.com"]
7
+ spec.homepage = 'https://github.com/tajchert/ruby_android'
8
+ spec.summary = 'static analysis tool for android apk'
9
+ spec.description = 'copy of update ruby_apk'
10
+ spec.license = "MIT"
11
+
12
+ spec.files = `git ls-files -z`.split("\x0")
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_development_dependency "bundler", '~> 1.7'
18
+ spec.add_development_dependency "rake", '~> 10.0'
19
+ spec.add_runtime_dependency "rubyzip", '~> 1.1'
20
+ spec.add_development_dependency "rspec", '~> 2.11'
21
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_android
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Michal Tajchert
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubyzip
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.11'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.11'
69
+ description: copy of update ruby_apk
70
+ email:
71
+ - thetajchert@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/ruby_android.rb
82
+ - lib/ruby_android/version.rb
83
+ - ruby_android.gemspec
84
+ homepage: https://github.com/tajchert/ruby_android
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.4.1
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: static analysis tool for android apk
108
+ test_files: []
109
+ has_rdoc: