ruby-macho-utils 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +11 -0
  4. data/bin/macho-info +73 -0
  5. metadata +75 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 83c93a0c18a6247a4d84f41401fd62e90d5c9aec
4
+ data.tar.gz: 110dc3c83305853ed3c70dfafe8e4b9bbcd76bdd
5
+ SHA512:
6
+ metadata.gz: 9160f15cbc0f056dc664c98ce77e7649665ea347fd061f132ec31f70dcd437ed93e53ac5eada6a4dded577bf512287275366181eed5854cfa736261816565dca
7
+ data.tar.gz: 298ae7d20596a209bc447894c974ee631c65916f0d655eec4d65d189240c86af698cc7c7404cece063900048e7318e8266cdfa8a67da9229efb47d48ec4524ee
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 William Woodruff <william @ tuffbizz.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ ruby-macho-utils
2
+ ================
3
+
4
+ Command line utilities for use with
5
+ [ruby-macho](https://github.com/Homebrew/ruby-macho/).
6
+
7
+ ### Installation
8
+
9
+ ```bash
10
+ $ gem install ruby-macho-utils
11
+ ```
data/bin/macho-info ADDED
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "macho"
4
+ require "slop"
5
+
6
+ def macho_info(macho)
7
+ puts "FILE INFORMATION:"
8
+ puts "\tHeader type: #{macho.header.class}"
9
+ puts "\tMagic: #{macho.magic_string}"
10
+ puts "\tFiletype: #{macho.filetype}"
11
+ puts "\tCPU type: #{macho.cputype}"
12
+ puts "\tCPU subtype: #{macho.cpusubtype}"
13
+ puts "\tNo. load commands: #{macho.ncmds}"
14
+ puts "\tSize of load commands: #{macho.sizeofcmds}"
15
+ puts "\tFlags: #{macho.flags}"
16
+ puts "\tAlignment: #{macho.alignment}"
17
+
18
+ puts "\nLOAD COMMANDS:"
19
+ macho.load_commands.each do |lc|
20
+ puts "\t#{lc} (#{lc.class}) (offset: #{lc.offset}, size: #{lc.cmdsize})"
21
+ end
22
+
23
+ puts "\nDYLIB ID: #{macho.dylib_id}" if macho.dylib?
24
+
25
+ puts "\nDYNAMIC LIBRARIES:"
26
+ macho.dylib_load_commands.each do |lc|
27
+ puts "\t#{lc.name.to_s} (#{lc.type})"
28
+ end
29
+
30
+ puts "\nSEGMENTS AND SECTIONS:"
31
+
32
+ macho.segments.each do |seg|
33
+ puts "\tSegment: #{seg.segname} " \
34
+ "(offset: #{seg.fileoff}, size: #{seg.filesize})"
35
+
36
+ seg.sections.each do |sect|
37
+ puts "\t\tSection: #{sect.section_name} " \
38
+ "(offset: #{sect.offset}, size: #{sect.size})"
39
+ end
40
+ end
41
+ end
42
+
43
+ opts = Slop.parse do |o|
44
+ o.banner = <<~EOS
45
+ Dump metadata and information in the given Mach-O binary.
46
+
47
+ Usage:
48
+ macho-info [--first-only] <file>
49
+ EOS
50
+ o.bool "-f", "--first-only", "only dump the first slice in a fat binary"
51
+ o.on "-h", "--help", "print this help message" do
52
+ puts o
53
+ exit
54
+ end
55
+ end
56
+
57
+ filename = opts.args.shift || abort("I need a file to dump.")
58
+
59
+ macho_file = MachO.open(filename)
60
+
61
+ if macho_file.is_a?(MachO::FatFile)
62
+ macho_slices = macho_file.machos
63
+ else
64
+ macho_slices = [macho_file]
65
+ end
66
+
67
+ if opts.first_only?
68
+ macho_info(macho_slices.first)
69
+ else
70
+ macho_slices.each do |macho|
71
+ macho_info(macho)
72
+ end
73
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-macho-utils
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - William Woodruff
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-macho
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: slop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.4'
41
+ description: A collection of command line utilities for use with ruby-macho.
42
+ email: william@tuffbizz.com
43
+ executables:
44
+ - macho-info
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE
49
+ - README.md
50
+ - bin/macho-info
51
+ homepage: https://github.com/Homebrew/ruby-macho
52
+ licenses:
53
+ - MIT
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 2.3.0
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.6.8
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: ruby-macho-utils - Command line utils for ruby-macho.
75
+ test_files: []