PDA

View Full Version : Metasploit & Oracle (ruby-oci8) not working together



deadl0ck
2015-05-19, 11:09
Hello Kali-Community,

After searching the web for a couple of days and following half a dozend different instructions without success, I'm hoping that you can help me to get metasploit working with oracle instant client.

Current Situation:


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


When I run the 'gem install ruby-oci8' I get the following:


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

And that's basically where I'm stuck.

As you can see, I extracted the latest instantclient files from Oracle (basic-linux / sdk / sqlplus in version 12.1.0.2) togehter with ruby-oci8-2.1.8.tar.gz to /opt/oracle/instantclient_12_1.

LD_LIBRARY_PATH, TNS_ADMIN, SQLPATH, ORACLE_HOME are set and PAHT has been extended to /opt/oracle/instantclient_12_1.

Many thanks in advance!

Any ideas would be highly welcome!

g0tmi1k
2015-05-26, 08:32
In short - its not easy.

Kali 1.x is based on Debian 7, which uses Ruby 1.9.x
Kali 2.x will be based on Debian 8, which uses Ruby 2.x

Metasploit v4.10+ (I think) made the switch to ruby 2.x.
To make sure metasploit will work with Kali - they have added in a 'custom environment/wrapper' of sorts to use their own version of ruby (v2), rather than the OSs (v1.9).

Edit:
Solution: https://github.com/rapid7/metasploit-framework/wiki/How-to-get-Oracle-Support-working-with-Kali-Linux

deadl0ck
2015-06-02, 11:55
Many thanks g0tmi1k!

Your solution works great!

grantc
2016-05-02, 22:19
In short - its not easy.

Kali 1.x is based on Debian 7, which uses Ruby 1.9.x
Kali 2.x will be based on Debian 8, which uses Ruby 2.x

Metasploit v4.10+ (I think) made the switch to ruby 2.x.
To make sure metasploit will work with Kali - they have added in a 'custom environment/wrapper' of sorts to use their own version of ruby (v2), rather than the OSs (v1.9).

Edit:
Solution: https://github.com/rapid7/metasploit-framework/wiki/How-to-get-Oracle-Support-working-with-Kali-Linux

I trekked through this solution and unfortunately, I no longer receive an error, but modules just hang indefinitely. I tried running auxiliary/admin/oracle/oracle_login and while it no longer throws an error, it just hangs after saying, "Starting brute force on <IP>...

Has anyone else run into this and solved it?