Giter Site home page Giter Site logo

radare2-pm's Introduction

R2PM

This repository is fetched by r2pm -U and provides the package database.

These packages are installed in user's home and can be plugins/scripts for radare2 or even utilities/programs related to r2.

See https://github.com/radareorg/radare2 for r2pm

How to use

$ r2pm -U
$ r2pm -ci r2frida

Testing new packages

export R2PM_DBDIR="$PWD/db"
# export R2PM_GITDIR="/path/to/the/root/folder/of/the/local/repository"
# export R2PM_USRDIR="/path/to/usr/dir"

radare2-pm's People

Contributors

alexkornitzer avatar apkunpacker avatar condret avatar d4em0n avatar fr0ster avatar fxti avatar gcolajan avatar jpenalbae avatar jroimartin avatar kazarmy avatar mrmacete avatar nicolaisoeborg avatar oleavr avatar p4n74 avatar packmad avatar radare avatar ret2libc avatar riptl avatar s0i37 avatar securisec avatar svenito avatar sylvainpelissier avatar thestr4ng3r avatar trufae avatar vpaulv avatar wargio avatar xarkes avatar xvilka avatar zamaudio avatar zlowram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

radare2-pm's Issues

r2pm -d / --doc not working

The -d / --doc switch doesn't seem to work. I use "?" within r2 to gain quick information on changes by diffing and I'd like to have something similar for plugins. "?" doesn't add plugin commands documentation for this.

If I type in any "r2pm -d" request the terminal only responds with the according help entry, e.g.:

$ r2pm -d pyc

Usage: r2pm -d [package] # show docs on [package]

I'd expect any kind of documentation.

I just used:

$ r2pm -v

r2pm 4.5.0-git

with:

$ r2 -v

radare2 4.5.0-git 24563 @ linux-x86-64 git.4.4.0-88-g2bf97bf57
commit: 2bf97bf5703cb8768871c72cd2bcd7009a9726ed build: 2020-04-27__09:28:08

... but this problem remains since I first tried it.

n.b.: I will post an enhancement request for radare2 in a minute, as I'd prefer to get the centrally through r2 via "?*". In case you'd implement that enhancement I wouldn't mind r2pm -d working or not.

error install r2frida

[~] r2pm install r2frida
Already up to date.
Install Done For r2frida
[ "readlink ext/frida" = frida-linux-10.6.41 ] ||
(cd ext && rm -f frida ; ln -fs frida-linux-10.6.41 frida)
make io_frida.so
make[1]: Entering directory '/root/.config/radare2/r2pm/git/r2frida'
pkg-config --cflags r_core
-I/usr/include/libr -I/usr/include/capstone -I/usr/include/libr
g++ src/io_frida.o -o io_frida.so -shared -fPIC -lr_core -lcapstone -lr_config -lr_debug -lr_bin -lr_anal -lr_bp -lr_egg -lr_asm -lr_lang -lr_parse -lr_flag -lr_cons -lr_reg -lr_search -lr_syscall -lr_fs -lr_io -lr_socket -lr_magic -lmagic -lr_crypto -lr_hash -lr_util -lz -lzip -ldl ext/frida/libfrida-core.a -lresolv
/usr/bin/ld: cannot find -lzip
collect2: error: ld returned 1 exit status
Makefile:104: recipe for target 'io_frida.so' failed
make[1]: *** [io_frida.so] Error 1
make[1]: Leaving directory '/root/.config/radare2/r2pm/git/r2frida'
Makefile:70: recipe for target 'all' failed
make: *** [all] Error 2
ERROR: Build failed

GoReSym package

Description

Please describe what are you missing or wanting to be improved

A package for hanemile/radare2-GoReSym, as suggested by pancake.

Essentially this would allow installing the package and thus installing mandiant/GoReSym. One could then use mandiant/GoReSym inline in order to extract the symbols from the current binary from within radare2 and then import those symbols using hanemile/radare2-GoReSym.

Provide images, ascii-art, test files and anything that may help us understand your request

Well, I've got no images, but I've copied another package as I've got no idea how this is actually done:

