nowsecure / r2frida

Radare2 and Frida better together.
MIT License
1.18k stars 121 forks source link

ERROR: Build failed #287

Closed Green360 closed 3 years ago

Green360 commented 3 years ago

I am using Ubuntu 20.04 and followed the install instructions:

$ sudo apt install -y make gcc libzip-dev nodejs npm curl pkg-config git $ r2pm -ci r2frida

Unfortunately, the build failed. This it what I get:

Cleaning r2frida...
Already up to date.
clean Done For r2frida
/home/none/.local/share/radare2/r2pm/db/r2frida TGZ=
Cleaning up /home/none/.local/share/radare2/r2pm/git//r2frida...
Cloning into 'r2frida'...
remote: Enumerating objects: 75, done.
remote: Counting objects: 100% (75/75), done.
remote: Compressing objects: 100% (70/70), done.
remote: Total 75 (delta 1), reused 38 (delta 0), pack-reused 0
Unpacking objects: 100% (75/75), 132.33 KiB | 857.00 KiB/s, done.
Submodule 'ext/swift-frida' (https://github.com/trufae/swift-frida.git) registered for path 'ext/swift-frida'
Cloning into '/home/none/.local/share/radare2/r2pm/git/r2frida/ext/swift-frida'...
remote: Enumerating objects: 683, done.        
remote: Total 683 (delta 0), reused 0 (delta 0), pack-reused 683        
Receiving objects: 100% (683/683), 269.50 KiB | 1.11 MiB/s, done.
Resolving deltas: 100% (450/450), done.
Submodule path 'ext/swift-frida': checked out '4ae3db96fc481507ac12867d0829fe4f12f6ab6f'
Install Done For r2frida
./configure
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 '/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... /usr/bin/wget
checking for git... /usr/bin/git
checking for xz... /usr/bin/xz
checking for node... /usr/bin/node
checking for npm... /usr/bin/npm
creating ./config.mk
creating ./config.h
cleaning temporally files... done
rm -f ext/frida
mkdir -p ext/frida-linux-14.1.3/_
curl -Ls https://github.com/frida/frida/releases/download/14.1.3/frida-core-devkit-14.1.3-linux-x86_64.tar.xz | xz -d | tar -C ext/frida-linux-14.1.3/_ -xf -
mv ext/frida-linux-14.1.3/_/* ext/frida-linux-14.1.3
rmdir ext/frida-linux-14.1.3/_
#mv ext/frida ext/frida-linux-14.1.3
cd ext && ln -fs frida-linux-14.1.3 frida
[ "`readlink ext/frida`" = frida-linux-14.1.3 ] || \
    (cd ext && rm -f frida ; ln -fs frida-linux-14.1.3 frida)
make io_frida.so
make[1]: Entering directory '/home/none/.local/share/radare2/r2pm/git/r2frida'
mkdir -p node_modules
npm i

> r2frida-agent@5.0.1 prepare /home/none/.local/share/radare2/r2pm/git/r2frida
> npm run build

> r2frida-agent@5.0.1 build /home/none/.local/share/radare2/r2pm/git/r2frida
> frida-compile src/agent -o src/_agent.js -c

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 414 packages from 235 contributors and audited 415 packages in 10.858s

55 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

npm run build

> r2frida-agent@5.0.1 build /home/none/.local/share/radare2/r2pm/git/r2frida
> frida-compile src/agent -o src/_agent.js -c

r2 -nfqcpc src/_agent.js | grep 0x > src/_agent.h
cc -c -fPIC -g -I/usr/include/libr -I/usr/include/capstone -I/usr/include/libr -Iext/frida src/io_frida.c -o src/io_frida.o
src/io_frida.c: In function ‘r_io_frida_new’:
src/io_frida.c:134:17: error: ‘RIO’ {aka ‘struct r_io_t’} has no member named ‘corebind’
  134 |  rf->r2core = io->corebind.core;
      |                 ^~
In file included from src/io_frida.c:9:
src/io_frida.c: In function ‘r_io_frida_free’:
ext/frida/frida-core.h:13142:18: warning: passing argument 1 of ‘_frida_g_object_unref’ discards ‘volatile’ qualifier from pointer target type [-Wdiscarded-qualifiers]
13142 |       (destroy) (_ptr);                                  \
      |                  ^~~~
ext/frida/frida-core.h:30420:36: note: in expansion of macro ‘g_clear_pointer’
30420 | #define g_clear_object(object_ptr) g_clear_pointer ((object_ptr), g_object_unref)
      |                                    ^~~~~~~~~~~~~~~
src/io_frida.c:177:2: note: in expansion of macro ‘g_clear_object’
  177 |  g_clear_object (&rf->crash);
      |  ^~~~~~~~~~~~~~
In file included from src/io_frida.c:9:
ext/frida/frida-core.h:30239:64: note: expected ‘gpointer’ {aka ‘void *’} but argument is of type ‘volatile FridaCrash *’ {aka ‘volatile struct _FridaCrash *’}
30239 | void        g_object_unref                    (gpointer        object);
      |                                                ~~~~~~~~~~~~~~~~^~~~~~
src/io_frida.c: In function ‘__open’:
src/io_frida.c:361:44: warning: passing argument 2 of ‘r_file_slurp’ from incompatible pointer type [-Wincompatible-pointer-types]
  361 |   code_malloc_data = r_file_slurp (r2f_as, &code_size);
      |                                            ^~~~~~~~~~
      |                                            |
      |                                            size_t * {aka long unsigned int *}
In file included from /usr/include/libr/r_cons.h:21,
                 from /usr/include/libr/r_agraph.h:5,
                 from /usr/include/libr/r_core.h:10,
                 from src/io_frida.c:3:
/usr/include/libr/r_util/r_file.h:32:13: note: expected ‘int *’ but argument is of type ‘size_t *’ {aka ‘long unsigned int *’}
   32 | R_API char *r_file_slurp(const char *str, int *usz);
      |             ^~~~~~~~~~~~
src/io_frida.c:471:5: error: ‘RIO’ {aka ‘struct r_io_t’} has no member named ‘corebind’
  471 |   io->corebind.cmd (rf->r2core, autocompletions[i]);
      |     ^~
src/io_frida.c: In function ‘__system_continuation’:
src/io_frida.c:744:26: warning: implicit declaration of function ‘r_str_trim_head_ro’; did you mean ‘r_str_trim_head’? [-Wimplicit-function-declaration]
  744 |    gchar *path = strdup (r_str_trim_head_ro (command + 3));
      |                          ^~~~~~~~~~~~~~~~~~
      |                          r_str_trim_head
src/io_frida.c:744:26: warning: passing argument 1 of ‘strdup’ makes pointer from integer without a cast [-Wint-conversion]
  744 |    gchar *path = strdup (r_str_trim_head_ro (command + 3));
      |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                          |
      |                          int
In file included from /usr/include/libr/r_types.h:210,
                 from /usr/include/libr/r_main.h:6,
                 from /usr/include/libr/r_core.h:6,
                 from src/io_frida.c:3:
/usr/include/string.h:167:14: note: expected ‘const char *’ but argument is of type ‘int’
  167 | extern char *strdup (const char *__s)
      |              ^~~~~~
src/io_frida.c:784:23: warning: initialization of ‘const char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  784 |     const char *arg = r_str_trim_head_ro (command + 2);
      |                       ^~~~~~~~~~~~~~~~~~
src/io_frida.c: In function ‘exec_pending_cmd_if_needed’:
src/io_frida.c:1398:23: error: ‘RIO’ {aka ‘struct r_io_t’} has no member named ‘corebind’
 1398 |  char *output = rf->io->corebind.cmdstr (rf->r2core, rf->pending_cmd->cmd_string);
      |                       ^~
make[1]: *** [Makefile:144: src/io_frida.o] Error 1
make[1]: Leaving directory '/home/none/.local/share/radare2/r2pm/git/r2frida'
make: *** [Makefile:99: all] Error 2
ERROR: Build failed

Does anyone know what to do to make it work? I am not experienced enough to figure it out by myself.

trufae commented 3 years ago

Which is the version of r2?

Green360 commented 3 years ago
$ r2 -v
radare2 4.2.1 0 @ linux-x86-64 git.4.2.1
commit: unknown build: 
trufae commented 3 years ago

Thats very old version of r2. Please use latest r2 release or use the git.

Green360 commented 3 years ago

Yeah with a newer version it goes. At first I used the radare2 Ubuntu package and this seems to be quite old. With the current version from the git it looks like everything is fine.

$ git clone https://github.com/radareorg/radare2.git
$ sys/install.sh
trufae commented 3 years ago

If you find the commit that makes it work with r2-4.2.1 i can add a tag in the r2frida repo to fix the build with r2frida. R2pm will pick the old version in that case