Skip to content

Commit

Permalink
Update gemspec (#54)
Browse files Browse the repository at this point in the history
* move crabstone and keystone from Gemfile to gemspec ( closed #53 )
* update readme
  • Loading branch information
david942j authored and hanhanW committed Oct 16, 2017
1 parent c8528f0 commit 144f69c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 44 deletions.
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
source 'https://www.rubygems.org'

gemspec

gem 'crabstone', git: 'https://github.com/bnagy/crabstone' # it doesn't push to RubyGems :(

gem 'keystone', git: 'https://github.com/sashs/ruby-keystone'
24 changes: 7 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
GIT
remote: https://github.com/bnagy/crabstone
revision: e3e0a552fcc8d45b7d2e5840456a0d6826271353
specs:
crabstone (3.0.3)
ffi

GIT
remote: https://github.com/sashs/ruby-keystone
revision: 2183b5a5d015789b36e51f102fc2d915722cad71
specs:
keystone (0.9.0)
ffi (~> 1.9)

PATH
remote: .
specs:
pwntools (0.1.0)
crabstone (~> 3)
dentaku (~> 2.0.11)
elftools (~> 1.0.1)
keystone-engine (~> 0.9)
rainbow (~> 2.2)

GEM
remote: https://www.rubygems.org/
specs:
ast (2.3.0)
bindata (2.4.0)
bindata (2.4.1)
codeclimate-test-reporter (0.6.0)
simplecov (>= 0.7.1, < 1.0.0)
coderay (1.1.1)
crabstone (3.0.3)
ffi
dentaku (2.0.11)
docile (1.1.5)
elftools (1.0.1)
bindata (~> 2)
ffi (1.9.18)
json (2.1.0)
keystone-engine (0.9.0)
ffi (~> 1.9)
method_source (0.8.2)
minitest (5.10.1)
parallel (1.11.2)
Expand Down Expand Up @@ -70,8 +62,6 @@ PLATFORMS

DEPENDENCIES
codeclimate-test-reporter (~> 0.6)
crabstone!
keystone!
minitest (= 5.10.1)
pry (~> 0.10)
pwntools!
Expand Down
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,20 @@ More features and details can be found in the

# Installation

Since there are two gems, which `pwntools-ruby` depends on, didn't be published to rubygems,
you should install them by self. :disappointed:

### Install the latest release:
```sh
gem install pwntools
```

git clone https://github.com/bnagy/crabstone.git /tmp/crabstone
cd /tmp/crabstone
gem build crabstone.gemspec
gem install crabstone

git clone https://github.com/sashs/ruby-keystone.git /tmp/ruby-keystone
cd /tmp/ruby-keystone/keystone_gem
gem build keystone.gemspec
gem install keystone
### Install from master branch:
```sh
git clone https://github.com/peter50216/pwntools-ruby
cd pwntools-ruby
gem build pwntools.gemspec && gem install pwntools-*.gem
```

### optional

Some of the features (assembling/disassembling) require non-Ruby dependencies. Checkout the
installation guide for
[keystone-engine](https://github.com/keystone-engine/keystone/tree/master/docs) and
Expand Down Expand Up @@ -115,9 +112,10 @@ sudo make install

# Development
```sh
git clone git@github.com:peter50216/pwntools-ruby.git
git clone https://github.com/peter50216/pwntools-ruby
cd pwntools-ruby
rake
bundle
bundle exec rake
```

# Note to irb users
Expand Down
14 changes: 7 additions & 7 deletions lib/pwnlib/asm.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: ASCII-8BIT

require 'keystone/keystone_const' # https://github.com/sashs/ruby-keystone/
require 'keystone_engine/keystone_const'

require 'pwnlib/context'
require 'pwnlib/util/ruby'
Expand Down Expand Up @@ -81,8 +81,8 @@ def disasm(data, vma: 0)
# @diff
# Not support +asm('mov eax, SYS_execve')+.
def asm(code)
require_message('keystone', install_keystone_guide)
Keystone::Ks.new(ks_arch, ks_mode).asm(code)[0]
require_message('keystone_engine', install_keystone_guide)
KeystoneEngine::Ks.new(ks_arch, ks_mode).asm(code)[0]
end

::Pwnlib::Util::Ruby.private_class_method_block do
Expand All @@ -102,15 +102,15 @@ def cap_mode

def ks_arch
{
'i386' => Keystone::KS_ARCH_X86,
'amd64' => Keystone::KS_ARCH_X86
'i386' => KeystoneEngine::KS_ARCH_X86,
'amd64' => KeystoneEngine::KS_ARCH_X86
}[context.arch]
end

def ks_mode
{
32 => Keystone::KS_MODE_32,
64 => Keystone::KS_MODE_64
32 => KeystoneEngine::KS_MODE_32,
64 => KeystoneEngine::KS_MODE_64
}[context.bits]
end

Expand Down
6 changes: 4 additions & 2 deletions pwntools.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ Gem::Specification.new do |s|

s.required_ruby_version = '>= 2.1.0'

s.add_runtime_dependency 'rainbow', '~> 2.2'
s.add_runtime_dependency 'elftools', '~> 1.0.1'
s.add_runtime_dependency 'crabstone', '~> 3'
s.add_runtime_dependency 'dentaku', '~> 2.0.11'
s.add_runtime_dependency 'elftools', '~> 1.0.1'
s.add_runtime_dependency 'keystone-engine', '~> 0.9'
s.add_runtime_dependency 'rainbow', '~> 2.2'

s.add_development_dependency 'codeclimate-test-reporter', '~> 0.6'
# TODO(david942j): check why ruby crash during testing if upgrade minitest to 5.10.2/3
Expand Down

0 comments on commit 144f69c

Please sign in to comment.