天天看点

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