How to install metasploit framework from Github on Ubuntu



   In this post, I'm going to share How to install metasploit framework from Github on Ubuntu 12.04.Some reference of installing metasploit,I got from here. I have added some steps which I think will make it more easier than the published post.


 The installation process doesn't go well for me as my system have some compatibility issue as you will see in the video .I will do a separate post on it. Below are steps taken to do the installation


Steps summary

1) Update system
2) Install metasploit dependencies
3) (OPTIONAL) Install nmap
4) Download metasploit framework from Github
5) Install gems and version required by metasploit
6) Run metasploit framework
7) Create and connect the database with metasploit
8) Test and optimize metasploit search function
9) Add the  metasploit folder to your system environment


Steps


1)Update and upgrade system

1.1)update system
shark_attack@Positive-Space:~$sudo apt-get update


update system
 1.2)upgrade system
shark_attack@Positive-Space:~$sudo apt-get update

upgrade system


 2)Install  metasploit required dependencies

2.1)Install Ruby 1.9.3 and other dependencies

shark_attack@Positive-Space:~$sudo apt-get install build-essential libreadline-dev libssl-dev libpq5 libpq-dev libreadline5 libsqlite3-dev libpcap-dev openjdk-7-jre subversion git-core autoconf postgresql pgadmin3 curl zlib1g-dev libxml2-dev libxslt1-dev vncviewer libyaml-dev ruby1.9.3

Install Ruby dependencies


 2.2) Install Ruby libraries that metasploit depend on

 shark_attack@Positive-Space:~$sudo gem install wirble sqlite3 bundler


Install Ruby libraries that metasploit depend

 3)(OPTIONAL) Install nmap
Install NMAP if you still don't use one on your system

 shark_attack@Positive-Space:~$sudo apt-get install nmap


Install nmap
4)Download metasploit framework from Github to your system


 shark_attack@Positive-Space:~$cd /opt
 shark_attack@Positive-Space:~$git clone https://github.com/rapid7/metasploit-framework.git


Dowloading metasploit framework to /opt

 5) Install gems and version required by metasploit.
After finish downloading, go to metasploit folder

shark_attack@Positive-Space:~$cd /opt/metasploit-framework
shark_attack@Positive-Space:/opt/metasploit-framework$sudo bundle install

go to metasploit folder

install bundle
 NOTE: My system have problem installing the gems . It trigger  "girl friday" error as shown in the video. Please check my next post on how I resolve it .I will not share details how to do it in this post .You can see it in this video though :-)

 6)Run metasploit framework .
It might take few minutes for first time loading .

 shark_attack@Positive-Space:~$./msfconsole


run metasploit


Metasploit
 7)Create and connect the database with metasploit

7.1)Create user and postgres database . Make sure you remember what you type in when you create the user and database information.


shark_attack@Positive-Space:~$su -s
root@Positive-Space:~$su postgres
postgres@Positive-Space:/home/shark_attack$ createuser msf -P -S -R -D
postgres@Positive-Space:/home/shark_attack$ createdb -0 msf msf


creating user and db information


7.2)Connect database . msf4 folder will be in your home folder after you run metasploit for the first time.
Go to ./msf4 folder

shark_attack@Positive-Space:~$cd .msf4 
shark_attack@Positive-Space:~/.msf4$


.msf4 folder


7.3)Create a file name "database.yml" and key in the  detail informations that you have created before .Make sure all the details are correct including the password.

shark_attack@Positive-Space:~/.msf4$nano database.yml


 key in your database and user detail as how you configured .




adapter: postgresql

database: msf

password: shark_attack

username: msf

pool: 75

host: 127.0.0.1
port: 5432

timeout: 5







type the db and user info
save it

database.yml in msf4 folder



8)Test  and optimize metasploit search function


8.1)run metasploit framework  from your console and check the database status once it finish load .Remember to run as sudo . It might take few minutes to load the first time

shark_attack@Positive-Space:/opt/metasploit-framework$ sudo ./msfconsole



msf>db_status


checking database status


8.2) This step is just something that I notice doesn't work on my system in which ,whenever I  try to use the search  on metasploit, it will give an error  "Database not connected or cache not built,using slow search" .  It took few minutes to search anything.To resolve this issue, I rebuild the db cache by typing below command .

msf>db_rebuild_cache

Database not connected or cache not built


rebuilding the cache



That's it for today. If you are looking on how to install Kali Linux in Ubuntu ,please visit here.