svent / jsdetox

A Javascript malware analysis tool
https://svent.dev/projects/jsdetox/
591 stars 79 forks source link

Dependency error #19

Closed DigiAngel closed 8 years ago

DigiAngel commented 9 years ago

Topic says it:

Installing therubyracer 0.9.8 with native extensions

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/ruby1.9.1
extconf.rb:15:in `<main>': undefined method `include_path' for Libv8:Module (NoMethodError)

Gem files will remain installed in /var/lib/gems/1.9.1/gems/therubyracer-0.9.8 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/therubyracer-0.9.8/ext/v8/gem_make.out
An error occurred while installing therubyracer (0.9.8), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.9.8'` succeeds before bundling.

mkmf.log contains the below:

have_library: checking for main() in -lpthread... -------------------- yes

"gcc -o conftest -I/usr/include/ruby-1.9.1/x86_64-linux -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -D_FORTIFY_SOURCE=2  -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -fno-strict-aliasing -fPIC conftest.c  -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/buildd/ruby1.9.1-1.9.3.484/debian/lib -rdynamic -Wl,-export-dynamic     -lruby-1.9.1  -lpthread -lrt -ldl -lcrypt -lm   -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"gcc -o conftest -I/usr/include/ruby-1.9.1/x86_64-linux -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -D_FORTIFY_SOURCE=2  -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -fno-strict-aliasing -fPIC conftest.c  -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/buildd/ruby1.9.1-1.9.3.484/debian/lib -rdynamic -Wl,-export-dynamic     -lruby-1.9.1 -lpthread  -lpthread -lrt -ldl -lcrypt -lm   -lc"
conftest.c: In function âtâ:
conftest.c:4:53: error: âmainâ undeclared (first use in this function)
 int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
                                                     ^
conftest.c:4:53: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:4:28: warning: variable âpâ set but not used [-Wunused-but-set-variable]
 int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
                            ^
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     printf("%p", &t);
 9:   }
10:
11:   return 0;
12: }
/* end */

"gcc -o conftest -I/usr/include/ruby-1.9.1/x86_64-linux -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -D_FORTIFY_SOURCE=2  -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -fno-strict-aliasing -fPIC conftest.c  -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/buildd/ruby1.9.1-1.9.3.484/debian/lib -rdynamic -Wl,-export-dynamic     -lruby-1.9.1 -lpthread  -lpthread -lrt -ldl -lcrypt -lm   -lc"
conftest.c: In function âtâ:
conftest.c:4:1: warning: implicit declaration of function âmainâ [-Wimplicit-function-declaration]
 int t() { main(); return 0; }
 ^
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: /*top*/
 4: int t() { main(); return 0; }
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     printf("%p", &t);
 9:   }
10:
11:   return 0;
12: }
/* end */

--------------------

This is on ubuntu 14.04 64-bit set up with SIFT and REMnux. What other information can I provide? Thank you

svent commented 9 years ago

It seems that the ruby gem 'therubyracer' has a problem with an already installed version of the gem 'libv8'. I cannot reproduce this problem right now, but removing libv8 and reinstalling therubyracer might solve to problem:

$ gem uninstall libv8
$ gem install therubyracer

Please note that this might have side effects on other programs depending on a specific version of libv8.

Sources: https://github.com/cowboyd/therubyracer/issues/166 http://stackoverflow.com/questions/14893272/an-error-occurred-while-installing-therubyracer-0-10-1

DigiAngel commented 9 years ago

Thanks for looking at this. Here's what I have: /var/lib/gems/1.9.1/gems/libv8-3.16.14.7-x86_64-linux /var/lib/gems/1.9.1/gems/libv8-3.3.10.4-x86_64-linux

To be honest I'm not sure if SIFT or Remnux installed this. In either case I will give the remove and install a go...thank you.

ccakgunduz commented 8 years ago

When I trying to bundle install it gives the same error. I'm trying to install it on Kali 2.0.

I follow the steps you mention above, unisntall libv8 and then install therubyracer but it still gives an error.

Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies......
Using rake 10.5.0
Using i18n 0.7.0
Using multi_json 1.11.2
Using bundler 1.11.2
Using haml 3.1.8
Using hexdump 0.2.3
Using rack 1.6.4
Using json 1.8.3
Installing libv8 3.3.10.4
Using mime-types 1.25.1
Using polyglot 0.3.5
Using mini_portile2 2.0.0
Using tilt 1.3.7
Using thor 0.15.4
Using sass 3.4.21
Using activesupport 3.2.22.1
Using url_mount 0.2.1
Using rack-protection 1.5.3
Installing therubyracer 0.9.8 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/bin/ruby2.1 extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/ruby2.1
extconf.rb:15:in `<main>': undefined method `include_path' for Libv8:Module (NoMethodError)

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.1.0/gems/therubyracer-0.9.8 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/therubyracer-0.9.8/gem_make.out
Using treetop 1.4.15
Using nokogiri 1.6.7.2
Using http_router 0.10.2
Using sinatra 1.3.6
An error occurred while installing therubyracer (0.9.8), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.9.8'` succeeds before bundling.

This is first error. When I apply the steps and trying to execute jsdetox, it still says there is a missing gems.

./jsdetox
[JSDetox] Loading framework ... Could not find gem 'therubyracer (= 0.9.8) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.

How should I fix this?

svent commented 8 years ago

I tested this on Kali 2.0 and ran into the same problems. Unfortunately, this dependency hell is hard to solve. As jsdetox should be used in a virtual machine anyway, I would recommend to use an Ubuntu 14.04 LTS installation.

On Kali 2.0, you could try to replace the line gem 'therubyracer', '0.9.8' in the Gemfile with gem 'therubyracer'. That way bundle install should work, but the v8 integration (for executing and tracing javascript code) will be somehow broken.

ccakgunduz commented 8 years ago

Thanks for sparing time. I use it on Ubuntu as you said.