r2pipe 0.1.2 → 0.1.3
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 +4 -4
- data/lib/r2pipe.rb +31 -12
- data/lib/r2pipe/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e704f13a7167821d211d8719a13a7ea52f3dfacc
|
4
|
+
data.tar.gz: fe52e28dc67357ae80cfef586efa9519fbe70f0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1042254c44fc987d15f3caf9da81652d123c75c1ad34d4cd7f69e4c5f0789c6a966518fac82aa432087e706441041b929d1124b5f5bd9c6293ba40fa673aacad
|
7
|
+
data.tar.gz: 2095d822db51d872a512ad84cbcaa214de99d10914648157d652dab4c9b8ad9e251ad9cc43ef7604306f2f2210c4567438574aebda52ffedffb4871762630ee3
|
data/lib/r2pipe.rb
CHANGED
@@ -5,31 +5,50 @@ require 'shellwords'
|
|
5
5
|
|
6
6
|
# R2Pipe is an easy way to communicate with an r2 core through ruby
|
7
7
|
class R2Pipe
|
8
|
-
def initialize(file)
|
8
|
+
def initialize(file = nil)
|
9
9
|
@file = file
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
if file == nil
|
11
|
+
fdIn = ENV['R2PIPE_IN'].to_i
|
12
|
+
fdOut = ENV['R2PIPE_OUT'].to_i
|
13
|
+
if fdIn < 1 or fdOut < 1
|
14
|
+
raise 'Cannot find R2PIPE_IN and R2PIPE_OUT environment variables'
|
15
|
+
end
|
16
|
+
@read = IO.new(fdIn, 'r')
|
17
|
+
@write = IO.new(fdOut, 'w')
|
18
|
+
@pid = -1
|
19
|
+
else
|
20
|
+
exec = "r2 -q0 #{Shellwords.shellescape file} 2>/dev/null"
|
21
|
+
PTY.spawn(exec) do |read, write, pid|
|
22
|
+
@read = read
|
23
|
+
@write = write
|
24
|
+
@pid = pid
|
25
|
+
@read.gets("\0")
|
26
|
+
end
|
16
27
|
end
|
17
28
|
end
|
18
29
|
|
19
|
-
# runs a command on the radare2 core
|
20
30
|
def cmd(str)
|
21
31
|
@write.print "#{str}\n"
|
32
|
+
@write.flush
|
22
33
|
@read.gets("\0")[0..-2]
|
23
34
|
end
|
24
35
|
|
25
|
-
|
36
|
+
def cmdj(str)
|
37
|
+
json(cmd(str))
|
38
|
+
end
|
39
|
+
|
26
40
|
def quit
|
27
41
|
cmd('q!')
|
28
|
-
|
42
|
+
@read.close
|
43
|
+
@write.close
|
44
|
+
if @pid != -1
|
45
|
+
::Process.wait @pid
|
46
|
+
end
|
29
47
|
end
|
30
48
|
|
31
|
-
# returns a parsed json string
|
32
49
|
def json(str)
|
33
|
-
|
50
|
+
if !str.nil?
|
51
|
+
JSON.parse str.sub("\n", '').sub("\r", '')
|
52
|
+
end
|
34
53
|
end
|
35
54
|
end
|
data/lib/r2pipe/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r2pipe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeffrey Crowell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -82,9 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
84
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
85
|
+
rubygems_version: 2.6.12
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Communicate with Radare2 via pipes.
|
89
89
|
test_files: []
|
90
|
-
has_rdoc:
|