問題1復現路徑:
1. 終端輸入msfconsole,進入msf命令行模式,需要等待若干分鍾;
2. 輸入db_status,查看連接狀態,兩種結果:一,默認連接msf3;二,沒有連接,顯示postgresql selected, no connection
3. 創建連接數據庫msfbook,輸入 db_connect postgres:toor@127.0.0.1/msfbook
現象:
沒有顯示任何信息,輸入db_status查看,仍沒有連接
分析:
沒有相關賬號和密碼,所以無法連接
解決方案:
1. 在#命令行模式下,輸入sudo -u postgres psql postgres // 來創建賬號
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 // 創建成功
