Go Back   TechArena Community > Software > Operating Systems
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , ,

Sponsored Links


How to install metasploit and postgresql in backtrack 5?

Operating Systems


Reply
 
Thread Tools Search this Thread
  #1  
Old 24-06-2011
Member
 
Join Date: May 2011
Posts: 1,568
How to install metasploit and postgresql in backtrack 5?

Sponsored Links
Backtrack 5 does not come with a postgresql server independently outside of the box. metasploit 3.7, however, comes with its own built-in PostgreSQL server and default connects to it in the back 5 (type 'db_driver' a new install or live back five starters, in msfconsole to see this in action - please that / opt/framework3/postgresql/data / is where all settings)! This HOWTO details how to run the PostgreSQL server and gets it.Right metasploit to interact with the bat I want to thank for his excellent tutorial disease => Metasploit db_autopwn using PostgreSQL you get a lot of this paper (literally) to metasploit get up and running. He is the person who thanked here; I just set things up a bit to work with Backtrack 5.
Code:
apt-get install postgresql libpq-dev
sudo su postgres -c psql
ALTER USER postgres WITH PASSWORD ‘your password’;
\q
sudo passwd -d postgres
sudo su postgres -c passwd
gem install pg
msfconsole
db_driver postgresql
db_connect postgres:”postgreSQL  password”@127.0.0.1/metasploit (“metasploit” being the name of the  database)
from there your good to go... I created the file /root/.msf3/msfconsole.rc with the following so I don't have to type the db_* commands each time ::
Code:
db_driver postgresql
db_connect postgres:”postgreSQL  password”@127.0.0.1:5432/metasploit
db_workspace -a PWBv3
lastly if you want to change the port postgresql runs on, change the 'port =' setting in the file/etc/postgresql/8.4/main/postgresql.conf then restart the server via '/etc/init.d/postgresql-8.4 restart'

Reply With Quote
  #2  
Old 24-06-2011
Deep123's Avatar
Member
 
Join Date: Apr 2009
Posts: 1,065
re: How to install metasploit and postgresql in backtrack 5?

when i try to install postgresql.i get following output

Code:
root@root:~# sudo su postgres -c psql
could not change directory to "/root"
psql (8.4.8)
Type "help" for help.
postgres=# ALTER USER postgres WITH PASSWORD root123
postgres-# \q
could not save history to file "/home/postgres/.psql_history": No such file or directory
root@root:~# sudo passwd -d postgres
passwd: password expiry information changed.
root@root:~# sudo su postgres -c passwd
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
root@root:~# update-alternatives --config ruby
There are 2 choices for the alternative ruby (providing /usr/bin/ruby).
  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/ruby1.8     500       auto mode
  1            /usr/bin/ruby1.8     500       manual mode
  2            /usr/bin/ruby1.9.2   400       manual mode

Press enter to keep the current choice[*], or type selection number: 
root@root:~# 
root@root:~# gem install postgres
ERROR:  http://rubygems.org/ does not appear to be a repository
ERROR:  Could not find a valid gem 'postgres' (>= 0) in any repository
root@root:~# gem install postgres
Building native extensions.  This could take a while...
ERROR:  Error installing postgres:
	ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:46: command not found: pg_config --includedir
extconf.rb:53: command not found: pg_config --libdir
checking for main() in -lpq... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/bin/ruby1.8
	--with-pgsql-dir
	--without-pgsql-dir
	--with-pgsql-include
	--without-pgsql-include=${pgsql-dir}/include
	--with-pgsql-lib
	--without-pgsql-lib=${pgsql-dir}/lib
	--with-pqlib
	--without-pqlib
Could not find PostgreSQL build environment (libraries & headers): Makefile not created
Reply With Quote
  #3  
Old 24-06-2011
Elieis's Avatar
Member
 
Join Date: Nov 2009
Posts: 726
re: How to install metasploit and postgresql in backtrack 5?

Quote:
Originally Posted by Deep123
Could someone please look over what I'm getting once I've ran apt-get install postgresql. It seems to install but things just dont seem to work after following your commands perfectly. I've tried this on 2 fresh installs, KDE and Gnome (32 bit). This is what i get:
Code:
root@root:~# sudo su postgres -c psql
could not change directory to "/root"
psql (8.4.8)
Type "help" for help.
postgres=# ALTER USER postgres WITH PASSWORD root123
postgres-# \q
that's your problem right there. make sure to follow the directions 'exactly' =)
Code:
ALTER USER postgres WITH PASSWORD ‘your password’;
note the RED =) you have to terminate your commands in psql with a ';' ... essentially your user isn't getting created.
Reply With Quote
  #4  
