From 24c7c33cdfc775a43f01366113d60793347b4df8 Mon Sep 17 00:00:00 2001 From: securisec Date: Tue, 20 Mar 2018 13:57:18 -0400 Subject: [PATCH] Mouse draggable, and python decompilation syntax. Updated readme. Removed docs from cmake. --- README.md | 10 ++++++---- r2retdec.js | 15 +++++++++++++-- retdec_install.sh | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2187537..f2bc460 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ![repo size](https://img.shields.io/github/repo-size/securisec/r2retdec.svg) -r2retdec is a bridge in between radare2 and retdec and decompiles individual functions. It also provides summary of strings, xrefs and calls for a function. +r2retdec is a bridge in between radare2 and retdec and decompiles individual functions. It also provides summary of strings, xrefs and calls for a function. The various windows are mouse scrollable and draggable. [![asciicast](https://asciinema.org/a/170931.png)](https://asciinema.org/a/170931) @@ -15,7 +15,8 @@ r2pm init r2pm update r2pm -i r2retdec ``` -Create a file in $HOME call .r2retdec and put the full path to retdec-decompiler.sh in it. +- Create a file in $HOME call .r2retdec and put the full path to retdec-decompiler.sh in it. +- A basic installation script is included in this repo. retdec_install.sh ## Uninstallation ``` @@ -31,12 +32,13 @@ r2retdec help Optional arguments: -h, --help Show this help message and exit. -t TMP Set temp file for decompiled code - -p Print decompilation to stdout + -p Print dicompilation to stdout + --python Print decompilation in python syntax. Default is C Invoke from inside r2 shell with $dec ``` -Press `h` in visual mode for visual mode help +- Press `h` in visual mode for visual mode help ## Dependencies Needs a locally compiled retdec available from https://github.com/avast-tl/retdec diff --git a/r2retdec.js b/r2retdec.js index 3b6aa2e..04c187e 100644 --- a/r2retdec.js +++ b/r2retdec.js @@ -25,6 +25,11 @@ function arg_help() { dest: 'print', action: 'storeTrue' }); + parser.addArgument('--python', { + help: 'Print decompilation in python syntax. Default is C', + dest: 'python', + action: 'storeTrue' + }); return parser.parseArgs(); } @@ -50,6 +55,7 @@ function boxFrame(align, height, width, content) { keys: true, mouse: true, top: align, + draggable: true, left: 'center', width: width, height: height, @@ -93,9 +99,14 @@ var functionStartAddress = '0x' + pdf.addr.toString(16); var functionEndAddress = '0x' + pdf.ops.pop().offset.toString(16); var retDecPath = checkConfig().replace('\n', ''); var a = arg_help(); -var command = `${retDecPath} --cleanup -o ${a.tmp} --select-ranges ${functionStartAddress}-${functionEndAddress} ${binaryPath}`; var function_pdf = r2.cmd('pdf'); +if (a.python === true) { + var command = `${retDecPath} --cleanup -o ${a.tmp} -l py --select-ranges ${functionStartAddress}-${functionEndAddress} ${binaryPath}`; +} else { + var command = `${retDecPath} --cleanup -o ${a.tmp} --select-ranges ${functionStartAddress}-${functionEndAddress} ${binaryPath}`; +} + try { var p = exec(command).toString(); var code = fs.readFileSync(a.tmp, 'utf8'); @@ -185,4 +196,4 @@ box2.key(['q'], function () { process.exit(0); }); -screen.render(); +screen.render(); \ No newline at end of file diff --git a/retdec_install.sh b/retdec_install.sh index d86f971..a482429 100644 --- a/retdec_install.sh +++ b/retdec_install.sh @@ -18,7 +18,7 @@ sudo make install cd ~/retdec mkdir build && cd build -cmake -DCMAKE_INSTALL_PREFIX=$HOME/retdec-install -DRETDEC_DOC=ON .. +cmake -DCMAKE_INSTALL_PREFIX=$HOME/retdec-install .. wget https://github.com/avast-tl/llvm/archive/753e703b185f07f6f85c8ca474a65f4a965371b1.zip -O external/src/llvm.zip make -j$cpucores make install