https://github.com/radare/v-r2pipe
r2pipe for V
https://github.com/radare/v-r2pipe
Last synced: 2 months ago
JSON representation
r2pipe for V
- Host: GitHub
- URL: https://github.com/radare/v-r2pipe
- Owner: radare
- License: mit
- Created: 2020-01-08T01:17:57.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-28T19:26:32.000Z (over 1 year ago)
- Last Synced: 2025-09-07T14:44:10.678Z (7 months ago)
- Language: V
- Size: 56.6 KB
- Stars: 6
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-csirt - r2pipe for V
README
# r2pipe for V
This repository contains the r2pipe implementation in V
## Installation
```go
$ v install radare.r2pipe
```
## Usage
This module can be used to interact with an already existing session of r2:
```go
$ r2 /bin/ls
[0x8048000]> #!pipe v
>>> import radare.r2pipe
>>> r2 := r2pipe.new()
>>> print(r2.cmd('?E Hello World'))
>>> r2.free()
```
or
```sh
$ r2 -i test.v /bin/ls
> . test.v
```
But it can also be used to spawn new instances of r2:
```go
module main
import radare.r2pipe
fn main() {
c := r2pipe.spawn('/bin/ls', '')
print(c.cmd('?E Hello'))
c.free()
}
```
## Side Channel
r2pipe.v introduces a new api to capture the output of the stderr messages printed by r2
to the user. This channel is async, and can contain anything unstructured, so it's not
breaking backward compatibility and enables the users to also use this side pipe to
comunicate with the target process when running in debugger mode for example.
This is implemented by making r2pipe run a command in r2 that redirects the stderr to
a pipe, socket or file, which is then handled as an event captured in the r2 side.
```go
import r2pipe
import time
fn main() {
mut r := r2pipe.spawn('/bin/ls', '')
r.on('errmsg', works, fn (s r2pipe.R2PipeSide, msg string) bool {
eprintln('errmsg.received($msg)')
return true
})
r.cmd('Z')
r.free()
}
```
## Example
```go
module main
import radare.r2pipe
fn main() {
c := r2pipe.new()
print(c.cmd('?E Hello'))
c.free()
}
```