-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b8df796
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{"argv":["python","-m","radare2", "-f", "{connection_file}"], | ||
"display_name":"radare2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright (C) 2017 Guillaume Valadon <[email protected]> | ||
|
||
""" | ||
A Jupyter kernel for radare2 | ||
""" | ||
|
||
|
||
import r2pipe | ||
|
||
from ipykernel.kernelbase import Kernel | ||
from ipykernel.kernelapp import IPKernelApp | ||
|
||
|
||
class Radare2Kernel(Kernel): | ||
"""radare2 Jupyter kernel""" | ||
|
||
# Kernel information | ||
implementation = "radare2" | ||
implementation_version = "0.1" | ||
banner = "radare2 Jupyter kernel" | ||
|
||
# Language information | ||
language_info = { | ||
"name": "radare2", | ||
"mimetype": "text/plain", | ||
"file_extension": ".r2", | ||
} | ||
|
||
|
||
|
||
def _get_r2pipe(self): | ||
"""Get the r2pipe handle""" | ||
|
||
if not hasattr(self, "r2"): | ||
self.r2 = r2pipe.open("-") | ||
|
||
def do_execute(self, code, silent, store_history=True, user_expressions=None, | ||
allow_stdin=False): | ||
"""Execute a radare2 commmand using r2pipe""" | ||
|
||
self._get_r2pipe() | ||
|
||
if not silent: | ||
result = self.r2.cmd(code) | ||
print result | ||
stream = {"name": "stdout", "text": result} | ||
self.send_response(self.iopub_socket, "stream", stream) | ||
|
||
return {"status": "ok", | ||
"execution_count": self.execution_count, | ||
"payload": [], | ||
"user_expressions": {}, | ||
} | ||
|
||
|
||
if __name__ == "__main__": | ||
IPKernelApp.launch_instance(kernel_class=Radare2Kernel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (C) 2017 Guillaume Valadon <[email protected]> | ||
|
||
|
||
import os | ||
import json | ||
from setuptools import setup | ||
|
||
from jupyter_client.kernelspec import install_kernel_spec | ||
from IPython.utils.tempdir import TemporaryDirectory | ||
|
||
|
||
setup(name="jupyter_radare2", | ||
description="A Jupyter radare2 kernel", | ||
author="Guillaume Valadon", | ||
author_email="[email protected]", | ||
version="0.1", | ||
url="https://github.com/guedou/jupyter_radare2", | ||
py_modules=["radare2"], | ||
) | ||
|
||
|
||
install_kernel_spec("./kernel_spec", "radare2", user=True, replace=True) |