rapid7 / metasploit-framework

Metasploit Framework
https://www.metasploit.com/
Other
33.79k stars 13.9k forks source link

pg 1.4.6 not installing #17779

Closed cybertuxh4xor closed 1 year ago

cybertuxh4xor commented 1 year ago

Steps to reproduce

How'd you do it?

  1. by trying to run nasm_shell.rb
  2. ...

metasploit is installed to the /opt directory

Were you following a specific guide/tutorial or reading documentation?

N/A

Expected behavior

it should allow me to run the program without crashing

Current behavior

kali@kali:/opt/metasploit-framework/embedded/framework$ /opt/metasploit-framework/embedded/framework/tools/exploit/nasm_shell.rb        
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Could not find pg-1.4.6 in any of the sources
Run `bundle install` to install missing gems.

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /tmp/bundler20230315-15680-2jr2yupg-1.4.6/extensions/x86_64-linux/3.1.0/pg-1.4.6/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20230315-15680-2jr2yupg-1.4.6/gems/pg-1.4.6 for inspection.
Results logged to /tmp/bundler20230315-15680-2jr2yupg-1.4.6/extensions/x86_64-linux/3.1.0/pg-1.4.6/gem_make.out

An error occurred while installing pg (1.4.6), and Bundler cannot continue.
Make sure that `gem install pg -v '1.4.6' --source 'https://rubygems.org/'` succeeds before bundling.                                                                                                                                       

In Gemfile:
  metasploit-framework was resolved to 6.3.7, which depends on
    metasploit-credential was resolved to 6.0.2, which depends on
      metasploit_data_models was resolved to 6.0.2, which depends on
        pg

kali@kali:/opt/metasploit-framework/embedded/framework$ cat /tmp/bundler20230315-15680-2jr2yupg-1.4.6/extensions/x86_64-linux/3.1.0/pg-1.4.6/mkmf.log
cat: /tmp/bundler20230315-15680-2jr2yupg-1.4.6/extensions/x86_64-linux/3.1.0/pg-1.4.6/mkmf.log: No such file or directory

Metasploit version

Framework Version: 6.3.8-dev-

gwillcox-r7 commented 1 year ago

@cybertuxh4xor Have you tried to run bundle install or done gem install pg -v '1.4.6' --source 'https://rubygems.org/' as was mentioned as potential solutions in the error logs? What was the output? Can you show us said output?

Note that nasm_shell.rb will not install pg for you if it is missing.

cybertuxh4xor commented 1 year ago

that is the said output, i ran both,

kali@kali:/opt/metasploit-framework/embedded/framework$ bundle install
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Fetching gem metadata from https://rubygems.org/.........
Using rake 13.0.6                                                                                                                                                                                                                           
Following files may not be writable, so sudo is needed:                                                                                                                                                                                     
  /usr/local/bin                                                                                                                                                                                                                            
  /var/lib/gems/3.1.0                                                                                                                                                                                                                       
  /var/lib/gems/3.1.0/build_info                                                                                                                                                                                                            
  /var/lib/gems/3.1.0/cache                                                                                                                                                                                                                 
  /var/lib/gems/3.1.0/doc                                                                                                                                                                                                                   
  /var/lib/gems/3.1.0/extensions                                                                                                                                                                                                            
  /var/lib/gems/3.1.0/gems                                                                                                                                                                                                                  
  /var/lib/gems/3.1.0/plugins                                                                                                                                                                                                               
  /var/lib/gems/3.1.0/specifications                                                                                                                                                                                                        
