[Shell-Script] Install Metasploit in Ubuntu for Beginner
Autor: Roberto dos Santos Soares (espreto) | Publicado: 2011-11-27T23:13:00-02:00

Devido receber vários e-mails perguntando como se instala (e quando digo vários, é vários meeeesmo :S) o metasploit no ubuntu, resolvi fazer rapidamente este script para tal fim.
É eu sei que o código tem bugs, mais ao que se propõe ele cumpre. :D
Testado nas versões 11.04 e 11.10.



#!/bin/bash

clear
echo
echo
echo " &nbsp; &nbsp; &nbsp; &nbsp; ..:[ Install MSF ]:.."
echo
echo " &nbsp; &nbsp; &nbsp; &nbsp;Roberto Soares (espreto)"
echo " &nbsp; &nbsp; &nbsp; &nbsp;robertoespreto@gmail.com"
echo
echo
echo "[+] Install the Metasploit Framework on Ubuntu Linux now? y/n "; read whx
&nbsp; &nbsp;if [ $whx = "y" ]
&nbsp; &nbsp;then
&nbsp; &nbsp; &nbsp; echo
&nbsp; &nbsp; &nbsp; echo "[+] Installing the Ruby dependencies..."
&nbsp; &nbsp; &nbsp; apt-get install -y ruby libopenssl-ruby libyaml-ruby libdl-ruby libiconv-ruby libreadline-ruby irb ri rubygems 1&gt; /dev/null 2&gt; /dev/stdout
&nbsp; &nbsp; &nbsp; echo "OK!"
&nbsp; &nbsp; &nbsp; echo "[+] Installing the Subversion client..."
&nbsp; &nbsp; &nbsp; apt-get install -y subversion 1&gt; /dev/null 2&gt; /dev/stdout
&nbsp; &nbsp; &nbsp; echo "OK!"
&nbsp; &nbsp; &nbsp; echo "[+] Installing extensions (pcaprub, lorcon2, etc)..."
&nbsp; &nbsp; &nbsp; apt-get install -y build-essential ruby-dev libpcap-dev 1&gt; /dev/null 2&gt; /dev/stdout
&nbsp; &nbsp; &nbsp; echo "OK!"
&nbsp; &nbsp; &nbsp; echo "[+] Download framework..."
&nbsp; &nbsp; &nbsp; echo
&nbsp; &nbsp; &nbsp; wget -c http://downloads.metasploit.com/data/releases/framework-latest.tar.bz2
&nbsp; &nbsp; &nbsp; echo "[+] Unpacking the file..."
&nbsp; &nbsp; &nbsp; tar -jxvf framework-latest.tar.bz2 1&gt; /dev/null 2&gt; /dev/stdout
&nbsp; &nbsp; &nbsp; mkdir -p /opt/metasploit
&nbsp; &nbsp; &nbsp; cp -a msf/ /opt/metasploit/msf3
&nbsp; &nbsp; &nbsp; chown root:root -R /opt/metasploit/msf3
&nbsp; &nbsp; &nbsp; ln -sf /opt/metasploit/msf3/msf* /usr/local/bin/
&nbsp; &nbsp; &nbsp; rm -rf msf/
&nbsp; &nbsp; &nbsp; echo "OK!"
&nbsp; &nbsp; &nbsp; echo
&nbsp; &nbsp; &nbsp; echo " &nbsp; CONGRATULATIONS! Install Metasploit Successful!!!"
&nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; echo &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; echo "Why?"
&nbsp; &nbsp; &nbsp; echo " &nbsp;You do not know what you're missing!"
&nbsp; &nbsp; &nbsp; echo
&nbsp; &nbsp; &nbsp; exit 0;
&nbsp; &nbsp;fi
echo

echo "[+] Update now? y/n "; read whx
&nbsp; &nbsp;if [ $whx = "y" ]
&nbsp; &nbsp;then
&nbsp; &nbsp; &nbsp; echo " &nbsp; Wait..."
&nbsp; &nbsp; &nbsp; msfupdate 1&gt; /dev/null 2&gt; /dev/stdout
&nbsp; &nbsp; &nbsp; echo " &nbsp; OK!"
&nbsp; &nbsp;else
&nbsp; &nbsp; &nbsp; echo " &nbsp; &nbsp; Future use in the terminal: msfupdate"
&nbsp; &nbsp;fi
echo
echo "[+] Install PostgreSQL Database now? y/n "; read whx
&nbsp; &nbsp;if [ $whx = "y" ]
&nbsp; &nbsp;then
&nbsp; &nbsp; &nbsp; echo " &nbsp; Wait..."
&nbsp; &nbsp; &nbsp; apt-get install -y postgresql-8.4 rubygems libpq-dev 1&gt; /dev/null 2&gt; /dev/stdout
&nbsp; &nbsp; &nbsp; gem install pg 1&gt; /dev/null 2&gt; /dev/stdout
&nbsp; &nbsp; &nbsp; apt-get install -y libreadline-dev libssl-dev libpq5 ruby-dev 1&gt; /dev/null 2&gt; /dev/stdout
&nbsp; &nbsp; &nbsp; echo " &nbsp; OK!"
&nbsp; &nbsp; &nbsp; echo
&nbsp; &nbsp; &nbsp; echo "1º Choice a username (user for connect in database):" ; read username
&nbsp; &nbsp; &nbsp; sudo -u postgres createuser -D -A -P $username
&nbsp; &nbsp; &nbsp; echo " &nbsp; Done!"
&nbsp; &nbsp; &nbsp; echo
&nbsp; &nbsp; &nbsp; echo "2º Choice a database name (that will be used by msf):" ; read db_name
&nbsp; &nbsp; &nbsp; sudo -u postgres createdb -O $username $db_name
&nbsp; &nbsp; &nbsp; echo " &nbsp; Done!"
&nbsp; &nbsp; &nbsp; echo
&nbsp; &nbsp; &nbsp; echo " &nbsp; &nbsp; &nbsp; &nbsp;Connect to the postgreSQL database in msfconsole using:"
&nbsp; &nbsp; &nbsp; echo " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msf&gt; db_driver postgresql"
&nbsp; &nbsp; &nbsp; echo " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msf&gt; db_connect $username:password@127.0.0.1/$db_name"
&nbsp; &nbsp; &nbsp; echo " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msf&gt; db_status"
&nbsp; &nbsp; &nbsp; echo
&nbsp; &nbsp; &nbsp; sleep 8
&nbsp; &nbsp;fi
clear
echo
echo " &nbsp; &nbsp; Installation Complete!"
echo " &nbsp;In terminal, run: msfconsole"
echo
echo
echo " &nbsp; &nbsp; &nbsp; &nbsp; Good bye!"
echo
# end script


:wq!