R2PM_BEGIN

R2PM_DESC "import symbols from GoReSym"

R2PM_INSTALL() {
	git clone https://github.com/mandiant/GoReSym
	pushd GoReSym
	go build
	popd

        git clone https://github.com/hanemile/radare2-GoReSym
	
	# Extract the symbols from the binary like this
	# GoReSym -t -d -p BINARY > goresym_out.txt
	#
	# Then within radare2:
	# [0x........]> . radare2GoReSym/rename.py
	#
	# Wait a bit and finally, the sumbols are renamed accordingly
}

R2PM_UNINSTALL() {
        rm -rf GoReSym radare2-GoReSym
}

R2PM_END

Duplicate installations of radare-extras for each package

Environment

Tue 21 Mar 10:58:43 CET 2023
radare2 5.8.5 30282 @ linux-x86-64 git.4.2.1-6563-gd6e7c1e162
commit: d6e7c1e162f5ec5b0da066f6394c8767e0592228 build: 2023-03-21__10:41:49
Linux x86_64

Description

r2pm duplicates the content of radare-extras for each package installation.

Test

$ r2pm -i vc4
INFO: Using r2-5.8.5 and r2pm-5.8.5
INFO: git clone --depth=10 --recursive https://github.com/radareorg/radare2-extras /home/sylvain/.local/share/radare2/r2pm/git//vc4
Cloning into '/home/sylvain/.local/share/radare2/r2pm/git//vc4'...
remote: Enumerating objects: 1270, done.
remote: Counting objects: 100% (1270/1270), done.
remote: Compressing objects: 100% (1090/1090), done.
remote: Total 1270 (delta 161), reused 1030 (delta 105), pack-reused 0
Receiving objects: 100% (1270/1270), 7.42 MiB | 854.00 KiB/s, done.
Resolving deltas: 100% (161/161), done.
INFO: Starting install for vc4
INFO: SCRIPT=<<EOF
INFO: 	./configure --prefix="${R2PM_PREFIX}" || exit 1
	cd libr/asm/p || exit 1
	${MAKE} clean
	${MAKE} asm_vc4.${R2_LIBEXT} || exit 1
	mkdir -p "${R2PM_PLUGDIR}" || exit 1
	cp -f asm_vc4.${R2_LIBEXT} "${R2PM_PLUGDIR}" || exit 1
INFO: EOF
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for working directories... current
using prefix '/home/sylvain/.local/share/radare2/prefix'
checking for pkg-config... Cannot find pkg-config or pkgconf in PATH

After the installation of the package vc4, the package folder contains the full radare2-extras repository:

$ ls ~/.local/share/radare2/r2pm/git/vc4
agc         binr            crashlog  jaguar-gpu  Makefile.acr    r2au       r2poke     ramoji2       ssdeep
asahi       blessr2         docker    kaitai      md380           r2elisa    r2pongo    rar           sys
Attic       checkm8         doc.sw    kdp         microblaze      r2emuhash  r2snowman  README.md     types
autogen.sh  configure       dwarf     keystone    openai          r2graph    r2svd      reil          unicorn
baleful     configure.acr   east      libr        options.mk.acr  r2ida      r2taint    rust-asm6502  world
bcl         COPYING         examples  lief        pimp            r2jadx     r2tox      scriptcraft   yara
binarly     COPYING.LESSER  iref      lua53       r2angr          r2k        r2w        slides        zpu

It is the same for each package installed and thus add unnecessary copy of radare2-extras.

Update iaito installation script

Radare2 installed from git
Iaito installed using r2pm -i iaito

[ arch ~ ]$ iaito
iaito: error while loading shared libraries: libr_core.so: cannot open shared object file: No such file or directory

I had to add /usr/local/lib to /etc/ld.so.conf in order to make iaito running. radareorg/iaito#59

Shellcheck complains

