Installing Metasploit Framework + PostgreSQL DB Backend Under Ubuntu 12.04 LTS

Posted: December 8, 2011 in Guides
Tags: ,

It occured to me that there may be some individuals using Ubuntu Linux that want to follow along with the Metasploitable Guide, or just otherwise have the Metasploit Framework without using Back Track for it. So here is a quick run down on installing and configuring Metasploit Framework on Ubuntu 12.04 LTS, with a PostgreSQL backend. This should work on other versions of Ubuntu as well. The advantage of using 12.04 though, is that the ruby libraries from the repos are a bit newer, and you will get slightly better performance out of Metasploit Framework by using them.

Satisfying Dependencies

First we must satisfy all the Metasploit Framework Dependencies.

sudo apt-get update && sudo apt-get install ruby libopenssl-ruby libyaml-ruby libdl-ruby libiconv-ruby libpq-dev libpq5 libreadline-ruby irb ri rubygems subversion build-essential ruby-dev libpcap-dev postgresql-8.4 nmap

Installing the Postgres Ruby Gem

Next we need to install the pgSQL Ruby gem.

sudo gem install pg

Installing Metasploit Framework

Next we need to install the Metasploit Framework itself, we will be using subversion to do so. It is also used to update the framework, though now you can also get the latest snapshots via Git.

sudo mkdir /opt/framework3
cd  /opt/framework3
sudo svn co https://www.metasploit.com/svn/framework3/trunk/ msf

Configuring Extensions

Next to configure raw socket and wifi extension.

Raw Socket Extension

cd /opt/framework3/msf/external/pcaprub
sudo ruby extconf.rb
sudo make && sudo make installing

Wireless Extension

cd /opt/framework3/msf/external/ruby-lorcon2
sudo svn co http://802.11ninja.net/svn/lorcon/trunk lorcon2
cd lorcon2
sudo ./configure --prefix=/usr && sudo make && sudo make install
cd ..
sudo ruby extconf.rb
sudo make && sudo make install

Add Metasploit To Path

sudo ln -sf /opt/framework3/msf/msf* /usr/local/bin

Configuring Database Back-End

Create the new database user

sudo -s
su postgres
createuser msf -P

Create a password and answer the following questions appropriately (n is a safe default).

Create Database

create db –owner=msf msf

Running Metasploit Framework and Connecting to Your DB Backend

To start Metasploit Framework do the following

sudo msfconsole

Connecting To your Database

To connect to our database from Metasploit framework console we’ll do the following.

db_driver postgresql
db_connect msf:msf@127.0.0.1:5432/msf

Note : You can also add these to your /opt/framework/msf/msfconsole.rc file and the database will connect at run time.

where msf:msf is the username:password 127.0.0.1 is the host running PGSQL and msf is the database name.

Hope this was helpful.

P.S : I’m still in a creative slump so I know this was a cop-out sorry guys lol 😛

Advertisements
Comments
  1. Travis says:

    Thank you, Your post worked really well for me. 🙂

  2. fadi says:

    Thank you

  3. linuxlover says:

    thank you it works well apart from the postgres version (v8) being obsolete

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s