mirror of
https://github.com/radareorg/radare2-r2pipe.git
synced 2026-11-07 06:35:58 -10:00
add r2pipe lisp bindings for radare2.
This commit is contained in:
1 parent
8b6832b001
commit
08f44fa326
2 files changed
+64
No files matched your search
@@ -0,0 +1,19 @@
|
||||
;;; -*- encoding:utf-8 Mode: LISP; Syntax: COMMON-LISP; Base: 10 -*- ---
|
||||
;;
|
||||
;; Filename: main.lisp
|
||||
;; Description:
|
||||
;; Author: Jingtao Xu <[email protected]>
|
||||
;; Created: 2015.09.29 17:43:05(+0800)
|
||||
;; Last-Updated: 2015.09.30 16:33:26(+0800)
|
||||
;; Update #: 6
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
;;
|
||||
;;
|
||||
;;(load "r2pipe.lisp")
|
||||
(setf pipe (r2pipe "/bin/bash"))
|
||||
(format t "~s~%" (r2-cmd pipe "pi 5"))
|
||||
(format t "~s~%" (r2-json (r2-cmd pipe "pij 1")))
|
||||
(format t "~s~%" (r2-cmd pipe "px 64"))
|
||||
(r2-quit pipe)
|
||||
@@ -0,0 +1,45 @@
|
||||
;;; -*- encoding:utf-8 Mode: LISP; Syntax: COMMON-LISP; Base: 10 -*- ---
|
||||
;;
|
||||
;; Filename: r2pipe.lisp
|
||||
;; Description:
|
||||
;; Author: Jingtao Xu <[email protected]>
|
||||
;; Created: 2015.09.29 17:42:43(+0800)
|
||||
;; Last-Updated: 2015.09.30 16:30:25(+0800)
|
||||
;; Update #: 38
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;;; Commentary:
|
||||
;;
|
||||
;;
|
||||
(in-package :cl-user)
|
||||
|
||||
(asdf:oos 'asdf:load-op :cl-json)
|
||||
|
||||
(defvar *r2-bin-path* "/usr/bin/r2")
|
||||
(defun r2-read-pipe (pipe)
|
||||
(with-output-to-string (stream)
|
||||
(loop for c = (read-char pipe)
|
||||
until (= 0 (char-code c))
|
||||
do (write-char c stream))))
|
||||
|
||||
(defun r2pipe (file)
|
||||
(let ((pipe #-lispworks(error "r2pipe is not implemented for current lisp platform.")
|
||||
#+lispworks(sys:open-pipe `(,*r2-bin-path* "-q" "-0" ,file) :direction :io)))
|
||||
(values pipe (r2-read-pipe pipe))))
|
||||
|
||||
(defun r2-cmd (pipe cmd)
|
||||
(write-line (format nil "~a" cmd) pipe)
|
||||
(finish-output pipe)
|
||||
(r2-read-pipe pipe))
|
||||
|
||||
(defun r2-quit (pipe)
|
||||
(r2-cmd pipe "q!"))
|
||||
|
||||
(defun r2-json (str)
|
||||
(json:decode-json-from-string
|
||||
(with-output-to-string (*standard-output*)
|
||||
(with-input-from-string (*standard-input* str)
|
||||
(loop for c = (read-char *standard-input* nil nil) then (read-char *standard-input* nil nil)
|
||||
until (null c)
|
||||
unless (find c '(#\Newline #\Return))
|
||||
do (write-char c))))))
|
||||
Reference in new issue
Block a user