kali下的Metasploit升级更新至5.0.62

apt-get remove metasploit-framework
apt-get install metasploit-framework

但是会出现各种问题

重装失败,显示找不到需要的软件,更换source源后重新安装。

vim /etc/apt/sources.list
添加这两行(任选)

#中科大
deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
deb-src http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib

#阿里云
#deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
#deb-src http://mirrors.aliyun.com/kali kali-rolling main non-free contrib

#清华大学
#deb http://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
#deb-src https://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free

#浙大
#deb http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free
#deb-src http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free

#东软大学
#deb http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib
#deb-src http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib

#官方源
#deb http://http.kali.org/kali kali-rolling main non-free contrib
#deb-src http://http.kali.org/kali kali-rolling main non-free contrib

#重庆大学
#deb http://http.kali.org/kali kali-rolling main non-free contrib
#deb-src http://http.kali.org/kali kali-rolling main non-free contrib


apt-get update
apt-get install metasploit-framework

 

You must use Bundler 2 or greater with this lockfile.

这个错误的原因的bundler插件版本过低,可能是因为某些gem更新了,所以我们来安装更高版本的bundler插件,这样错误就解决了

gem update --system

bundler -v

gem install bundler -v2.0.2

Successfully installed bundler-2.0.2
NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::Specification#rubyforge_project= called from /usr/share/rubygems-integration/all/specifications/erubis-2.7.0.gemspec:16.
NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::Specification#rubyforge_project= called from /usr/share/rubygems-integration/all/specifications/multipart-post-1.2.0.gemspec:16.
/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:10: warning: constant Gem::ConfigMap is deprecated
Parsing documentation for bundler-2.0.2
Installing ri documentation for bundler-2.0.2
Done installing documentation for bundler after 4 seconds
1 gem installed

成功安装2.0.1版本的bundler后,可是执行msfconsole还是同样报错,这里得找Gemfile.lock的路径

复制代码

cd /usr/share/metasploit-framework/
bundler update
# 报错如下
Traceback (most recent call last):
    2: from /usr/local/bin/bundler:23:in `
' 1: from /usr/local/lib/site_ruby/2.5.0/rubygems.rb:308:in `activate_bin_path' /usr/local/lib/site_ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundler (Gem::GemNotFoundException)

复制代码

最后pcat经过一番摸索,发现最主要的是:安装的bundler版本需要大于等于Gemfile.lock中要求的版本

cd /usr/share/metasploit-framework/
cat Gemfile.lock | grep -A 1 "BUNDLED"

得到bundler的版本

BUNDLED WITH
   2.1.4
gem update --system
gem install bundler -v 2.1.4

查看源是否最新

gem sources -l

*** CURRENT SOURCES ***

https://rubygems.org/
https://gems.ruby-china.com

gem sources --remove https://gems.ruby-china.org/
gem sources -a https://gems.ruby-china.com

 往下面可能还有坑,这个是从网上找的,但是我放弃了。。。。我选了下载2020kaili,不这样玩了,忒累。。。。

 

 

-= UPDATE 2020.05.02 =-

有好友反映按照pcat上面的方法更新后,运行msfconsole还会报错:

/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:10: warning: constant Gem::ConfigMap is deprecated
/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:10: warning: constant Gem::ConfigMap is deprecated
Could not find json-2.3.0 in any of the sources
Run `bundle install` to install missing gems.

pcat经过测试后发现gem的版本最近更新得很高,为3.1.2,而且还带来很多warning。

# 例如
NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.

经搜索github上有一个做法是:

gem update --system 3.0.6

这是不可取的,这是把gem的版本降低,虽然降了后可以运行msfconsole,但是bundler、wpscan等运行也会报错。

经多番测试,发现只有把gem更新到3.2.0才可以,直接更新是不行的,必须源码安装:

复制代码

# 源码安装gem 3.2.0
git clone https://github.com/rubygems/rubygems
cd rubygems
ruby setup.rb

# 再进行修复
apt install ruby-dev -y
apt install libpq-dev libpcap-dev libsqlite3-dev -y
cd /usr/share/metasploit-framework/
sed -i 's#https://rubygems.org#https://gems.ruby-china.com#' Gemfile
bundler install --no-deployment
gem install json -v '2.3.0'

复制代码

这样msfconsole就可以使用了。

不过ruby新版有不少warning:

/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:10: warning: constant Gem::ConfigMap is deprecated
/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:29: warning: constant Gem::ConfigMap is deprecated
/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:30: warning: constant Gem::ConfigMap is deprecated

# 解决方法
sed -i "s#Gem::ConfigMap\[:arch\]#RbConfig::CONFIG\['arch'\]#g;s#Gem::ConfigMap\[:ruby_version\]#RbConfig::CONFIG\['ruby_version'\]#g" /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb

复制代码

/usr/share/rubygems-integration/all/gems/mime-types-3.2.2/lib/mime/types/logger.rb:30: warning: `_1' is reserved for numbered parameter; consider another name
/usr/share/rubygems-integration/all/gems/mime-types-3.2.2/lib/mime/types/logger.rb:30: warning: `_2' is reserved for numbered parameter; consider another name
/usr/share/rubygems-integration/all/gems/mime-types-3.2.2/lib/mime/types/logger.rb:30: warning: `_3' is reserved for numbered parameter; consider another name

# 暂时没好的解决方法
# 如果不想显示warning
export RUBYOPT='-W0'

复制代码

rubygems最近修改得不少,要想等到一个相对稳定的版本,还需要一段时间。

 

你可能感兴趣的:(网络安全)