问题1复现路径:sql
1. 终端输入msfconsole,进入msf命令行模式,须要等待若干分钟;数据库
2. 输入db_status,查看链接状态,两种结果:一,默认链接msf3;二,没有链接,显示postgresql selected, no connectionpost
3. 建立链接数据库msfbook,输入 db_connect postgres:toor@127.0.0.1/msfbook编码
现象:命令行
没有显示任何信息,输入db_status查看,仍没有链接postgresql
分析:it
没有相关帐号和密码,因此没法链接io
解决方案:console
1. 在#命令行模式下,输入sudo -u postgres psql postgres // 来建立帐号coding
2. 就会进入到postgres=#模式下,在msfconsole模式下输入 alter user postgres with password 'toor'; // 来修改密码
3. 显示ALTER ROLE // 修改生效
4. 退出postgres=#模式,从新输入db_connect postgres:toor@127.0.0.1/msfbook,就会出现一堆冗长的信息,这是建立链接数据表的过程,这只有在第一次建立postgres的msfbook库时出现冗长信息,之后就没有了,直接回到msf终端提示符。
提示:
记得开始进入msfconsole前,启动postgresql和metasploit服务,命令以下:
1. service postgresql start
2. service metasploit start
问题2现象:
根据以上的步骤进行建立链接数据库后,msf中会提示,建立时数据库编码错误,"Error while running command db_connect: Failed to connect to the database: PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) HINT: Use the same encoding as in the template database, or use template0 as template.: CREATE DATABASE "msfbook" ENCODING = 'utf8' Call stack:......"
分析:
默认数据库编码问题
解决方案:
1. sudo -u postgres psql postgres // 进入postgres用户PostgreSQL数据库模式中
2. 输入 create database msfbook with encoding='SQL_ASCII';
3. 显示 CREATE DATABASE // 建立成功