mootool 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +78 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/exe/mootool +8 -0
- data/lib/mootool/command.rb +26 -0
- data/lib/mootool/controller_base.rb +33 -0
- data/lib/mootool/controllers/dwarf.rb +0 -0
- data/lib/mootool/controllers/dyld_linker.rb +0 -0
- data/lib/mootool/controllers/dyld_shared_cache.rb +0 -0
- data/lib/mootool/controllers/fat_binary.rb +0 -0
- data/lib/mootool/controllers/kernel_collection.rb +24 -0
- data/lib/mootool/controllers/sections.rb +0 -0
- data/lib/mootool/version.rb +5 -0
- data/lib/mootool/views/sections.full.erb +5 -0
- data/lib/mootool.rb +14 -0
- data/mootool.gemspec +42 -0
- data/sorbet/config +3 -0
- data/sorbet/rbi/sorbet-typed/lib/rainbow/all/rainbow.rbi +276 -0
- data/sorbet/rbi/sorbet-typed/lib/rake/all/rake.rbi +645 -0
- data/sorbet/rbi/sorbet-typed/lib/rspec-core/all/rspec-core.rbi +24 -0
- data/sorbet/rbi/sorbet-typed/lib/rubocop/>=1.8/rubocop.rbi +12 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ef531c9ada953ff11d3a146970e1d92b685e499cd65d14c66af18ef3d65aed6c
|
4
|
+
data.tar.gz: 907b8dcadf9d5ed376f9850126f006d8cce27b11fcf4f543b7dbfbf853d4a38f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 186606d385d6a82c675cb31724c08695927dac94dc940570b244d2ede26e05bc87118607228e2366073dab94727c12847459658bccf1d108a073ee77cad96ac4
|
7
|
+
data.tar.gz: '03691c2682f2288907351217b7e7a7da58cee543f60cc174729a4d57d9c7c3c65ebfa4f3d3ae3fd9aa41c5daa63efcf094939c2e53a4f3ed7b592b32a20f5b30'
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.2
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at rickmark@outlook.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
# Specify your gem's dependencies in mootool.gemspec
|
8
|
+
gemspec
|
9
|
+
|
10
|
+
group :development, :test do
|
11
|
+
gem 'overcommit'
|
12
|
+
gem 'rake'
|
13
|
+
gem 'rspec'
|
14
|
+
gem 'rubocop'
|
15
|
+
gem 'rubocop-rake'
|
16
|
+
gem 'rubocop-rspec'
|
17
|
+
gem 'sorbet'
|
18
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mootool (0.1.0)
|
5
|
+
ruby-macho
|
6
|
+
sorbet-runtime
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.4.2)
|
12
|
+
childprocess (4.1.0)
|
13
|
+
diff-lcs (1.5.0)
|
14
|
+
iniparse (1.5.0)
|
15
|
+
overcommit (0.58.0)
|
16
|
+
childprocess (>= 0.6.3, < 5)
|
17
|
+
iniparse (~> 1.4)
|
18
|
+
rexml (~> 3.2)
|
19
|
+
parallel (1.21.0)
|
20
|
+
parser (3.1.0.0)
|
21
|
+
ast (~> 2.4.1)
|
22
|
+
rainbow (3.1.1)
|
23
|
+
rake (13.0.6)
|
24
|
+
regexp_parser (2.2.0)
|
25
|
+
rexml (3.2.5)
|
26
|
+
rspec (3.10.0)
|
27
|
+
rspec-core (~> 3.10.0)
|
28
|
+
rspec-expectations (~> 3.10.0)
|
29
|
+
rspec-mocks (~> 3.10.0)
|
30
|
+
rspec-core (3.10.1)
|
31
|
+
rspec-support (~> 3.10.0)
|
32
|
+
rspec-expectations (3.10.2)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-mocks (3.10.2)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.10.0)
|
38
|
+
rspec-support (3.10.3)
|
39
|
+
rubocop (1.25.0)
|
40
|
+
parallel (~> 1.10)
|
41
|
+
parser (>= 3.1.0.0)
|
42
|
+
rainbow (>= 2.2.2, < 4.0)
|
43
|
+
regexp_parser (>= 1.8, < 3.0)
|
44
|
+
rexml
|
45
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
46
|
+
ruby-progressbar (~> 1.7)
|
47
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
48
|
+
rubocop-ast (1.15.1)
|
49
|
+
parser (>= 3.0.1.1)
|
50
|
+
rubocop-rake (0.6.0)
|
51
|
+
rubocop (~> 1.0)
|
52
|
+
rubocop-rspec (2.8.0)
|
53
|
+
rubocop (~> 1.19)
|
54
|
+
ruby-macho (3.0.0)
|
55
|
+
ruby-progressbar (1.11.0)
|
56
|
+
sorbet (0.5.9553)
|
57
|
+
sorbet-static (= 0.5.9553)
|
58
|
+
sorbet-runtime (0.5.9553)
|
59
|
+
sorbet-static (0.5.9553-universal-darwin-21)
|
60
|
+
unicode-display_width (2.1.0)
|
61
|
+
|
62
|
+
PLATFORMS
|
63
|
+
x86_64-darwin-21
|
64
|
+
|
65
|
+
DEPENDENCIES
|
66
|
+
bundler (> 2)
|
67
|
+
mootool!
|
68
|
+
overcommit
|
69
|
+
rake
|
70
|
+
rspec
|
71
|
+
rubocop
|
72
|
+
rubocop-rake
|
73
|
+
rubocop-rspec
|
74
|
+
ruby-macho
|
75
|
+
sorbet
|
76
|
+
|
77
|
+
BUNDLED WITH
|
78
|
+
2.3.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Rick Mark
|
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,37 @@
|
|
1
|
+
# MachO's Other Tool
|
2
|
+
|
3
|
+
`mootool` is an attempt at an open source replacement to the legandary `jtool2` allowing it to continue to progress
|
4
|
+
with the Apple research community. Ruby was selected as [Homebrew](https://brew.sh) maintains a good Mach-O parser
|
5
|
+
that is pure (meaning it needs no dependencies other then a Ruby runtime).
|
6
|
+
|
7
|
+
As a secondary goal every command should provide output both in human readable as well as machien readable (YAML)
|
8
|
+
format making it suitable for use in scripting.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Install this utility by running `gem install mootool`
|
13
|
+
|
14
|
+
The code can also be used as a library with `gem 'mootool'`
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
* `kc`
|
19
|
+
* `list`
|
20
|
+
|
21
|
+
## Development
|
22
|
+
|
23
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
24
|
+
|
25
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mootool. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
30
|
+
|
31
|
+
## License
|
32
|
+
|
33
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
34
|
+
|
35
|
+
## Code of Conduct
|
36
|
+
|
37
|
+
Everyone interacting in the Mootool project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mootool/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'mootool'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/mootool
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MooTool
|
4
|
+
class Command
|
5
|
+
attr_reader :file, :controller, :action, :output_format, :remain
|
6
|
+
|
7
|
+
def self.parse(args)
|
8
|
+
Command.new args[2], :human, args[0], args[1], args[3..]
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(file, _output_format, controller, action, remain)
|
12
|
+
@file = file
|
13
|
+
@controller = controller
|
14
|
+
@output_format = :human
|
15
|
+
@remain = remain
|
16
|
+
@action = action
|
17
|
+
end
|
18
|
+
|
19
|
+
def run!
|
20
|
+
MooTool::ControllerBase.load_all
|
21
|
+
|
22
|
+
controller = MooTool::ControllerBase.for_controller @controller
|
23
|
+
controller.new.send @action, self, @remain
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
CONTROLLERS_PATH = File.join(File.dirname(__FILE__), 'controllers')
|
4
|
+
|
5
|
+
module MooTool
|
6
|
+
class ControllerBase
|
7
|
+
def self.load_all
|
8
|
+
Dir.glob(File.join(CONTROLLERS_PATH, '*')).each do |file|
|
9
|
+
require file
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.for_controller(name)
|
14
|
+
@@controllers.find { |c| c.command == name }
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.inherited(child)
|
18
|
+
@@controllers ||= []
|
19
|
+
@@controllers << child
|
20
|
+
end
|
21
|
+
|
22
|
+
class << self
|
23
|
+
def command(command = nil)
|
24
|
+
@command = command if command
|
25
|
+
@command
|
26
|
+
end
|
27
|
+
|
28
|
+
def description(description)
|
29
|
+
@description = description
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MooTool
|
4
|
+
class KernelCollection < ControllerBase
|
5
|
+
command 'kc'
|
6
|
+
description 'Kernel Collections'
|
7
|
+
|
8
|
+
def extract(command, output_folder)
|
9
|
+
file = MachO.open command.file
|
10
|
+
input = File.open(command.file, 'rb')
|
11
|
+
|
12
|
+
file.command(:LC_FILESET_ENTRY).each do |entry|
|
13
|
+
output_path = File.join(output_folder, entry.entry_id.to_s)
|
14
|
+
puts "Writing to #{output_path}"
|
15
|
+
output_file = File.open(output_path, 'wb')
|
16
|
+
matching = file.command(:LC_SEGMENT_64).find { |command| command.fileoff == entry.fileoff }
|
17
|
+
|
18
|
+
input.seek(matching.fileoff)
|
19
|
+
output_file.write input.read(matching.filesize)
|
20
|
+
output_file.close
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
File without changes
|
data/lib/mootool.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mootool/version'
|
4
|
+
|
5
|
+
require 'bundler/setup'
|
6
|
+
|
7
|
+
require 'macho'
|
8
|
+
|
9
|
+
module MooTool
|
10
|
+
class Error < StandardError; end
|
11
|
+
# Your code goes here...
|
12
|
+
autoload :Command, 'mootool/command'
|
13
|
+
autoload :ControllerBase, 'mootool/controller_base'
|
14
|
+
end
|
data/mootool.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'mootool/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'mootool'
|
9
|
+
spec.version = MooTool::VERSION
|
10
|
+
spec.authors = ['Rick Mark']
|
11
|
+
spec.email = ['rickmark@outlook.com']
|
12
|
+
|
13
|
+
spec.summary = "Mach-O's Other Tool"
|
14
|
+
spec.description = 'mootool is a swiss army knife for dealing wiith Apple Mach-O files'
|
15
|
+
spec.homepage = 'https://github.com/hack-different/mootool'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
|
+
if spec.respond_to?(:metadata)
|
21
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
22
|
+
|
23
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
24
|
+
spec.metadata['source_code_uri'] = 'https://github.com/hack-different/mootool'
|
25
|
+
spec.metadata['changelog_uri'] = 'https://github.com/hack-different/mootool'
|
26
|
+
else
|
27
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
28
|
+
'public gem pushes.'
|
29
|
+
end
|
30
|
+
|
31
|
+
# Specify which files should be added to the gem when it is released.
|
32
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
33
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
34
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
35
|
+
end
|
36
|
+
spec.bindir = 'exe'
|
37
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
38
|
+
spec.require_paths = ['lib']
|
39
|
+
|
40
|
+
spec.add_runtime_dependency 'sorbet-runtime'
|
41
|
+
spec.add_runtime_dependency 'ruby-macho', '~> 3'
|
42
|
+
end
|
data/sorbet/config
ADDED