Sha256: 30da2930f16b9d03399694b05d7b68221ea82c07715dc7c5a2c1976a6875b529

Contents?: true

Size: 1.73 KB

Versions: 728

Compression:

Stored size: 1.73 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'yaml'

# Install Metasploit from Source
printf 'Installing Metasploit *****************************************************************'
if ENV.fetch('PWN_ROOT')
  pwn_root = ENV.fetch('PWN_ROOT')
elsif Dir.exist?('/pwn')
  pwn_root = '/pwn'
else
  pwn_root = Dir.pwd
end

pwn_provider = ENV.fetch('PWN_PROVIDER') if ENV.fetch('PWN_PROVIDER')

metasploit_root = '/opt/metasploit-framework-dev'
`sudo git clone https://github.com/rapid7/metasploit-framework.git #{metasploit_root}`
`sudo apt install -y libpq-dev postgresql-server-dev-all`
metasploit_ruby_version = File.readlines("#{metasploit_root}/.ruby-version")[0].to_s.scrub.strip.chomp
metasploit_gemset = File.readlines("#{metasploit_root}/.ruby-gemset")[0].to_s.scrub.strip.chomp
`
  sudo bash \
    --login \
    -c "\
      rvm install ruby-#{metasploit_ruby_version} && \
      rvm use ruby-#{metasploit_ruby_version} && \
      rvm gemset create #{metasploit_gemset} && \
      cd #{metasploit_root} && \
      gem install bundler && \
      bundle install
    "
`

printf 'Starting up MSFRPCD *******************************************************************'
vagrant_example = "#{pwn_root}/etc/userland/#{pwn_provider}/metasploit/vagrant.yaml.EXAMPLE"
vagrant_yaml = "#{pwn_root}/etc/userland/#{pwn_provider}/metasploit/vagrant.yaml"

system(
  "
    sudo bash \
      --login \
      -c 'cp #{vagrant_example} #{vagrant_yaml}'
  "
)

system(
  "
    sudo bash \
      --login \
      -c \"\
        rvm use ruby-#{metasploit_ruby_version}@#{metasploit_gemset} && \
        cp #{pwn_root}/etc/systemd/msfrpcd.service /etc/systemd/system/ && \
        systemctl enable msfrpcd.service && \
        systemctl start msfrpcd.service
      \"
  "
)

Version data entries

728 entries across 728 versions & 1 rubygems

Version Path
pwn-0.5.214 packer/provisioners/metasploit.rb
pwn-0.5.213 packer/provisioners/metasploit.rb
pwn-0.5.212 packer/provisioners/metasploit.rb
pwn-0.5.211 packer/provisioners/metasploit.rb
pwn-0.5.210 packer/provisioners/metasploit.rb
pwn-0.5.209 packer/provisioners/metasploit.rb
pwn-0.5.207 packer/provisioners/metasploit.rb
pwn-0.5.206 packer/provisioners/metasploit.rb
pwn-0.5.205 packer/provisioners/metasploit.rb
pwn-0.5.204 packer/provisioners/metasploit.rb
pwn-0.5.203 packer/provisioners/metasploit.rb
pwn-0.5.202 packer/provisioners/metasploit.rb
pwn-0.5.201 packer/provisioners/metasploit.rb
pwn-0.5.200 packer/provisioners/metasploit.rb
pwn-0.5.199 packer/provisioners/metasploit.rb
pwn-0.5.198 packer/provisioners/metasploit.rb
pwn-0.5.197 packer/provisioners/metasploit.rb
pwn-0.5.196 packer/provisioners/metasploit.rb
pwn-0.5.195 packer/provisioners/metasploit.rb
pwn-0.5.194 packer/provisioners/metasploit.rb