Using Ascii85 1.1.0                                                                                                                                                                                                                         
Using concurrent-ruby 1.2.2                                                                                                                                                                                                                 
Using i18n 1.12.0                                                                                                                                                                                                                           
Using minitest 5.18.0                                                                                                                                                                                                                       
Using tzinfo 2.0.6                                                                                                                                                                                                                          
Using activesupport 7.0.4.2                                                                                                                                                                                                                 
Using builder 3.2.4                                                                                                                                                                                                                         
Using erubi 1.12.0                                                                                                                                                                                                                          
Using mini_portile2 2.8.1                                                                                                                                                                                                                   
Using racc 1.6.2                                                                                                                                                                                                                            
Using nokogiri 1.14.2 (x86_64-linux)                                                                                                                                                                                                        
Using rails-dom-testing 2.0.3                                                                                                                                                                                                               
Using crass 1.0.6                                                                                                                                                                                                                           
Using loofah 2.19.1                                                                                                                                                                                                                         
Using rails-html-sanitizer 1.5.0
Using actionview 7.0.4.2
Using rack 2.2.6.3
Using rack-test 2.0.2
Using actionpack 7.0.4.2
Using activemodel 7.0.4.2
Using activerecord 7.0.4.2
Using public_suffix 5.0.1
Using addressable 2.8.1
Using afm 0.2.2
Using arel-helpers 2.14.0
Using ast 2.4.2
Using aws-eventstream 1.2.0
Using aws-partitions 1.722.0
Using aws-sigv4 1.5.2
Using jmespath 1.6.2
Using aws-sdk-core 3.170.0
Using aws-sdk-ec2 1.368.0
Using aws-sdk-iam 1.75.0
Using aws-sdk-kms 1.63.0
Using aws-sdk-s3 1.119.1
Using bcrypt 3.1.18
Using bcrypt_pbkdf 1.1.0
Using bindata 2.4.15
Using bson 4.15.0
Using bundler 2.1.4
Using byebug 11.1.3
Using chunky_png 1.4.0
Using coderay 1.1.3
Using cookiejar 0.3.3
Using daemons 1.4.1
Using io-console 0.6.0
Using reline 0.3.2
Using irb 1.6.3
Using debug 1.7.1
Using diff-lcs 1.5.0
Using unf_ext 0.0.8.2
Using unf 0.1.4
Using simpleidn 0.2.1
Using dnsruby 1.61.9
Using docile 1.4.0
Using domain_name 0.5.20190701
Using ed25519 1.3.0
Using eventmachine 1.2.7
Using em-socksify 0.3.2
Using http_parser.rb 0.8.0
Using em-http-request 1.1.7
Using factory_bot 6.2.1
Using method_source 1.0.0
Using thor 1.2.1
Using zeitwerk 2.6.7
Using railties 7.0.4.2
Using factory_bot_rails 6.2.0
Using faker 3.1.1
Using faraday-net_http 3.0.2
Using ruby2_keywords 0.0.5
Using faraday 2.7.4
Using faraday-retry 2.1.0
Using websocket-extensions 0.1.5
Using websocket-driver 0.7.5
Using faye-websocket 0.11.1
Using ffi 1.15.5
Using filesize 0.2.0
Using fivemat 1.3.7
Using gssapi 1.3.1
Using rexml 3.2.5
Using gyoku 1.4.0
Using hashery 2.1.2
Using hrr_rb_ssh 0.4.2
Using hrr_rb_ssh-ed25519 0.4.2
Using http-cookie 1.0.5
Using httpclient 2.8.3
Using rkelly-remix 0.0.7
Using jsobfu 0.4.2
Using json 2.6.3
Using little-plugger 1.1.4
Using multi_json 1.15.0
Using logging 2.3.1
Using memory_profiler 1.0.1
Using metasm 1.0.5
Using metasploit-concern 5.0.1
Using metasploit-model 5.0.1
Fetching pg 1.4.6

Your user account isn't allowed to install to the system RubyGems.
  You can cancel this installation and run:

      bundle install --path vendor/bundle

  to install the gems into ./vendor/bundle/, or you can enter your password
  and install the bundled gems to RubyGems using sudo.

  Password: 

Your user account isn't allowed to install to the system RubyGems.
  You can cancel this installation and run:

      bundle install --path vendor/bundle

  to install the gems into ./vendor/bundle/, or you can enter your password
  and install the bundled gems to RubyGems using sudo.

  Password: 
Installing pg 1.4.6 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /tmp/bundler20230315-123126-4eupiepg-1.4.6/gems/pg-1.4.6/ext
/usr/bin/ruby3.1 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20230315-123126-k94me7.rb extconf.rb
Calling libpq with GVL unlocked
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for whether -Wl,-rpath,/usr/lib/x86_64-linux-gnu is accepted as LDFLAGS... yes
Using libpq from /usr/lib/x86_64-linux-gnu
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*****************************************************************************

