nowsecure / frida-trace

Trace APIs declaratively through Frida.
MIT License
221 stars 28 forks source link

Can't build frida-trace because of ffi #9

Closed louison closed 4 years ago

louison commented 6 years ago

Hi there, thanks for your work. I tried to clone and build this repo and I currently have an error with ffi :

~/Development/work/frida-trace master
❯ npm install
npm WARN deprecated babel-preset-es2015@6.24.1: 🙌  Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!

> ref@1.3.5 install /Users/lgitzing/Development/work/frida-trace/node_modules/ref
> node-gyp rebuild

  CXX(target) Release/obj.target/binding/src/binding.o
../src/binding.cc:360:23: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    String::Utf8Value _str(in);
                      ^
/Users/lgitzing/.node-gyp/10.0.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/lgitzing/.node-gyp/10.0.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/binding.cc:447:23: warning: 'Utf8Value' is deprecated [-Wdeprecated-declarations]
    String::Utf8Value _str(in);
                      ^
/Users/lgitzing/.node-gyp/10.0.0/include/node/v8.h:2821:5: note: 'Utf8Value' has been explicitly marked deprecated here
    V8_DEPRECATED("Use Isolate version",
    ^
/Users/lgitzing/.node-gyp/10.0.0/include/node/v8config.h:321:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated))
                            ^
../src/binding.cc:643:8: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  Nan::ForceSet(target, Nan::New<v8::String>("endianness").ToLocalChecked(), Nan::New<v8::String>(CheckEndianness()).ToLocalChecked(), static_cast<PropertyAttribute>(ReadOnly|DontDelete));
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/binding.cc:644:8: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  Nan::ForceSet(target, Nan::New<v8::String>("NULL").ToLocalChecked(), WrapNullPointer(), static_cast<PropertyAttribute>(ReadOnly|DontDelete));
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
4 warnings generated.
  SOLINK_MODULE(target) Release/binding.node

> ffi@2.2.0 install /Users/lgitzing/Development/work/frida-trace/node_modules/ffi
> node-gyp rebuild

  CC(target) Release/obj.target/ffi/deps/libffi/src/prep_cif.o
  CC(target) Release/obj.target/ffi/deps/libffi/src/types.o
  CC(target) Release/obj.target/ffi/deps/libffi/src/raw_api.o
  CC(target) Release/obj.target/ffi/deps/libffi/src/java_raw_api.o
  CC(target) Release/obj.target/ffi/deps/libffi/src/closures.o
  CC(target) Release/obj.target/ffi/deps/libffi/src/x86/ffi.o
  CC(target) Release/obj.target/ffi/deps/libffi/src/x86/ffi64.o
  CC(target) Release/obj.target/ffi/deps/libffi/src/x86/darwin.o
  CC(target) Release/obj.target/ffi/deps/libffi/src/x86/darwin64.o
  LIBTOOL-STATIC Release/libffi.a
  CXX(target) Release/obj.target/ffi_bindings/src/ffi.o
../src/ffi.cc:58:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(FFI_OK);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:59:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(FFI_BAD_TYPEDEF);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:60:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(FFI_BAD_ABI);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:63:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(FFI_DEFAULT_ABI);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:64:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(FFI_FIRST_ABI);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:65:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(FFI_LAST_ABI);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:81:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(FFI_SYSV);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:83:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(FFI_UNIX64);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:88:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(RTLD_LAZY);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:91:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(RTLD_NOW);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:94:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(RTLD_LOCAL);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:97:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(RTLD_GLOBAL);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:100:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(RTLD_NOLOAD);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:103:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(RTLD_NODELETE);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:106:3: warning: 'ForceSet' is deprecated [-Wdeprecated-declarations]
  SET_ENUM_VALUE(RTLD_FIRST);
  ^
