Backtrack5的Postpresql的使用
TCP/IP connections on port 5432?
-----------------------------------------------------------------
从这里我们看出
?db_connect命令
默认去连接
5432接口,而我们可以通过多种方式看到开启的端口其实是
7337
?
【1】
?
root@bt:~# ps -ef|grep post
?
?
?
root ? ? ?3554 ? ? 1 ?0 19:50 tty1 ? ? 00:00:13 gedit /opt/metasploit/postgresql/data/pg_hba.conf
postgres ?4980 ? ? 1 ?0 21:11 pts/2 ? ?00:00:00 /opt/metasploit/postgresql/bin/postgres.bin -D /opt/metasploit/postgresql/data -p 7337
【2】/opt/metasploit/postgresql/data/postgresql.conf文件里有
?
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------
?
# - Connection Settings -
?
listen_addresses = '*'# what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost', '*' = all
# (change requires restart)
#port = 7377# (change requires restart)
max_connections = 100# (change requires restart)
【3】/etc/init.d/metasploit-postgres restart
?
LOG: ?received smart shutdown request
LOG: ?autovacuum launcher shutting down
LOG: ?shutting down
LOG: ?database system is shut down
/opt/metasploit/postgresql/scripts/ctl.sh : postgresql stopped
LOG: ?database system was shut down at 2013-03-02 20:45:52 CST
LOG: ?database system is ready to accept connections
LOG: ?autovacuum launcher started
/opt/metasploit/postgresql/scripts/ctl.sh : postgresql ?started at port 7337
?
------------------------------------------
接着用psql连接去连接发现
root@bt:~# psql
程序“psql”尚未安装。 ?您可以使用以下命令安装:
-----------------------------------------
然后安装
root@bt:~# apt-get install postgresql-client-common
----------------------------------------
安装完后发现还是有问题
Error: You must install at least one postgresql-client-<version> package.
奇怪了,这个时候去查看安装的依赖包关系
root@bt:~# apt-get install postgresql libpq-dev
下列软件包有未满足的依赖关系:
? libpq-dev: 依赖: libpq5 (= 8.4.8-0ubuntu0.10.04) 但是 8.4.12-0ubuntu10.04 正要被安装
被打败了。。。。。果断执行
root@bt:~# sudo apt-get install postgresql-8.4 postgresql-client-8.4
--------------------------------------------
这个时候发现其实已经重装好了postgresql了,版本是8.4
用命令重新启动:/etc/init.d/postgresql-8.4 restart
?
?
----------------------------------------------------------------------
root@bt:/etc/init.d# update-alternatives --config rubyThere 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 modePress enter to keep the current choice[*], or type selection number: 0update-alternatives: using /usr/bin/ruby1.8 to provide /usr/bin/ruby (ruby) in auto mode.root@bt:/etc/init.d# gem install pgBuilding native extensions. This could take a while...Successfully installed pg-0.11.01 gem installedInstalling ri documentation for pg-0.11.0...Installing RDoc documentation for pg-0.11.0... -----------------------最后一步,连接注意是
msf > db_connect postgres:"test12345"@127.0.0.1/postgres
?