Unable to find PostgreSQL client library.

Please install libpq or postgresql client package like so:
  sudo apt install libpq-dev
  sudo yum install postgresql-devel
  sudo zypper in postgresql-devel
  sudo pacman -S postgresql-libs

or try again with:
  gem install pg -- --with-pg-config=/path/to/pg_config

or set library paths manually with:
  gem install pg -- --with-pg-include=/path/to/libpq-fe.h/ --with-pg-lib=/path/to/libpq.so/

*** 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/$(RUBY_BASE_NAME)3.1
        --with-pg
        --without-pg
        --enable-gvl-unlock
        --disable-gvl-unlock
        --enable-windows-cross
        --disable-windows-cross
        --with-pg-config
        --without-pg-config
        --with-pg_config
        --without-pg_config
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /tmp/bundler20230315-123126-4eupiepg-1.4.6/extensions/x86_64-linux/3.1.0/pg-1.4.6/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20230315-123126-4eupiepg-1.4.6/gems/pg-1.4.6 for inspection.
Results logged to /tmp/bundler20230315-123126-4eupiepg-1.4.6/extensions/x86_64-linux/3.1.0/pg-1.4.6/gem_make.out

An error occurred while installing pg (1.4.6), and Bundler cannot continue.
Make sure that `gem install pg -v '1.4.6' --source 'https://rubygems.org/'` succeeds before bundling.                                                                                                                                       

In Gemfile:
  metasploit-framework was resolved to 6.3.8, which depends on
    metasploit-credential was resolved to 6.0.2, which depends on
      metasploit_data_models was resolved to 6.0.2, which depends on
        pg

kali@kali:/opt/metasploit-framework/embedded/framework$ gem install pg -v '1.4.6' --source 'https://rubygems.org/'
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/3.1.0 directory.

kali@kali:/opt/metasploit-framework/embedded/framework$ sudo gem install pg -v '1.4.6' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/3.1.0/gems/pg-1.4.6/ext
/usr/bin/ruby3.1 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20230315-123699-rck9p6.rb extconf.rb
Calling libpq with GVL unlocked
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for whether -Wl,-rpath,/usr/lib/x86_64-linux-gnu is accepted as LDFLAGS... yes
Using libpq from /usr/lib/x86_64-linux-gnu
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*****************************************************************************

Unable to find PostgreSQL client library.

Please install libpq or postgresql client package like so:
  sudo apt install libpq-dev
  sudo yum install postgresql-devel
  sudo zypper in postgresql-devel
  sudo pacman -S postgresql-libs

or try again with:
  gem install pg -- --with-pg-config=/path/to/pg_config

or set library paths manually with:
  gem install pg -- --with-pg-include=/path/to/libpq-fe.h/ --with-pg-lib=/path/to/libpq.so/

*** 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/$(RUBY_BASE_NAME)3.1
        --with-pg
        --without-pg
        --enable-gvl-unlock
        --disable-gvl-unlock
        --enable-windows-cross
        --disable-windows-cross
        --with-pg-config
        --without-pg-config
        --with-pg_config
        --without-pg_config
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/lib/gems/3.1.0/extensions/x86_64-linux/3.1.0/pg-1.4.6/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/3.1.0/gems/pg-1.4.6 for inspection.
Results logged to /var/lib/gems/3.1.0/extensions/x86_64-linux/3.1.0/pg-1.4.6/gem_make.out

kali@kali:/opt/metasploit-framework/embedded/framework$ 
gwillcox-r7 commented 1 year ago

My guess is that you are mixing both sudo'd parts of your Ruby install with non-sudo'd parts. Generally speaking you shouldn't need to sudo to install Ruby otherwise you can run into odd errors like this one due to root having one setup of Ruby and your current user having a separate setup.

It may be an idea to remove your existing Ruby installation and try reinstall as a non-root user; your current install seems to have been potentially messed up as a result of this.

Alternatively try run sudo /opt/metasploit-framework/embedded/framework/tools/exploit/nasm_shell.rb and that might work since you are now using root's version of Ruby and its setup vs your normal user which seems to be broken.

I'd still recommend reinstalling Ruby as a non-root user though to prevent future issues like this one.

bcoles commented 1 year ago

Have you installed libpq-dev PostgreSQL dev library?

sudo apt install libpq-dev
cybertuxh4xor commented 1 year ago

That took care of it

Sent from Proton Mail for iOS

On Sat, Mar 18, 2023 at 10:11 PM, bcoles @.***> wrote:

Have you installed libpq-dev PostgreSQL dev library?

sudo apt install libpq-dev

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

SurajSharma52 commented 1 year ago

Sir i followed all your instructions but still it show error

(surajsharma㉿windows)-[~/metasploit-framework/tools/exploit] └─$ sudo /home/surajsharma/metasploit-framework/tools/exploit/nasm_shell.rb Calling DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please callDidYouMean.correct_error(error_name, spell_checker)' instead. Could not find pg-1.5.3 in any of the sources Run bundle install to install missing gems.

(surajsharma㉿windows)-[~/metasploit-framework] └─$ bundle install Calling DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please callDidYouMean.correct_error(error_name, spell_checker)' instead. fatal: detected dubious ownership in repository at '/home/surajsharma/metasploit-framework' To add an exception for this directory, call:

    git config --global --add safe.directory /home/surajsharma/metasploit-framework

Fetching gem metadata from https://rubygems.org/......... Using rake 13.0.6 Following files may not be writable, so sudo is needed: /usr/local/bin
/var/lib/gems/3.1.0
/var/lib/gems/3.1.0/build_info
/var/lib/gems/3.1.0/cache
/var/lib/gems/3.1.0/doc
/var/lib/gems/3.1.0/extensions
/var/lib/gems/3.1.0/gems
/var/lib/gems/3.1.0/plugins
/var/lib/gems/3.1.0/specifications
Using Ascii85 1.1.0 Using concurrent-ruby 1.2.2 Using i18n 1.14.1 Using minitest 5.18.0 Using tzinfo 2.0.6 Using activesupport 7.0.5 Using builder 3.2.4 Using erubi 1.12.0 Using mini_portile2 2.8.2 Using racc 1.7.0 Using nokogiri 1.14.5 (x86_64-linux) Using rails-dom-testing 2.0.3 Using crass 1.0.6 Using loofah 2.21.3 Using rails-html-sanitizer 1.6.0 Using actionview 7.0.5 Using rack 2.2.7 Using rack-test 2.1.0 Using actionpack 7.0.5 Using activemodel 7.0.5 Using activerecord 7.0.5 Using public_suffix 5.0.1 Using addressable 2.8.4 Using afm 0.2.2 Using arel-helpers 2.14.0 Using ast 2.4.2 Using aws-eventstream 1.2.0 Using aws-partitions 1.776.0 Using aws-sigv4 1.5.2 Using jmespath 1.6.2 Using aws-sdk-core 3.174.0 Using aws-sdk-ec2 1.382.0 Using aws-sdk-iam 1.79.0 Using aws-sdk-kms 1.66.0 Using aws-sdk-s3 1.123.1 Using aws-sdk-ssm 1.151.0 Using bcrypt 3.1.18 Using bcrypt_pbkdf 1.1.0 Using bindata 2.4.15 Using msgpack 1.6.1 Using bootsnap 1.16.0 Using bson 4.15.0 Using bundler 2.1.4 Using byebug 11.1.3 Using chunky_png 1.4.0 Using coderay 1.1.3 Using cookiejar 0.3.3 Using daemons 1.4.1 Using io-console 0.6.0 Using reline 0.3.5 Using irb 1.7.0 Using debug 1.8.0 Using diff-lcs 1.5.0 Using unf_ext 0.0.8.2 Using unf 0.1.4 Using simpleidn 0.2.1 Using dnsruby 1.70.0 Using docile 1.4.0 Using domain_name 0.5.20190701 Using ed25519 1.3.0 Using eventmachine 1.2.7 Using em-socksify 0.3.2 Using http_parser.rb 0.8.0 Using em-http-request 1.1.7 Using factory_bot 6.2.1 Using method_source 1.0.0 Using thor 1.2.2 Using zeitwerk 2.6.8 Using railties 7.0.5 Using factory_bot_rails 6.2.0 Using faker 3.2.0 Using faraday-net_http 3.0.2 Using ruby2_keywords 0.0.5 Using faraday 2.7.6 Using faraday-retry 2.2.0 Using websocket-extensions 0.1.5 Using websocket-driver 0.7.5 Using faye-websocket 0.11.2 Using ffi 1.15.5 Using filesize 0.2.0 Using fivemat 1.3.7 Using gssapi 1.3.1 Using rexml 3.2.5 Using gyoku 1.4.0 Using hashery 2.1.2 Using hrr_rb_ssh 0.4.2 Using hrr_rb_ssh-ed25519 0.4.2 Using http-cookie 1.0.5 Using httpclient 2.8.3 Using rkelly-remix 0.0.7 Using jsobfu 0.4.2 Using json 2.6.3 Using little-plugger 1.1.4 Using multi_json 1.15.0 Using logging 2.3.1 Using memory_profiler 1.0.1 Using metasm 1.0.5 Using metasploit-concern 5.0.1 Using metasploit-model 5.0.1 Fetching pg 1.5.3

Your user account isn't allowed to install to the system RubyGems. You can cancel this installation and run:

  bundle install --path vendor/bundle

to install the gems into ./vendor/bundle/, or you can enter your password and install the bundled gems to RubyGems using sudo.

Password:

Your user account isn't allowed to install to the system RubyGems. You can cancel this installation and run:

  bundle install --path vendor/bundle

to install the gems into ./vendor/bundle/, or you can enter your password and install the bundled gems to RubyGems using sudo.

Password: Installing pg 1.5.3 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /tmp/bundler20230702-4171-ydks62pg-1.5.3/gems/pg-1.5.3/ext

/usr/bin/ruby3.1 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20230702-4171-53e53q.rb extconf.rb Calling libpq with GVL unlocked checking for pg_config... yes Using config values from /usr/bin/pg_config checking for whether -Wl,-rpath,/usr/lib/x86_64-linux-gnu is accepted as LDFLAGS... yes Using libpq from /usr/lib/x86_64-linux-gnu checking for libpq-fe.h... no Can't find the 'libpq-fe.h header


Unable to find PostgreSQL client library.

Please install libpq or postgresql client package like so: sudo apt install libpq-dev sudo yum install postgresql-devel sudo zypper in postgresql-devel sudo pacman -S postgresql-libs

or try again with: gem install pg -- --with-pg-config=/path/to/pg_config

or set library paths manually with: gem install pg -- --with-pg-include=/path/to/libpq-fe.h/ --with-pg-lib=/path/to/libpq.so/

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/$(RUBY_BASE_NAME)3.1 --with-pg --without-pg --enable-gvl-unlock --disable-gvl-unlock --enable-windows-cross --disable-windows-cross --with-pg-config --without-pg-config --with-pg_config --without-pg_config --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/tmp/bundler20230702-4171-ydks62pg-1.5.3/extensions/x86_64-linux/3.1.0/pg-1.5.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20230702-4171-ydks62pg-1.5.3/gems/pg-1.5.3 for inspection. Results logged to /tmp/bundler20230702-4171-ydks62pg-1.5.3/extensions/x86_64-linux/3.1.0/pg-1.5.3/gem_make.out

An error occurred while installing pg (1.5.3), and Bundler cannot continue. Make sure that gem install pg -v '1.5.3' --source 'https://rubygems.org/' succeeds before bundling.

In Gemfile: metasploit-framework was resolved to 6.3.24, which depends on metasploit-credential was resolved to 6.0.5, which depends on metasploit_data_models was resolved to 6.0.2, which depends on pg

bcoles commented 1 year ago

Sir i followed all your instructions but still it show error

Refer to the error message:

checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header

Unable to find PostgreSQL client library.

Please install libpq or postgresql client package like so:
sudo apt install libpq-dev
sudo yum install postgresql-devel
sudo zypper in postgresql-devel
sudo pacman -S postgresql-libs
SurajSharma52 commented 1 year ago

ok thank you sir, it works