1. 啟動postgresql
root@kali:~# service postgresql start
2. 設置用戶與數據庫
root@kali:~# su postgres postgres@kali:/root$ createuser msf4 -P Enter password for new role: Enter it again: postgres@kali:/root$ createdb --owner=msf4 msf4
postgres@kali:/root$ exit
exit
3. 測試數據庫連接狀態
root@kali:~# msfconsole ### ### msf > db_connect msf4:password@localhost/msf4 [*] Rebuilding the module cache in the background... msf > db_status [*] postgresql connected to msf4 msf > search 2015-0531 [!] Module database cache not built yet, using slow search #這里要稍等一下才會正常,可以考慮關閉應用重啟一下
4. 設置自動連接
自動連接可以通過配置文件 /usr/share/metasploit-framework/config/database.yml 完成,內容可以通過復制database.yml.example並修改內容來完成設置。
root@kali:/usr/share/metasploit-framework/config# cp database.yml.example database.yml root@kali:/usr/share/metasploit-framework/config# vi database.yml root@kali:/usr/share/metasploit-framework/config# cat database.yml # Please only use postgresql bound to a TCP port. # Only postgresql is supportable for metasploit-framework # these days. (No SQLite, no MySQL). # # To set up a metasploit database, follow the directions hosted at: # http://r-7.co/MSF-DEV#set-up-postgresql development: &pgsql adapter: postgresql database: msf3 #主要該紅色的這三個值 username: msf3 password: jinchangkun host: localhost port: 5432 pool: 5 timeout: 5 # You will often want to seperate your databases between dev # mode and prod mode. Absent a production db, though, defaulting # to dev is pretty sensible for many developer-users. production: &production <<: *pgsql # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. # # Note also, sqlite3 is totally unsupported by Metasploit now. test: <<: *pgsql database: metasploit_framework_test username: metasploit_framework_test password: ___________________________
重新執行msfconsole即可直接鏈接數據庫
root@kali:~# msfconsole ### ### msf > db_status [*] postgresql connected to msf4 msf > search CVE-2015-0311 Matching Modules ================ Name Disclosure Date Rank Description ---- --------------- ---- ----------- exploit/multi/browser/adobe_flash_uncompress_zlib_uaf 2014-04-28 great Adobe Flash Player ByteArray UncompressViaZlibVariant Use After Free msf >
本文轉自:http://www.mamicode.com/info-detail-1208947.html
僅供我個人學習使用,請到原作者處查看!!!
