ruby_apk 0.4.1 → 0.4.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.
data/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # ChangeLog
2
+ ## 0.4.2
3
+ * fix bugs(#2, #3)
4
+ * divide change log from readme
5
+
6
+ ## 0.4.1
7
+ * fix typo
8
+ * add document
9
+
10
+ ## 0.4.0
11
+ * add resource parser
12
+ * enhance dex parser
13
+
14
+ ## 0.3.0
15
+ * add and change name space
16
+ * add Android::Utils module and some util methods
17
+ * add Apk#entry, Apk#each_entry, and Apk#time methods,
18
+
19
+ ## 0.2.0
20
+ * update documents
21
+ * add Apk::Dex#each_strings, Apk::Dex#each_class_names
22
+
23
+ ## 0.1.2
24
+ * fix bug(improve android binary xml parser)
25
+
26
+ ## 0.1.1
27
+ * fix bug(failed to initialize Apk::Manifest::Meta class)
28
+ * replace iconv to String#encode(for ruby1.9)
29
+
data/README.md CHANGED
@@ -3,108 +3,99 @@ Android Apk static analysis library for Ruby.
3
3
 
4
4
  ## Requirements
5
5
  - ruby(>=1.9.x)
6
- - rubyzip gem(>=0.9.9)
7
6
 
8
7
  ## Install
9
- $ gem install ruby_apk
8
+ $ gem install ruby_apk
10
9
 
11
10
  ## Usage
12
11
  ### Initialize
13
- require 'ruby_apk'
14
- apk = Android::Apk.new('sample.apk') # set apk file path
12
+ ```ruby
13
+ require 'ruby_apk'
14
+ apk = Android::Apk.new('sample.apk') # set apk file path
15
+ ```
15
16
 
16
17
  ### Apk
17
18
  #### Listing files in Apk
18
- # listing files in apk
19
- apk = Android::Apk.new('sample.apk')
20
- apk.each_file do |name, data|
21
- puts "#{name}: #{data.size}bytes" # puts file name and data size
22
- end
19
+ ```ruby
20
+ # listing files in apk
21
+ apk = Android::Apk.new('sample.apk')
22
+ apk.each_file do |name, data|
23
+ puts "#{name}: #{data.size}bytes" # puts file name and data size
24
+ end
25
+ ```
23
26
 
24
27
  #### Find files in Apk
25
- apk = Android::Apk.new('sample.apk')
26
- elf_files = apk.find{|name, data| data[0..3] == [0x7f, 0x45, 0x4c, 0x46] } # ELF magic number
28
+ ```ruby
29
+ apk = Android::Apk.new('sample.apk')
30
+ elf_files = apk.find{|name, data| data[0..3] == [0x7f, 0x45, 0x4c, 0x46] } # ELF magic number
31
+ ```
27
32
 
28
33
  ### Manifest
29
34
  #### Get readable xml
30
- apk = Android::Apk.new('sample.apk')
31
- manifest = apk.manifest
32
- puts manifest.to_xml
35
+ ```ruby
36
+ apk = Android::Apk.new('sample.apk')
37
+ manifest = apk.manifest
38
+ puts manifest.to_xml
39
+ ```
33
40
 
34
41
  #### Listing components and permissions
35
- apk = Android::Apk.new('sample.apk')
36
- manifest = apk.manifest
37
- # listing components
38
- manifest.components.each do |c| # 'c' is Android::Manifest::Component object
39
- puts "#{c.type}: #{c.name}"
40
- c.intent_filters.each do |filter|
41
- puts "\t#{filter.type}"
42
- end
43
- end
44
-
45
- # listing use-permission tag
46
- manifest.use_permissions.each do |permission|
47
- puts permission
48
- end
42
+ ```ruby
43
+ apk = Android::Apk.new('sample.apk')
44
+ manifest = apk.manifest
45
+ # listing components
46
+ manifest.components.each do |c| # 'c' is Android::Manifest::Component object
47
+ puts "#{c.type}: #{c.name}"
48
+ c.intent_filters.each do |filter|
49
+ puts "\t#{filter.type}"
50
+ end
51
+ end
52
+
53
+ # listing use-permission tag
54
+ manifest.use_permissions.each do |permission|
55
+ puts permission
56
+ end
57
+ ```
49
58
 
50
59
  ### Resource
51
60
  #### Extract resource strings from apk
52
- apk = Android::Apk.new('sample.apk')
53
- rsc = apk.resource
54
- rsc.strings.each do |str|
55
- puts str
56
- end
61
+ ```ruby
62
+ apk = Android::Apk.new('sample.apk')
63
+ rsc = apk.resource
64
+ rsc.strings.each do |str|
65
+ puts str
66
+ end
67
+ ```
57
68
 
58
69
  #### Parse resource file directly
59
- rsc_data = File.open('resources.arsc', 'rb').read{|f| f.read }
60
- rsc = Android::Resource.new(rsc_data)
70
+ ```ruby
71
+ rsc_data = File.open('resources.arsc', 'rb').read{|f| f.read }
72
+ rsc = Android::Resource.new(rsc_data)
73
+ ```
61
74
 
62
75
  ### Dex
63
76
  #### Extract dex information
64
- apk = Android::Apk.new('sample.apk')
65
- dex = apk.dex
66
- # listing string table in dex
67
- dex.strings do |str|
68
- puts str
69
- end
70
-
71
- # listing all class names
72
- dex.classes do |cls| # cls is Android::Dex::ClassInfo
73
- puts "class: #{cls.name}"
74
- cls.virtual_methods.each do |m| # Android::Dex::MethodInfo
75
- puts "\t#{m.definition}" # puts method definition
76
- end
77
- end
77
+ ```ruby
78
+ apk = Android::Apk.new('sample.apk')
79
+ dex = apk.dex
80
+ # listing string table in dex
81
+ dex.strings do |str|
82
+ puts str
83
+ end
84
+
85
+ # listing all class names
86
+ dex.classes do |cls| # cls is Android::Dex::ClassInfo
87
+ puts "class: #{cls.name}"
88
+ cls.virtual_methods.each do |m| # Android::Dex::MethodInfo
89
+ puts "\t#{m.definition}" # puts method definition
90
+ end
91
+ end
92
+ ```
78
93
 
79
94
  #### Parse dex file directly
80
- dex_data = File.open('classes.dex','rb').read{|f| f.read }
81
- dex = Android::Dex.new(dex_data)
82
-
83
-
84
- ## ChangeLog
85
- ### 0.4.1
86
- * fix typo
87
- * add document
88
-
89
- ### 0.4.0
90
- * add resource parser
91
- * enhance dex parser
92
-
93
- ### 0.3.0
94
- * add and change name space
95
- * add Android::Utils module and some util methods
96
- * add Apk#entry, Apk#each_entry, and Apk#time methods,
97
-
98
- ### 0.2.0
99
- * update documents
100
- * add Apk::Dex#each_strings, Apk::Dex#each_class_names
101
-
102
- ### 0.1.2
103
- * fix bug(improve android binary xml parser)
104
-
105
- ### 0.1.1
106
- * fix bug(failed to initialize Apk::Manifest::Meta class)
107
- * replace iconv to String#encode(for ruby1.9)
95
+ ```ruby
96
+ dex_data = File.open('classes.dex','rb').read{|f| f.read }
97
+ dex = Android::Dex.new(dex_data)
98
+ ```
108
99
 
109
100
 
110
101
  ## Copyright
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -405,7 +405,7 @@ module Android
405
405
  def parse
406
406
  @params[:size] = read_sleb
407
407
  @params[:list] = read_class_array(EncodedTypeAddrPair, @params[:size].abs)
408
- @params[:catch_all_addr] = read_uleb if @params[:size] < 0
408
+ @params[:catch_all_addr] = read_uleb if @params[:size] <= 0
409
409
  end
410
410
  end
411
411
 
@@ -38,6 +38,7 @@ module Android
38
38
  @intent_filters = []
39
39
  unless elem.elements['intent-filter'].nil?
40
40
  elem.elements['intent-filter'].each do |e|
41
+ next unless e.instance_of? REXML::Element
41
42
  @intent_filters << IntentFilter.parse(e)
42
43
  end
43
44
  end
data/ruby_apk.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ruby_apk"
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["SecureBrain"]
12
- s.date = "2012-10-28"
12
+ s.date = "2012-12-19"
13
13
  s.description = "static analysis tool for android apk"
14
14
  s.email = "info@securebrain.co.jp"
15
15
  s.extra_rdoc_files = [
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.files = [
20
20
  ".rspec",
21
+ "CHANGELOG.md",
21
22
  "Gemfile",
22
23
  "Gemfile.lock",
23
24
  "LICENSE.txt",
@@ -122,6 +122,23 @@ describe Android::Manifest do
122
122
  context "with no components" do
123
123
  it { should be_empty }
124
124
  end
125
+ context 'with text element in intent-filter element. (issue #3)' do
126
+ before do
127
+ app = REXML::Element.new('application')
128
+ activity = REXML::Element.new('activity')
129
+ intent_filter = REXML::Element.new('intent-filter')
130
+ text = REXML::Text.new('sample')
131
+
132
+ intent_filter << text
133
+ activity << intent_filter
134
+ app << activity
135
+ dummy_xml.root << app
136
+ end
137
+ it "should have components" do
138
+ subject.should have(1).items
139
+ end
140
+ it { expect { subject }.to_not raise_error }
141
+ end
125
142
  end
126
143
  end
127
144
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_apk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-28 00:00:00.000000000 Z
12
+ date: 2012-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubyzip
@@ -132,6 +132,7 @@ extra_rdoc_files:
132
132
  - README.md
133
133
  files:
134
134
  - .rspec
135
+ - CHANGELOG.md
135
136
  - Gemfile
136
137
  - Gemfile.lock
137
138
  - LICENSE.txt
@@ -182,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
183
  version: '0'
183
184
  segments:
184
185
  - 0
185
- hash: 3605376742814916476
186
+ hash: -1781742787123284542
186
187
  required_rubygems_version: !ruby/object:Gem::Requirement
187
188
  none: false
188
189
  requirements: