适用linux(centos/ubuntu/arch) Metasploit安装及配置数据库 postgresql 10(For Metasploit)
Metasploit是一款很吊的开源的安全漏洞检测与利用工具(包含最新的0day漏洞利用)
我们以后会详细讲解如何使用,总之记得关注我哦!
在shell中复制下面的一段话输入
curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && \
chmod 755 msfinstall && \
./msfinstall
会自动开始下载并安装Metasploit
安装完后在shell输入
msfconsole
###输出以下内容即表示成功进入Metasploit###
Ready...
> access security
access: PERMISSION DENIED.
> access security grid
access: PERMISSION DENIED.
> access main security grid
access: PERMISSION DENIED....and...
YOU DIDN'T SAY THE MAGIC WORD!
YOU DIDN'T SAY THE MAGIC WORD!
YOU DIDN'T SAY THE MAGIC WORD!
YOU DIDN'T SAY THE MAGIC WORD!
YOU DIDN'T SAY THE MAGIC WORD!
YOU DIDN'T SAY THE MAGIC WORD!
YOU DIDN'T SAY THE MAGIC WORD!
=[ metasploit v5.0.3-dev- ]
+ -- --=[ 1852 exploits - 1046 auxiliary - 325 post ]
+ -- --=[ 541 payloads - 44 encoders - 10 nops ]
+ -- --=[ 2 evasion ]
+ -- --=[ ** This is Metasploit 5 development branch ** ]
msf >
以下是数据库配置,如果你不需要保存扫描结果,不安装配置数据库也可以
创建用户
[root@localhost ~]#useradd postgres
配置yum存储库
[root@localhost ~]# vim /etc/yum.repos.d/CentOS-Base.repo
[base] 和[updates] 区段之间添加:
exclude=postgresql*
安装pg的rpm文件
[root@localhost ~]# yum localinstall https://download.postgresql.org/pub/repos/yum/testing/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
安装pg数据库
[root@localhost ~]# yum list postgresql*
[root@localhost ~]# yum install postgresql10-server.x86_64
[root@localhost ~]# mkdir postgres /var/lib/pgsql/10/data
初始化数据库
[root@localhost ~]# /usr/pgsql-10/bin/postgresql10-setup initdb
Initializing database ... OK
[root@localhost ~]# su - postgres
[postgres@localhost ~]$ /usr/pgsql-10/bin/pg_ctl -D /var/lib/pgsql/10/data start
[postgres@localhost ~]$ /usr/pgsql-10/bin/psql -p 5432
psql (10devel)
输入 "help" 来获取帮助信息.
postgres=#
创建msf用户和msf数据库
postgres=# CREATE USER msf WITH PASSWORD 'msf';
postgres=# CREATE DATABASE msf OWNER msf;
postgres=# ALTER ROLE msf LOGIN ;
postgres=#\du 查看用户
postgres=#\l 查看数据库
postgres=#\c msf 切换数据库
postgres=#\d 列出当前数据库表
postgres=#\q 退出
安装完成!
修改配置文件 ,否则无法登录数据库
find / -name pg_hba.conf 找到文件
vi /var/lib/pgsql/10/data/pg_hba.conf
修改如下
[postgres@localhost ~] /usr/pgsql-10/bin/pg_ctl -D /var/lib/pgsql/10/data restart
使用root登录
在shell中输入
[root@localhost ~] psql -U msf -d msf -h 127.0.0.1 -p 5432
配置msf自动登录数据库
[root@localhost ~] find / -name database.yml.example
#找到目录/opt/metasploit-framework/embedded/framework/config/database.yml.example
copy /opt/metasploit-framework/embedded/framework/config/database.yml.example /opt/metasploit-framework/embedded/framework/config/database.yml
#修改该文件
[root@localhost ~] vim /opt/metasploit-framework/embedded/framework/config/database.yml
修改为以下信息
完成配置,重启metasploit与postgresql 即可完成数据库配置
reference material:
https://yizhishengsheng.blogspot.com/2017/11/centos-7-metasploit-postgresql-10for.html