../src/ffi.cc:38:8: note: expanded from macro 'SET_ENUM_VALUE'
  Nan::ForceSet(target, Nan::New<String>(#_value).ToLocalChecked(), \
       ^
../../nan/nan_maybe_43_inl.h:130:1: note: 'ForceSet' has been explicitly marked deprecated here
NAN_DEPRECATED inline Maybe<bool> ForceSet(
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
../src/ffi.cc:111:11: error: no member named 'ForceSet' in 'v8::Object'
  target->ForceSet(Nan::New<String>("RTLD_NEXT").ToLocalChecked(), WrapPointer((char *)RTLD_NEXT), static_cast<PropertyAttribute>(ReadOnly | DontDelete));
  ~~~~~~  ^
../src/ffi.cc:114:11: error: no member named 'ForceSet' in 'v8::Object'
  target->ForceSet(Nan::New<String>("RTLD_DEFAULT").ToLocalChecked(), WrapPointer((char *)RTLD_DEFAULT), static_cast<PropertyAttribute>(ReadOnly | DontDelete));
  ~~~~~~  ^
../src/ffi.cc:117:11: error: no member named 'ForceSet' in 'v8::Object'
  target->ForceSet(Nan::New<String>("RTLD_SELF").ToLocalChecked(), WrapPointer((char *)RTLD_SELF), static_cast<PropertyAttribute>(ReadOnly|DontDelete));
  ~~~~~~  ^
../src/ffi.cc:120:11: error: no member named 'ForceSet' in 'v8::Object'
  target->ForceSet(Nan::New<String>("RTLD_MAIN_ONLY").ToLocalChecked(), WrapPointer((char *)RTLD_MAIN_ONLY), static_cast<PropertyAttribute>(ReadOnly|DontDelete));
  ~~~~~~  ^
../src/ffi.cc:123:11: error: no member named 'ForceSet' in 'v8::Object'
  target->ForceSet(Nan::New<String>("FFI_ARG_SIZE").ToLocalChecked(), Nan::New<Uint32>((uint32_t)sizeof(ffi_arg)), static_cast<PropertyAttribute>(ReadOnly|DontDelete));
  ~~~~~~  ^
../src/ffi.cc:124:11: error: no member named 'ForceSet' in 'v8::Object'
  target->ForceSet(Nan::New<String>("FFI_SARG_SIZE").ToLocalChecked(), Nan::New<Uint32>((uint32_t)sizeof(ffi_sarg)), static_cast<PropertyAttribute>(ReadOnly | DontDelete));
  ~~~~~~  ^
../src/ffi.cc:125:11: error: no member named 'ForceSet' in 'v8::Object'
  target->ForceSet(Nan::New<String>("FFI_TYPE_SIZE").ToLocalChecked(), Nan::New<Uint32>((uint32_t)sizeof(ffi_type)), static_cast<PropertyAttribute>(ReadOnly | DontDelete));
  ~~~~~~  ^
../src/ffi.cc:126:11: error: no member named 'ForceSet' in 'v8::Object'
  target->ForceSet(Nan::New<String>("FFI_CIF_SIZE").ToLocalChecked(), Nan::New<Uint32>((uint32_t)sizeof(ffi_cif)), static_cast<PropertyAttribute>(ReadOnly | DontDelete));
  ~~~~~~  ^
../src/ffi.cc:132:11: error: no member named 'ForceSet' in 'v8::Object'
  target->ForceSet(Nan::New<String>("HAS_OBJC").ToLocalChecked(), Nan::New<Boolean>(hasObjc), static_cast<PropertyAttribute>(ReadOnly | DontDelete));
  ~~~~~~  ^
../src/ffi.cc:367:16: warning: 'Call' is deprecated [-Wdeprecated-declarations]
  p->callback->Call(1, argv);
               ^
../../nan/nan.h:1617:3: note: 'Call' has been explicitly marked deprecated here
  NAN_DEPRECATED inline v8::Local<v8::Value>
  ^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
16 warnings and 9 errors generated.
make: *** [Release/obj.target/ffi_bindings/src/ffi.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:225:12)
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/Cellar/node/9.10.1/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/lgitzing/Development/work/frida-trace/node_modules/ffi
gyp ERR! node -v v10.0.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ffi@2.2.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ffi@2.2.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/lgitzing/.npm/_logs/2018-05-02T09_27_35_874Z-debug.log

I saw that ffi is used by frida-libclang so I built frida-libclang and ffi sepparately and added ffi as a local dependency ("ffi":"file:../../node-ffi" in the frida-libclang package.json. After that, I've been able to build frida-trace, but when I tried to use ./bin/parse-header.js binder.h, I had the following error :

~/Development/work/frida-trace master*
❯ ./bin/parse-header.js binder.h
assert.js:247
    throw err;
    ^

AssertionError [ERR_ASSERTION]: Could not determine the `ffi_type` instance for type: Object
    at Type (/Users/lgitzing/Development/work/node-ffi/lib/type.js:125:3)
    at CIF (/Users/lgitzing/Development/work/node-ffi/lib/cif.js:41:19)
    at ForeignFunction (/Users/lgitzing/Development/work/node-ffi/lib/foreign_function.js:33:13)
    at /Users/lgitzing/Development/work/node-ffi/lib/library.js:68:16
    at Array.forEach (<anonymous>)
    at new Library (/Users/lgitzing/Development/work/node-ffi/lib/library.js:47:28)
    at Object.<anonymous> (/Users/lgitzing/Development/work/frida-libclang/lib/dynamic_clang.js:951:20)
    at Module._compile (internal/modules/cjs/loader.js:678:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
    at Module.load (internal/modules/cjs/loader.js:589:32)

Can you help me with that ? Thnx in advance

mrmacete commented 6 years ago

i think that's because this module is supposed to be included in a node project already using Frida, did you take a look at the example folder and try to npm install there?