Saturday, December 27, 2014

How to create a new Postgresql database and new user to work with Metasploit Framework


 
  In this tutorial, I'm going to share on how to create a new Postgresql database and new user to work with Metasploit Framework .This tutorial might be useful to those who have problems connecting to pre install Metasploit Framework either when you are running on Backtrack or Kali Linux.

In this tutorial,I will create a new database name "msf" and create a user name "msf" with password "metasploit". You will need to use this information when configure "database.yml" file . If you plan to use different database and user name please remember the details

Tutorial rundown

1) Run Postgresql service
2) Create new Postgresql user and database
3) Edit "database.yml" file
4) Run Metasploit service
5)Run the metasploit framework and check the connected database.


Steps

1) Run Postgresql service by typing

orca@omura:~$sudo service postgresql start






2) Create new Postgresql user and database

2.1) Create new user in Postgresql by login to postgres in root

orca@omura:~$sudo -su postgres
postgres@omura:/home/orca$ createuser msf -P -S -R -D
Enter password for new role :
Enter it again:



2.2) Create new database in Postgresql

postgres@omura:/home/orca$ createdb -o msf msf
postgres@omura:/home/orca$ exit



3) Edit "database.yml" file

3.1) Copy "database.yml" file from /opt/metasploit/apps/pro/ui/config/database.yml to home/.msf4 folder

orca@omura:~$sudo cp /opt/metasploit/apps/pro/ui/config/database.yml  /home/orca/.msf4





NOTE :If you already have database.yml file in /home/.msf4 folder , you can skip this step.


3.2)Change the file permission and edit database.yml file details


orca@omura:~/.msf4$sudo chmod 755 database.yml 



3.3)Edit  "database.yml" file with the information that you use to create user and database.

production:
  adapter :"postgresql"
  database: "msf"
  username: "msf"
  password:"metasploit"
  port:5432
  host: "localhost"
  pool:256
  timeout:5



4) Run Metasploit service

orca@omura:~$sudo service metasploit start 




5)Run the metasploit framework and check the connected database

5.1) Click "Applications>Kali Linux >Top 10 tools> Metasploit Framework "



5.2)Check the connected database

msf> db_status









Saturday, December 13, 2014

How to run metasploit (missing database.yml) and make postgresql,metasploit run at startup


    In this tutorial, I'm going to share on How to run metasploit (missing database.yml) and make Postgresql,Metasploit to run at startup. For official documentation on running Metasploit in Kali Linux, please visit here.


Steps

1) Run postgresql and metasploit service on the machine by typing

orca@omura:~$sudo service postgresql start

orca@omura:~$sudo service metasploit start

Starting postgresql and Metasploit service

2)Run Metasploit framework by going  to Applications>Kali Linux>Top 10 security tools>Metasploit framework

 
Run Metasploit Framework




3) Once Metasploit finished loading, check the database connection by typing
 
msf>db_status



No connected database.

4)If metasploit does not connect to postgresql database, check for "database.yml" file in .msf4 file in home directory


No database.yml file

4.1)Copy database.yml file from opt directory by typing


orca@omura:~$sudo cp /opt/metasploit/apps/pro/ui/config/database.yml /home/orca/.msf4  


Copy file from /opt

4.2) Change file permission by typing

orca@omura:~/.msf4$ sudo chmod 755 database.yml

Change file permission

5)Run Metasploit framework by going  to Applications>Kali Linux>Top 10 security tools>Metasploit framework and check database connection status

Check the database connection
(If it is not connected, you can try to create a new database and new user to make it work with metasploit . I will share in my future tutorial on how to do this)

6)Make postgresql and metasploit service to run at startup by typing

orca@omura:~/.msf4$ sudo update-rc.d postgresql enable

orca@omura:~/.msf4$ sudo update-rc.d metasploit enable



Updating Postgresql and Metasploit service to run at startup

 7)Reboot your machine and try to run Metasploit framework straight after you log on.

System reboot