I recently installed Metasploit on a MacBook Pro running Yosemite 10.10.3. Most of the information I found online was outdated so I thought it would be a good idea to create this post.
Before you can begin the installation of metasploit you need to have the Xcode Command line tools installed.
You also need to have the latest Java SE JDK installed.
If you do not have the latest version you can download and install it from here
You also need to have the latest version of Homebrew installed. To learn more about what Homebrew is please visit brew.sh.
The command to install Homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
When you install Homebrew you need to update your PATH.
echo PATH=/usr/local/bin:/usr/local/sbin:$PATH >> ~/.bash_profile
brew tap homebrew/versions
We can now install NMAP using Homebrew.
brew install nmap
libxml2 is needed
brew install libxml2
PostgreSQL is needed
brew install postgresql —without-ossp-uuid
The PostgreSQL Configuration
Initialize the database:
Set up the database to start after a user logs in
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.4.2/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
( replace 9.4.2 with the version you have installed )
Create the database for metasploit.
createuser meta -P -h localhost
createdb -O meta meta -h localhost
Clone and install Metasploit.
git clone https://github.com/rapid7/metasploit-framework.git
for MSF in $(ls msf*); do ln -s /usr/local/share/metasploit-framework/$MSF /usr/local/bin/$MSF;done
sudo chmod go+w /etc/profile
sudo echo export MSF_DATABASE_CONFIG=/usr/local/share/metasploit-framework/config/database.yml >> /etc/profile
Install Nokogiri Gem
bundle config build.nokogiri "--use-system-libraries —with-xml2-include=/usr/local/opt/libxml2/include/libxml2"
Install PG Gem
sudo env ARCHFLAGS="-arch x86_64" gem install pg
In the metasploit folder, use bundle to install the remaining gems.
sudo bundle install
Create the Metasploit Database Configuration
Paste the following text:
production: adapter: postgresql database: meta username: meta password: passwordgoeshere host: 127.0.0.1 port: 5432 pool: 75 timeout: 5
Now update your environment:
You are now ready to run Metasploit