{"id":13643564,"url":"https://github.com/wargio/r2dec-js","last_synced_at":"2025-04-04T17:08:56.567Z","repository":{"id":21489260,"uuid":"89411088","full_name":"wargio/r2dec-js","owner":"wargio","description":"radare2 plugin - converts asm to pseudo-C code.","archived":false,"fork":false,"pushed_at":"2024-04-06T14:36:32.000Z","size":6096,"stargazers_count":488,"open_issues_count":39,"forks_count":47,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-04-13T23:29:48.737Z","etag":null,"topics":["assembly","converts-asm","decompiler","duktape","javascript","pseudo","radare2"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wargio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSES/BSD-3-Clause.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-25T22:03:55.000Z","updated_at":"2024-05-01T03:34:01.729Z","dependencies_parsed_at":"2023-02-15T07:45:41.213Z","dependency_job_id":"9e2439b5-047e-4cb7-9d8d-339a0c53d557","html_url":"https://github.com/wargio/r2dec-js","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wargio%2Fr2dec-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wargio%2Fr2dec-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wargio%2Fr2dec-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wargio%2Fr2dec-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wargio","download_url":"https://codeload.github.com/wargio/r2dec-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217184,"owners_count":20903009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","converts-asm","decompiler","duktape","javascript","pseudo","radare2"],"created_at":"2024-08-02T01:01:49.331Z","updated_at":"2025-04-04T17:08:56.547Z","avatar_url":"https://github.com/wargio.png","language":"C","readme":"![Build Status](https://github.com/wargio/r2dec-js/workflows/continuous-tests/badge.svg)\n[![CodeFactor](https://www.codefactor.io/repository/github/wargio/r2dec-js/badge)](https://www.codefactor.io/repository/github/wargio/r2dec-js)\n\n![r2dec](https://raw.githubusercontent.com/wargio/r2dec-js/image/r2dec200.png)\n\nConverts asm to pseudo-C code.\n\n# Software Requirements\n\nRequires radare2\n\n# Install\n\nFollow the following steps to install r2dec via r2pm\n\n### Install using r2pm:\n\n```bash\n# initialize the r2pm database\n$ r2pm -U\n# install r2dec via r2pm\n$ r2pm -i r2dec\n```\n\n### Manual build \u0026 install:\n\n - clone this repository\n - Run `meson setup build` to create the build folder\n - Run `ninja -C build install` to build the shared library and to install it \n\n# Usage\n\n* Open your file with radare2\n* Analyze the function you want to disassemble (`af`)\n* Run the plugin via `pdd`\n\n# Arguments\n\n```\n[0x00000000]\u003e pdd?\nUsage: pdd [args] - core plugin for r2dec\n pdd           - decompile current function\n pdd?          - show this help\n pdd*          - the decompiled code is returned to r2 as comment (via CCu)\n pdda          - decompile current function side by side with assembly\n pddb          - decompile current function but shows only scopes\n pddo          - decompile current function side by side with offsets\n pddu          - install/upgrade r2dec via r2pm\n pdds \u003cbranch\u003e - switches r2dec branch\n pddi          - generates the issue data\n\nEnvironment\n R2DEC_HOME  defaults to the root directory of the r2dec repo\n\n[0x00000000]\u003e pdd --help\n\nr2dec [options]\n       --help       | this help message\n       --assembly   | shows pseudo next to the assembly\n       --blocks     | shows only scopes blocks\n       --casts      | shows all casts in the pseudo code\n       --colors     | enables syntax colors\n       --debug      | do not catch exceptions\n       --html       | outputs html data instead of text\n       --issue      | generates the json used for the test suite\n       --offsets    | shows pseudo next to the assembly offset\n       --paddr      | all xrefs uses physical addresses instead of virtual addresses\n       --xrefs      | shows also instruction xrefs in the pseudo code\n       --as-comment | the decompiled code is returned to r2 as comment (via CCu)\n       --as-opcode  | the decompiled code is returned to r2 as opcode (via aho)\n```\n\n# Radare2 Evaluable vars\n\nYou can use these in your `.radare2rc` file.\n\n```\nr2dec.asm           | if true, shows pseudo next to the assembly.\nr2dec.blocks        | if true, shows only scopes blocks.\nr2dec.casts         | if false, hides all casts in the pseudo code.\nr2dec.debug         | do not catch exceptions in r2dec.\nr2dec.paddr         | if true, all xrefs uses physical addresses compare.\nr2dec.slow          | if true load all the data before to avoid multirequests to r2.\nr2dec.theme         | defines the color theme to be used on r2dec.\nr2dec.xrefs         | if true, shows all xrefs in the pseudo code.\ne scr.html          | outputs html data instead of text.\ne scr.color         | enables syntax colors.\n```\n\n# Report an Issue\n\n* Open your file with radare2\n* Analyze the function you want to disassemble (`af`)\n* Give the data to the plugin via `pddi` or `pdd --issue`\n* Insert the JSON returned by the previous command into the issue (you can also upload the output)\n\n# Supported Arch\n\n    6502 (experimental)\n    8051 (experimental)\n    arm 16/32/64 bit\n    avr\n    dalvik\n    m68k (experimental)\n    mips\n    ppc 32/64 bit (VLE included)\n    superh (experimental)\n    sparc\n    v850\n    wasm (experimental)\n    x86/x64\n    riscv (experimental)\n\n# Developing on r2dec\n\n[Read DEVELOPERS.md](https://github.com/wargio/r2dec-js/blob/master/DEVELOPERS.md)\n\n## Example\n\nThis example shows a possible dump of the plugin.\n\n### Source Code\n\n```c\n#include \u003cstdio.h\u003e\n\nint main(int argc, char const *argv[]) {\n    int var = 0;\n    while(var \u003c 0x90) {\n        if(var \u003c 0x10) {\n            var += 0x50;\n        }\n        var += 0x10;\n    }\n    return 0;\n}\n```\n\n### radare2 view\n\n\n```\n╭ (fcn) main 50\n│   main (int arg1, int arg2);\n│           ; var int local_20h @ rbp-0x20\n│           ; var int local_14h @ rbp-0x14\n│           ; var signed int local_4h @ rbp-0x4\n│           ; DATA XREF from entry0 (0x1041)\n│           0x00001119      55             push rbp\n│           0x0000111a      4889e5         mov rbp, rsp\n│           0x0000111d      897dec         mov dword [local_14h], edi  ; arg1\n│           0x00001120      488975e0       mov qword [local_20h], rsi  ; arg2\n│           0x00001124      c745fc000000.  mov dword [local_4h], 0\n│       ╭─\u003c 0x0000112b      eb0e           jmp 0x113b\n│       │   ; CODE XREF from main (0x1142)\n│      ╭──\u003e 0x0000112d      837dfc0f       cmp dword [local_4h], 0xf   ; [0xf:4]=0x3e000300\n│     ╭───\u003c 0x00001131      7f04           jg 0x1137\n│     │⋮│   0x00001133      8345fc50       add dword [local_4h], 0x50  ; 'P'\n│     │⋮│   ; CODE XREF from main (0x1131)\n│     ╰───\u003e 0x00001137      8345fc10       add dword [local_4h], 0x10\n│      ⋮│   ; CODE XREF from main (0x112b)\n│      ⋮╰─\u003e 0x0000113b      817dfc8f0000.  cmp dword [local_4h], 0x8f  ; [0x8f:4]=0x2a800\n│      ╰──\u003c 0x00001142      7ee9           jle 0x112d\n│           0x00001144      b800000000     mov eax, 0\n│           0x00001149      5d             pop rbp\n╰           0x0000114a      c3             ret\n```\n\n### r2dec pseudo-C code\n\n```c\n/* r2dec pseudo C output */\n#include \u003cstdint.h\u003e\n \nint32_t main (int32_t argc, char ** argv) {\n    char ** local_20h;\n    int32_t local_14h;\n    int32_t local_4h;\n    local_14h = edi;\n    local_20h = rsi;\n    local_4h = 0;\n    while (local_4h \u003c= 0x8f) {\n        if (local_4h \u003c= 0xf) {\n            local_4h += 0x50;\n        }\n        local_4h += 0x10;\n    }\n    eax = 0;\n    return eax;\n}\n```\n","funding_links":[],"categories":["JavaScript","2. [↑](#-content) Pentesting","Scripts"],"sub_categories":["2.3 [↑](#-content) Decompilers","Conferences"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwargio%2Fr2dec-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwargio%2Fr2dec-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwargio%2Fr2dec-js/lists"}