天天看點

metasploit的資料庫配置

metasploit所處位置:/usr/share/metasploit-framework

msf資料庫連接配接指令:db_connect msf:[email protected]/msf

1、啟動postgresql

service postgresql start/2、進入postgresql配置      

2、進入postgresql配置

sudo -u postgres psql
alter user postgres with password 'kaliadmin';
注意1:’admin’ 這個是密碼。 
注意2:分号!!!! 一定要帶上分号”;”。 
注意3:\q:退出資料庫      

3、修改linux系統的postgres使用者的密碼(密碼與資料庫使用者postgres的密碼相同)

root@kali:~# sudo passwd -d postgres
passwd:密碼過期資訊已更改。
root@kali:~# sudo -u postgres passwd
輸入新的 UNIX 密碼:
重新輸入新的 UNIX 密碼:
passwd:已成功更新密碼      

4、修改PostgresSQL資料庫配置實作遠端通路

root@kali:~# vi /etc/postgresql/13/main/postgresql.conf    //由于我裝的是msf6,是以對應的資料庫版本是13.x
更改#listen_addresses = 'localhost'為listen_addresses = '*' 
更改#password_encryption = on為password_encryption = on      
root@kali:~# vi /etc/postgresql/13/main/pg_hba.conf
在文檔末尾加上以下内容
    # to allow your client visiting postgresql server
    host all all 0.0.0.0/32 md5
root@kali:~# service postgresql restart  //重新開機資料庫      

5、管理PostgresSQL使用者和資料庫

root@kali:~# psql -U postgres -h 127.0.0.1
使用者 postgres 的密碼:
psql (9.4.6)
SSL連接配接 (協定: TLSv1.2, 加密:ECDHE-RSA-AES256-GCM-SHA384,二進制位: 256, 壓縮比: 關閉)
輸入 "help" 來擷取幫助資訊.
postgres=# create user msf with password 'msfadmin' nocreatedb;
CREATE ROLE
postgres=# create database msf with owner=msf;
CREATE DATABASE
postgres=# \q
注意
    1、還是要注意分号!!!沒有分号指令就無法執行。 
    2、注意複制的時候”“符号問題。 
    3、user後面是使用者名,password後面是使用者名對應的密碼。 
    4、指令執行後有傳回結果才是執行成功了。
​      

6、msf配置連接配接

root@kali:~# msfconsole
msf > db_status 
[*] postgresql selected, no connection
msf > db_connect msf:[email protected]/msf
[*] Rebuilding the module cache in the background...
msf > db_status 
[*] postgresql connected to msf
msf > 
注意:
    1:”msf:admin”這個是步驟5中的 
        “create user msf with password ‘admin’ nocreatedb;”所建立的。 
        “127.0.0.1”是指本機。 
        “msf”這個是庫名。 
    2:”[*] postgresql connected to msf”這個是說明以連結成功資料庫。      

7、配置自動連接配接

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
development: &pgsql
  adapter: postgresql
  database: msf
  username: msf
  password: msfadmin
  host: localhost
  port: 5432
  pool: 5
  timeout: 5
​
        主要改database、password、host這三個值      

8、提示

下一篇: html