From 4fa9b6732b00698b34f3a62cedecab26c1cae3ad Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 21 Mar 2024 18:31:52 +0100 Subject: [PATCH] Add the required README for r2pipe-ts --- typescript/README.md | 42 ++++++++++++++++++++++++++++++++++++ typescript/package-lock.json | 17 +++------------ typescript/package.json | 25 ++++++++++++++++----- 3 files changed, 65 insertions(+), 19 deletions(-) create mode 100644 typescript/README.md diff --git a/typescript/README.md b/typescript/README.md new file mode 100644 index 0000000..e9ea6c0 --- /dev/null +++ b/typescript/README.md @@ -0,0 +1,42 @@ +# r2pipe API for radare2 + +![r2pipe logo](http://lolcathost.org/b/r2pipe.png) + +This is a reimplementation in TypeScript of the original `r2pipe` and `r2pipe-promise` modules for NodeJS. + +## Usage + +If you are using r2skel (`r2pm -ci r2skel`) you can get a hello world to use this module with the following line: + +``` +r2pm -r r2skel r2-script-r2pipe-ts hello-ts +make -C hello-ts +``` + +## Basics + +The basic fundamentals of r2pipe is that you the API provides the most basic communication channel with r2, this is a single function called `cmd` that takes the command to be executed and returns the output of the command as a string. + +As long as many commands in r2 return JSON, it is ideal for working with TS/JS, because using `cmdj()` the API will convert the output into an object. + +In order to provide compatibility with all kind of backends, the whole api has been made asynchronous, this allows the developer to change the backend by only changing one line. + +Note that stderr events are not handled by this API, process stdin/stdout is also not handled by r2pipe, but there are ways to manage it if needed. + +## Supported r2pipe methods + +* http (since node 18, plaintext http networking is not allowed unless you use the `--insecure-http-parser` flag) +* spawn (launch a new radare2 process and communicate with it sending async commands to collect the response) +* local (the local pipe is used when launching scripts from `r2 -i too.ts` or `> . too.ts` + +## r2Frida-Compile + +radare2 also supports the esm modules generated by frida-compile. But it is worth to mention that r2frida comes with a C reimplementation of frida-compile (python). Which ships a typescript compiler and is able to pack multiple ts/js files into a single file. + +## Runtime + +This module is suposed to run with NodeJS, under some circunstancies, it may also with with r2js, bun or deno. + +## Author + +--pancake <@nopcode.org> diff --git a/typescript/package-lock.json b/typescript/package-lock.json index 812c6bb..bc01e2b 100644 --- a/typescript/package-lock.json +++ b/typescript/package-lock.json @@ -1,16 +1,13 @@ { "name": "r2pipe-ts", - "version": "0.0.6", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "r2pipe-ts", - "version": "0.0.6", + "version": "0.1.0", "license": "MIT", - "dependencies": { - "wtfnode": "^0.9.1" - }, "devDependencies": { "@types/node": "^20.11.28", "@typescript-eslint/eslint-plugin": "^7.2.0", @@ -19,7 +16,7 @@ "typescript": "^5.0.0" }, "engines": { - "node": ">=20.0" + "node": ">=18.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -1606,14 +1603,6 @@ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, - "node_modules/wtfnode": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/wtfnode/-/wtfnode-0.9.1.tgz", - "integrity": "sha512-Ip6C2KeQPl/F3aP1EfOnPoQk14Udd9lffpoqWDNH3Xt78svxPbv53ngtmtfI0q2Te3oTq79XKTnRNXVIn/GsPA==", - "bin": { - "wtfnode": "proxy.js" - } - }, "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", diff --git a/typescript/package.json b/typescript/package.json index c46148f..46d5844 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -1,13 +1,13 @@ { "name": "r2pipe-ts", - "version": "0.0.6", + "version": "0.1.0", "description": "TypeScript r2pipe API", "type": "commonjs", "main": "./r2pipe/index.js", "types": "./r2pipe/index.d.js", "license": "MIT", "engines": { - "node": ">=20.0" + "node": ">=18.0" }, "devDependencies": { "@types/node": "^20.11.28", @@ -16,7 +16,22 @@ "eslint": "^8.34.0", "typescript": "^5.0.0" }, - "dependencies": { - "wtfnode": "^0.9.1" - } + "files": [ + "README.md", + "r2pipe/base.js", + "r2pipe/index.js", + "r2pipe/http.js", + "r2pipe/spawn.js" + ], + "keywords": [ + "radare", + "radare2", + "r2", + "reversing", + "disassembler", + "hexadecimal", + "editor", + "exploit", + "exploiting" + ] }