Metasploit-framework: Metasploit & Oracle (ruby-oci8) not working together

Created on 27 May 2015  路  17Comments  路  Source: rapid7/metasploit-framework

msf > use auxiliary/admin/oracle/oracle_login
msf auxiliary(oracle_login) > set rhost 127.0.0.1
rhost => 127.0.0.1
msf auxiliary(oracle_login) > run

[-] Failed to load the OCI library: cannot load such file -- oci8
[-] Try 'gem install ruby-oci8'[*] Auxiliary module execution completed
msf auxiliary(oracle_login) > gem install ruby-oci8[*] exec: gem install ruby-oci8

Building native extensions.  This could take a while...
ERROR:  Error installing ruby-oci8:
        ERROR: Failed to build gem native extension.

    /opt/metasploit/ruby/bin/ruby extconf.rb
checking for load library path...
  LD_LIBRARY_PATH...
    checking /opt/metasploit/ruby/lib... no
    checking /opt/oracle/instantclient_12_1... yes
  /opt/oracle/instantclient_12_1/libclntsh.so.12.1 looks like an instant client.
checking for cc... *** 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=/opt/metasploit/ruby/bin/ruby
        --with-instant-client
        --without-instant-client
/opt/metasploit/ruby/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': RuntimeError (RuntimeError)
        from /opt/metasploit/ruby/lib/ruby/2.1.0/mkmf.rb:541:in `try_link0'
        from /opt/metasploit/ruby/lib/ruby/2.1.0/mkmf.rb:834:in `try_run'
        from /opt/metasploit/apps/pro/vendor/bundle/ruby/2.1.0/gems/ruby-oci8-2.1.8/ext/oci8/oraconf.rb:566:in `check_cc'
        from /opt/metasploit/apps/pro/vendor/bundle/ruby/2.1.0/gems/ruby-oci8-2.1.8/ext/oci8/oraconf.rb:556:in `init'
        from /opt/metasploit/apps/pro/vendor/bundle/ruby/2.1.0/gems/ruby-oci8-2.1.8/ext/oci8/oraconf.rb:933:in `initialize'
        from /opt/metasploit/apps/pro/vendor/bundle/ruby/2.1.0/gems/ruby-oci8-2.1.8/ext/oci8/oraconf.rb:318:in `new'
        from /opt/metasploit/apps/pro/vendor/bundle/ruby/2.1.0/gems/ruby-oci8-2.1.8/ext/oci8/oraconf.rb:318:in `get'
        from extconf.rb:18:in `<main>'
---------------------------------------------------
Error Message:
  The compiler failed to generate an executable file.
  You have to install development tools first.

