Metasploit 설치 과정 중 발생할 수 있는 문제에 대한 해결방법입니다. 이번 글에서는 git 을 이용하여 clone 후 bundler 를 통한 ruby package 설치 과정 중 발생하는 에러에 대해서 처리하는 방법으로 작성하였습니다.
1. PG, pq 관련 에러 시 처리(PG or PQ Error)
Error log /usr/bin/ruby2.1 extconf.rb checking for pg_config… no No pg_config… trying anyway. If building fails, please try again with –with-pg-config=/path/to/pg_config checking for libpq-fe.h… no Can’t find the ‘libpq-fe.h header ** 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.
처리방법
apt-get install ruby-pg libpq5 libpq-dev
2. SQLite3 관련 에러 시 처리(SQLite3 Error)
Error log Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.1 extconf.rb checking for sqlite3.h... no sqlite3.h is missing. Try 'port install sqlite3 +universal', 'yum install sqlite-devel' or 'apt-get install libsqlite3-dev' and check your shared library search path (the location where your sqlite3 shared library is located). *** 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.
apt-get install libsqlite3-dev
3. Pcap 관련 에러 시 처리(Pcap Error)
Error log
Gem files will remain installed in /var/lib/gems/2.1.0/gems/pcaprub-0.12.0 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/pcaprub-0.12.0/gem_make.out
An error occurred while installing pcaprub (0.12.0), and Bundler cannot continue.
Make sure that gem install pcaprub -v '0.12.0'
succeeds before bundling.
apt-get install ruby-pcaprub
apt-get install libpcap0.8 libpcap0.8-dev
Easy Install Script(Install Metasploit)
apt-get install ruby-dev libpcap0.8 libpcap0.8-dev ruby-pcaprub libsqlite3-dev ruby-pg libpq5 libpq-dev
bundler install
대체로 에러는 에러메시지에 해답이 있습니다. 조금만 찾아보시면 해결 가능한 문제들이 많으니 에러를 처리하기 위한 검색 스킬을 강화하면 좋습니다.
※ 추가로 아래와 같이 ffi나 다른 패키지에서 오류가 나는 경우도 있습니다. ruby-dev 패키지가 안깔려 있을때 발생할 수 있으니 같이 설치해주시면 될 것 같습니다./
apt-get install ruby-dev
Error log Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/ffi-1.9.14/ext/ffi_c /usr/bin/ruby2.3 -r ./siteconf20161122-4849-2yy977.rb extconf.rb mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/ffi-1.9.14 for inspection. Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.14/gem_make.out
An error occurred while installing ffi (1.9.14), and Bundler cannot continue.
Make sure that gem install ffi -v '1.9.14'
succeeds before bundling.