Skip to content
This repository has been archived by the owner on Dec 4, 2021. It is now read-only.

Commit

Permalink
Mouse draggable, and python decompilation syntax. Updated readme. Rem…
Browse files Browse the repository at this point in the history
…oved docs from cmake.
  • Loading branch information
securisec committed Mar 20, 2018
1 parent 5f036fd commit 24c7c33
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
10 changes: 6 additions & 4 deletions README.md
Expand Up @@ -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)

Expand All @@ -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
```
Expand All @@ -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
Expand Down
15 changes: 13 additions & 2 deletions r2retdec.js
Expand Up @@ -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();
}

Expand All @@ -50,6 +55,7 @@ function boxFrame(align, height, width, content) {
keys: true,
mouse: true,
top: align,
draggable: true,
left: 'center',
width: width,
height: height,
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -185,4 +196,4 @@ box2.key(['q'], function () {
process.exit(0);
});

screen.render();
screen.render();
2 changes: 1 addition & 1 deletion retdec_install.sh
Expand Up @@ -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

0 comments on commit 24c7c33

Please sign in to comment.