./binr/r2pm/r2pm:18:8: warning: Declare and assign separately to avoid masking return values. [SC2155]
./binr/r2pm/r2pm:18:19: note: Use $(..) instead of legacy `..`. [SC2006]
./binr/r2pm/r2pm:19:9: note: Use $(..) instead of legacy `..`. [SC2006]
./binr/r2pm/r2pm:21:1: warning: LIBDIR appears unused. Verify it or export it. [SC2034]
./binr/r2pm/r2pm:22:1: warning: WRKDIR appears unused. Verify it or export it. [SC2034]
./binr/r2pm/r2pm:23:8: warning: Declare and assign separately to avoid masking return values. [SC2155]
./binr/r2pm/r2pm:23:16: note: Use $(..) instead of legacy `..`. [SC2006]
./binr/r2pm/r2pm:24:8: warning: Declare and assign separately to avoid masking return values. [SC2155]
./binr/r2pm/r2pm:24:19: note: Use $(..) instead of legacy `..`. [SC2006]
./binr/r2pm/r2pm:36:8: warning: Declare and assign separately to avoid masking return values. [SC2155]
./binr/r2pm/r2pm:36:25: note: Use $(..) instead of legacy `..`. [SC2006]
./binr/r2pm/r2pm:49:1: warning: R2PM_ETCD appears unused. Verify it or export it. [SC2034]
./binr/r2pm/r2pm:71:2: warning: IS_SYSPKG appears unused. Verify it or export it. [SC2034]
./binr/r2pm/r2pm:82:3: warning: Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames. [SC2010]
./binr/r2pm/r2pm:84:3: note: Use find instead of ls to better handle non-alphanumeric filenames. [SC2012]
./binr/r2pm/r2pm:91:18: note: Use ./*glob* or -- *glob* so names with dashes won't become options. [SC2035]
./binr/r2pm/r2pm:91:47: note: Use $(..) instead of legacy `..`. [SC2006]
./binr/r2pm/r2pm:93:18: note: Use ./*glob* or -- *glob* so names with dashes won't become options. [SC2035]
./binr/r2pm/r2pm:93:47: note: Use $(..) instead of legacy `..`. [SC2006]
./binr/r2pm/r2pm:99:24: note: Use ./*glob* or -- *glob* so names with dashes won't become options. [SC2035]
./binr/r2pm/r2pm:99:53: note: Use $(..) instead of legacy `..`. [SC2006]
./binr/r2pm/r2pm:102:9: note: Double quote to prevent globbing and word splitting. [SC2086]
./binr/r2pm/r2pm:109:7: note: Use $(..) instead of legacy `..`. [SC2006]
./binr/r2pm/r2pm:109:17: note: Double quote to prevent globbing and word splitting. [SC2086]
./binr/r2pm/r2pm:110:2: warning: Use cd ... || exit in case cd fails. [SC2164]
./binr/r2pm/r2pm:112:3: warning: Use cd ... || exit in case cd fails. [SC2164]
./binr/r2pm/r2pm:121:31: error: Argument mixes string and array. Use * or separate argument. [SC2145]
./binr/r2pm/r2pm:127:2: warning: R2PM_GIT appears unused. Verify it or export it. [SC2034]
./binr/r2pm/r2pm:131:26: warning: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. [SC2166]
./binr/r2pm/r2pm:133:3: warning: Use cd ... || exit in case cd fails. [SC2164]
./binr/r2pm/r2pm:134:13: note: Use find instead of ls to better handle non-alphanumeric filenames. [SC2012]
./binr/r2pm/r2pm:136:2: warning: Use cd ... || exit in case cd fails. [SC2164]
./binr/r2pm/r2pm:138:9: warning: Don't use variables in the printf format string. Use printf "..%s.." "$foo". [SC2059]
./binr/r2pm/r2pm:138:14: note: Use find instead of ls to better handle non-alphanumeric filenames. [SC2012]
./binr/r2pm/r2pm:162:4: warning: Can't follow non-constant source. Use a directive to specify location. [SC1090]
./binr/r2pm/r2pm:179:4: warning: Can't follow non-constant source. Use a directive to specify location. [SC1090]
./binr/r2pm/r2pm:195:15: error: Double quote array expansions to avoid re-splitting elements. [SC2068]
./binr/r2pm/r2pm:199:8: note: Double quote to prevent globbing and word splitting. [SC2086]
./binr/r2pm/r2pm:203:17: error: Double quote array expansions to avoid re-splitting elements. [SC2068]
./binr/r2pm/r2pm:210:14: note: Use $(..) instead of legacy `..`. [SC2006]
./binr/r2pm/r2pm:211:17: note: $/${} is unnecessary on arithmetic variables. [SC2004]
./binr/r2pm/r2pm:216:13: note: Double quote to prevent globbing and word splitting. [SC2086]
./binr/r2pm/r2pm:216:62: note: Double quote to prevent globbing and word splitting. [SC2086]
./binr/r2pm/r2pm:219:13: note: Double quote to prevent globbing and word splitting. [SC2086]
./binr/r2pm/r2pm:219:62: note: Double quote to prevent globbing and word splitting. [SC2086]
./binr/r2pm/r2pm:243:15: error: Double quote array expansions to avoid re-splitting elements. [SC2068]
./binr/r2pm/r2pm:252:17: error: Double quote array expansions to avoid re-splitting elements. [SC2068]

Acompilation error occurred when i install r2golf:has no member named ‘cmd_depth’

➜  ~ r2pm -i r2golf
Cloning into 'r2lrn'...
remote: Enumerating objects: 46, done.
remote: Counting objects: 100% (46/46), done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 46 (delta 0), reused 32 (delta 0), pack-reused 0
Unpacking objects: 100% (46/46), done.
Install Done For r2golf
cc -g -I/usr/include/libr -lr_core -lr_config -lr_debug -lr_bin -lr_anal -lr_bp -lr_egg -lr_asm -lr_lang -lr_parse -lr_flag -lr_cons -lr_reg -lr_search -lr_syscall -lr_fs -lr_io -lr_socket -lr_magic -lr_crypto -lr_hash -lr_util -ldl -shared -o r2golf.so plugin.c
plugin.c: In function ‘isRootCommand’:
plugin.c:201:36: error: ‘RConsContext {aka struct r_cons_context_t}’ has no member named ‘cmd_depth’
  int curDepth = core->cons->context->cmd_depth;
                                    ^~
Makefile:7: recipe for target 'all' failed
make: *** [all] Error 1
mkdir -p "/home/lushan/.local/share/radare2/plugins"
cp -f r2golf.so "/home/lushan/.local/share/radare2/plugins"
cp: cannot stat 'r2golf.so': No such file or directory
Makefile:10: recipe for target 'install' failed
make: *** [install] Error 1

ubuntu 1804
r2pm 3.7.0

Causes error 127 if Cmake isn't already installed.

r2pm install package causes error 127 if Cmake isn't already installed. Happened when I installed r2snow. Don't know if this is right place to report it. Error happens on cmake version line. Worked/Installed properly after installing cmake. Happened on Kali OS using WSL on Windows.

pick another command line flag for "info"

So I just tried to run r2pm -i to get information about installed packages but it returned nothing.

I double-checked the manpage and had a good laugh:

     -i, info    Show information about repository and installed packages

     -i, install pkgname
                 Install a package

Might want to change the flag from -i to -I or something :)

Add and use R2PM_VERSION

This keyword is still not handled, but will be good to start versioning the packages, and be able to use that var in the clone urls and installation scripts blocks

ERROR: This package does not have R2PM_INSTALL_WINDOWS instructions

Running r2pm -ci r2frida gives me an error

INFO: Using r2-5.8.9 and r2pm-5.8.9                                                                                     
INFO: Cleaning r2frida                                                                                                
fatal: not a git repository (or any of the parent directories): .git                                                    
INFO: Starting install for r2frida                                                                                      
ERROR: This package does not have R2PM_INSTALL_WINDOWS instructions```

Use more R2PM_DOC

Very few packages provide documentation about how to use the plugin or tool. will be good to extend that and improve the current ones

Dont use R2PM_FAIL

This keyword is marked as deprecated because it doesnt with r2pm.c you can just use exit 1 because the function is not a bash subroutine. so we must replace all those r2pmfails with echo+exit or just exit 1

r2golf install error

I have the issue with installing r2golf plugin.
r2pm version 3.9.0
Arch and Kali - both the same.

root@kali:~/temp/radare2-3.9.0# r2pm -i r2golf
Already up to date.
Install Done For r2golf
cc -g -I/usr/include/libr -lr_core -lssl -lcrypto -lr_config -lr_debug -lr_bin -lr_anal -lr_bp -lr_egg -lr_asm -lr_lang -lr_parse -lr_flag -lr_cons -lr_reg -lr_search -lr_syscall -lr_fs -lr_io -lr_socket -lr_magic -lr_crypto -lr_hash -lr_util -ldl -shared -o r2golf.so plugin.c
/usr/bin/ld: /tmp/ccEFKDx0.o: relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [Makefile:7: all] Error 1
mkdir -p "/root/.local/share/radare2/plugins"
cp -f r2golf.so "/root/.local/share/radare2/plugins"
cp: cannot stat 'r2golf.so': No such file or directory
make: *** [Makefile:11: install] Error 1

`r2pm install r2frida` fails - should I use another command?

r2pm install r2frida always fails on my mac.

radare 2 is installed and working. r2pm version installed was r2pm 1.3.0

Makefile:1: config.mk: No such file or directory
./configure
checking build system type... x86_64-unknown-darwin
checking host system type... x86_64-unknown-darwin
checking target system type... x86_64-unknown-darwin
checking for working directories... current
using prefix '/usr/local'
checking for c compiler... gcc
checking for c++ compiler... g++
Using PKGCONFIG: pkg-config
checking pkg-config flags for r_core... yes
checking for curl... /usr/bin/curl
checking for wget... no
checking for git... /usr/bin/git
checking for xz... /usr/local/bin/xz
checking for node... no
error: This program is required.
make: *** [config.mk] Error 1
**ERROR: Build failed**

Cannot use $dec alias

/home/vagrant/.local/share/radare2/r2pm/git/r2retdec/node_modules/r2pipe/index.js:403
    const ls = proc.spawn(this.r2bin, ['-qc.:' + port].concat(...opts).concat(file));
                                                              ^^^

SyntaxError: Unexpected token ...
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/vagrant/.local/share/radare2/r2pm/git/r2retdec/r2retdec.js:1:78)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)

alias:

vagrant@ubuntu-xenial:/vagrant/test$ cat ~/.radare2rc 
$dec=#!pipe node /home/vagrant/.local/share/radare2/r2pm/git//r2retdec/r2retdec.js

radare:

vagrant@ubuntu-xenial:/vagrant/test$ r2 -v
radare2 2.6.0-git 18219 @ linux-x86-64 git.2.5.0-297-gefda76c
commit: efda76cc18f164dce2e468bbe095b6f0c6e5a43a build: 2018-05-20__01:20:18

path to the decompiler:

vagrant@ubuntu-xenial:/vagrant/test$ cat ~/.r2retdec 
/opt/retdec/bin/retdec-decompiler.sh

Asciinema:
asciicast

How I'm supposed to use it?

Support windows in more packages

Right now r2pm.c supports windows. but only the packages containing R2PM_INSTALL_WINDOWS() directives do work in there. the packages must be updated to ship an installation script, ideally using binary builds of the packages to get them installed in the right place. powershell is probably prefered over cmd scripts.

  • See r2frida for inspiration.
  • Check and run that stuff in windows

Add lang-* packages

to build and install all the plugins from r2b/libr/lang/p/lang_*

see the makefile in libr/lang, there's already d/csharp. which should be probably renamed to lang-csharp

Support binary packages

We need a binary r2pm tool that will fetch binary builds of the packages. The reason for this is because Windows, Android and iOS users usually don't have a compiler and r2pm is a shellscript that may not work on those platforms without dependencies or other tools installed.

We can put all those builds in branches or in another repo, but we need a way to automate the build of most interesting plugins like keystone, dirtycow, ... for those platforms

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.