Backtrace:
  /opt/metasploit/ruby/lib/ruby/2.1.0/mkmf.rb:456:in `try_do'
  /opt/metasploit/ruby/lib/ruby/2.1.0/mkmf.rb:541:in `try_link0'
  /opt/metasploit/ruby/lib/ruby/2.1.0/mkmf.rb:834:in `try_run'
  /opt/metasploit/apps/pro/vendor/bundle/ruby/2.1.0/gems/ruby-oci8-2.1.8/ext/oci8/oraconf.rb:566:in `check_cc'
  /opt/metasploit/apps/pro/vendor/bundle/ruby/2.1.0/gems/ruby-oci8-2.1.8/ext/oci8/oraconf.rb:556:in `init'
  /opt/metasploit/apps/pro/vendor/bundle/ruby/2.1.0/gems/ruby-oci8-2.1.8/ext/oci8/oraconf.rb:933:in `initialize'
  /opt/metasploit/apps/pro/vendor/bundle/ruby/2.1.0/gems/ruby-oci8-2.1.8/ext/oci8/oraconf.rb:318:in `new'
  /opt/metasploit/apps/pro/vendor/bundle/ruby/2.1.0/gems/ruby-oci8-2.1.8/ext/oci8/oraconf.rb:318:in `get'
  extconf.rb:18:in `<main>'
---------------------------------------------------
See:
 * http://rubydoc.info/gems/ruby-oci8/file/docs/install-full-client.md for Oracle full client
 * http://rubydoc.info/gems/ruby-oci8/file/docs/install-instant-client.md for Oracle instant client
 * http://ruby-oci8.rubyforge.org/en/file.report-installation-issue.html to report an issue.


extconf failed, exit code 1

Gem files will remain installed in /opt/metasploit/apps/pro/vendor/bundle/ruby/2.1.0/gems/ruby-oci8-2.1.8 for inspection.
Results logged to /opt/metasploit/apps/pro/vendor/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0/ruby-oci8-2.1.8/gem_make.out

The compiler failed to generate an executable file.
You have to install development tools first.

new install of kali 1.1.0a x64

All 17 comments

This message appears to give a clue:

Error Message:
  The compiler failed to generate an executable file.
  You have to install development tools first.

Did you try installing a C compiler first? 'apt-get install build-essential' might be enough. There may be other development packages you need as well, e.g. https://github.com/rapid7/metasploit-framework/wiki/Setting-Up-a-Metasploit-Development-Environment#tldr-as-msfdev

@bcook-r7 The ruby oci-8 need oracle client and sqlplus* in order to compile successfully. This unfortunately can't be resolved natively by the gem. The ruby gem is only a wrapper around the binary oracle clients.The solution to resolve the above issue can be found at http://leonjza.github.io/blog/2014/08/17/kali-linux-oracle-support/. I have tested it and the workaround works without any problem.

@bcook-r7

already told you clean kali install
kali x64 comes with gcc already installed

im not the only one
https://forums.kali.org/showthread.php?25542-Metasploit-amp-Oracle-(ruby-oci8)-not-working-together

@after100 Follow the steps mentioned in the link in my previous response.

I also have the same problem. I am dealing with this issue for a week and I couldn't find a single solution that works. I am using kali 1.1.0a x86 and metasploit v4.11.1. @void-in the solution is provided in the link doesn't work for me. I am still getting same error messages.

@softwarerat and @after100 As per the policy, these pages are not for troubleshooting. Your issue is not a bug but rather a design limitation of the ruby gem. Please post your issue at https://community.rapid7.com and will resolve it there.

@void-in
kali is flag ship os. kali is official support
shouldnt have to do manual installs of gems

if for whatever reason have to do manual install of gem (no distribute of oracle files) the guide that i should follow should come from rapid7 official page and linked into the error message. yea its a bug/issue and not me troubleshooting

[-] Failed to load the OCI library: cannot load such file -- oci8
[-] follow our guide: http://rapid7.com/documation/ruby-oci8..................

not some blog post thats dated and doesnt work with ruby 2

@void-in
i hav gcc + gem + oracle installed in kali and msf doesnt detect so it is bug

The issue is simply a missing default package on Kali Linux. Here are the steps I followed.

1.) Follow the steps on the blog post at http://leonjza.github.io/blog/2014/08/17/kali-linux-oracle-support/ until you get to the 'make' step.
2.) Before running 'make', run 'export PATH=/opt/metasploit/ruby/bin:$PATH' so that Metasploit's ruby interpreter is in the PATH before Kali Linux's 1.9 version. This blog post was written before we had to package a newer Ruby interpreter than Kali Linux provides by default.
3.) Verify you have the correct version of ruby in the path:

# ruby -v
ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-linux-gnu]

4.) at this point, if you run 'make', you will get an error as indicated at the top of this issue report. Note that it says 'Check the mkmf.log file for more details'. Check that, and note the contents:

# cat ./ext/oci8/mkmf.log
"gcc -o conftest -I/opt/metasploit/ruby/include/ruby-2.1.0/x86_64-linux-gnu -I/opt/metasploit/ruby/include/ruby-2.1.0/ruby/backward -I/opt/metasploit/ruby/include/ruby-2.1.0 -I/root/ruby-oci8-ruby-oci8-2.1.7/ext/oci8    -g -O2 -fPIC conftest.c  -L. -L/opt/metasploit/ruby/lib -Wl,-R/opt/metasploit/ruby/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic     -Wl,-R -Wl,/opt/metasploit/ruby/lib -L/opt/metasploit/ruby/lib -lruby  -lpthread -lrt -lgmp -ldl -lcrypt -lm   -lc"
/usr/bin/ld: cannot find -lgmp
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

It is saying that a library is missing from Kali linux called 'gmp'.
5.) Let's install that missing library and its headers:

apt-get install libgmp-dev

6.) Run 'make / make install' as normal.

To summarize, the two missing steps from the blog post before running 'make' are:

export PATH=/opt/metasploit/ruby/bin:$PATH
apt-get install libgmp-dev

this should b documented on the official site so its not forgotten and lost
people should be able to find this easy and linked to in the framework rather than just closed

I'd love to put up a blog post about it, but now is probably not a good time for getting a permanent link. I added something to the metasploit-framework wiki for now. https://github.com/rapid7/metasploit-framework/wiki/How-to-get-Oracle-Support-working-with-Kali-Linux

@bcook-r7 Will update the blogpost too for completeness sake.

fantasic, thanks @leonjza (and let me know if I left anything out)

Sorry for pinging an old issue. @bcook-r7 Finally got round to updating the post. FWIW, it still works with your amendments as of today too.

@bcook-r7 The ruby oci-8 need oracle client and sqlplus* in order to compile successfully. This unfortunately can't be resolved natively by the gem. The ruby gem is only a wrapper around the binary oracle clients.The solution to resolve the above issue can be found at http://leonjza.github.io/blog/2014/08/17/kali-linux-oracle-support/. I have tested it and the workaround works without any problem.

Still needed, after almost 5 years... but also "still works" :-)

For the record, the step by step instructions are in the wiki as well, I've run through them twice on fresh systems and gotten this working

5 years haha. Im impressed by that post's mileage ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adrianmihalko picture adrianmihalko  路  3Comments

XSecr3t picture XSecr3t  路  3Comments

fluit105 picture fluit105  路  3Comments

notdodo picture notdodo  路  3Comments

jecoliho picture jecoliho  路  3Comments