Old 24-06-2011
mv's Avatar
mv mv is offline
Member
 
Join Date: May 2008
Posts: 682
re: How to install metasploit and postgresql in backtrack 5?

working mode code
Code:
root@bt:~# apt-get install postgresql 
root@bt:~# sudo apt-get install libpgsql-ruby
root@bt:~# sudo su postgres
sh-4.1$ createuser root -P
could not change directory to "/root"
Enter password for new role: 
Enter it again: 
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
sh-4.1$ createdb --owner=root metasploit
could not change directory to "/root"
exit
sh-4.1$ exit
exit
root@bt:~# msfconsole
msf > db_driver postgresql[*] Using database driver postgresql
msf > db_connect root:toor@127.0.0.1:5432/metasploit
db_workspace -a MyProject
*] Added workspace: MyProject
msf > db_nmap 192.168.1.165 -sS -O[*] Nmap: Starting Nmap 5.51SVN ( http://nmap.org ) at 2011-05-14 15:27 CEST[*] Nmap: Nmap scan report for hackdany-cecb3e.homenet.telecomitalia.it (192.168.1.165)[*] Nmap: Host is up (0.00055s latency).[*] Nmap: Not shown: 997 closed ports[*] Nmap: PORT STATE SERVICE[*] Nmap: 135/tcp open msrpc[*] Nmap: 139/tcp open netbios-ssn[*] Nmap: 445/tcp open microsoft-ds[*] Nmap: MAC Address: 08:00:27:F1:F2:8F (Cadmus Computer Systems)[*] Nmap: Device type: general purpose[*] Nmap: Running: Microsoft Windows XP[*] Nmap: OS details: Microsoft Windows XP SP2 or SP3[*] Nmap: Network Distance: 1 hop[*] Nmap: OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .[*] Nmap: Nmap done: 1 IP address (1 host up) scanned in 3.56 seconds
msf > db_autopwn -p -e -q[*] (1/51 [0 sessions]): Launching exploit/windows/dcerpc/ms03_026_dcom against 192.168.1.165:135...[*] (2/51 [0 sessions]): Launching exploit/freebsd/samba/trans2open against 192.168.1.165:139...[*] (3/51 [0 sessions]): Launching exploit/linux/samba/chain_reply against 192.168.1.165:139...[*] (4/51 [0 sessions............................etc...etc...et c
the work is perfect (FOR ME)
Reply With Quote
  #5  
Old 24-06-2011
Edi Edi is offline
Member
 
Join Date: May 2011
Posts: 121
re: How to install metasploit and postgresql in backtrack 5?

I've been trying to get this job for about 2 weeks. Thank you a lot of study and documentation postgresql, finally understand my problem. I had to install postgresql database that runs from the Metasploit Framework. No configuration files for him than I can find. However it is running in the background. The disabled with 'service postgresql-8.3 stop' postgresql installed and configured for 9.1 postgresql start on port the standard port. I think the port is like 5432. 9.1 default start 5433, so I changed the postgresql.conf and pg_hba.conf to enable my password. Restart the server and load the connect command to MSF. Here is my output after.
Code:
msf > db_driver[*] Active Driver: postgresql[*] Available: postgresql, mysql
msf > db_connect postgres:redhat590@127.0.0.1/metasploit
NOTICE: CREATE TABLE will create implicit sequence "hosts_id_seq" for serial column "hosts.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "hosts_pkey" for table "hosts"
NOTICE: CREATE TABLE will create implicit sequence "clients_id_seq" for serial column "clients.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clients_pkey" for table "clients"
NOTICE: CREATE TABLE will create implicit sequence "services_id_seq" for serial column "services.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "services_pkey" for table "services"
NOTICE: CREATE TABLE will create implicit sequence "vulns_id_seq" for serial column "vulns.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "vulns_pkey" for table "vulns"
NOTICE: CREATE TABLE will create implicit sequence "refs_id_seq" for serial column "refs.id"
Freaking worked like a charm. Turns out I had to leave the old server running postgres. Is integrated into Metasploit, so I have to set up a script to make stops at the beginning is not Biggy. Also, for anyone who cannot get this working. Be sure to check the PostgreSQL server is running with "service - status-all". You may perhaps see one that is previously built into metasploit; it has no place to edit the file pg_hba.conf. I cannot seem to find it. Anyway, upgrade to PostgreSQL 9.1 and the service status to all and hope to run the version. It will show a + next to the version. Thereafter. Disable it with "service postgresql-(version) stop" and start the server with 9.1 "service postgresql-(version) start". Allowing you to connect very well. Sure to change the port postgresql. Conf and change the settings in pg_hba.conf to "password" so you do not have to encrypt your password.
Reply With Quote
  #6  
Old 24-06-2011
Member
 
Join Date: May 2011
Posts: 205
re: How to install metasploit and postgresql in backtrack 5?

can anyone tell me how to fix this error?
Code:
postgres=# ALTER USER postgres WITH PASSWORD root123;
ERROR:  syntax error at or near "root123"
LINE 1: ALTER USER postgres WITH PASSWORD root123;
Reply With Quote
  #7  
Old 24-06-2011
Member
 
Join Date: Apr 2010
Posts: 71
re: How to install metasploit and postgresql in backtrack 5?

You need to use the surround your password with an apostrophe at each side of it::
Code:
  <..SNIP..>   <..SNIP..>
sudo su postgres -c psql
ALTER USER postgres WITH PASSWORD ’your password’;
/g
Reply With Quote
  #8  
Old 30-09-2011
Member
 
Join Date: Sep 2011
Posts: 1
Exclamation Re: How to install metasploit and postgresql in backtrack 5?

alright guys im kind of stumped here, can you please help. I am trying to run install postgresql because it is necessary to run armitage. i keep getting error codes left and right after following each of these installation codes. Now in armitage i get this message that it failed to connect bla bla bla, then it has something like this.

Code:
Call Stack:
/opt/framework/msf3/lib/msf/ui/console/command_dispatcher/db.rb:1908:in 'db_connect_postgresql
/opt/framework/msf3/lib/msf/ui/console/command_dispatcher/db.rb:1716:in 'cmd_db_connect'
and then about six more different errors. but i followed your steps and i noticed that it isnt letting me connect the postgresql and wont let me modify the directory name to "root". since i have postgresql installed how would i go about connecting this? all im trying to do is to use armitage, and when I start msfgui and create a new msfrpcd the exploits, auxiliaries payloads and post modules are listed.... but like i said a thousand times haha armitage just doesnt want too cooperate lol. Thank you.
Reply With Quote
  #9  
Old 30-09-2011
SUpER CoP's Avatar
Member
 
Join Date: Dec 2007
Posts: 981
Re: How to install metasploit and postgresql in backtrack 5?

To get metasploit up and running, it is NOT required to disable ssl in the postgresql.conf, as the server works without trouble simply be installing postgresql from package.
Code:
apt-get install postgresql libpq-dev
sudo su postgres -c psql
ALTER USER postgres WITH PASSWORD 'your password';
\q
sudo passwd -d postgres
sudo su postgres -c passwd
<type the password for postgres account>
update-alternatives --config ruby
choose 0 for "auto-mode"
gem install pg
msfconsole
db_driver postgresql
db_connect postgres:”postgreSQL_password”@127.0.0.1/metasploit (“metasploit” being the name of the  database)
workspace -a <workspace>
from there your good to go... I created the file /root/.msf4/msfconsole.rc with the following so I don't have to type the db_* commands each time ::
Code:
db_driver postgresql
db_connect postgres:”postgreSQL_password”@127.0.0.1/metasploit
workspace PWBv3
lastly if you want to change the port postgresql runs on, change the 'port =' setting in the file /etc/postgresql/8.4/main/postgresql.conf then restart the server via '/etc/init.d/postgresql-8.4 restart'
Reply With Quote
Reply

  TechArena Community > Software > Operating Systems


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to install metasploit and postgresql in backtrack 5?"
Thread Thread Starter Forum Replies Last Post
Backtrack 5 – No database in metasploit, when followed proposed steps Habiba22 Windows Software 5 05-08-2011 09:21 AM
BackTrack 5: Getting call stack error on metasploit drivers Aag-Man Windows Software 5 09-07-2011 10:36 AM
Unable to execute metasploit in backtrack 5 after updating db_driver sqlite 3 Gaganvihari Windows Software 5 06-07-2011 07:40 PM
Can’t get metasploit working in backtrack 5 Baijayanthi Operating Systems 4 20-06-2011 06:34 AM
Metasploit pcaprub solution for Backtrack 5 Farzana Operating Systems 4 19-06-2011 01:31 AM


All times are GMT +5.5. The time now is 04:53 AM.