VPS搭建msf教程

VPS搭建msf教程

20231215记录

弄好VPS后,先更新yum:

yum -y update

之后执行下面的命令即可(好像连postgres都不用管就可以连接数据库):

wget https://downloads.metasploit.com/data/releases/metasploit-latest-linux-x64-installer.run

end

2022年5月16日

19:30

这里使用的是centos7搭建的vps,搭建完毕之后按照以下步骤执行即可:

1、切换到root权限之后找一个合适目录下载msf,这里我在home目录里面下载的。

wget https://downloads.metasploit.com/data/releases/metasploit-latest-linux-x64-installer.run

给权限:

chmod +x metasploit-latest-linux-x64-installer.run

运行:

./metasploit-latest-linux-x64-installer.run

2、安装postgresql

yum install -y postgresql-server

配置数据库:

[root@localhost ~]# postgresql-setup initdb

[root@localhost ~]# su - postgres

-bash-4.2$ whoami

postgres

-bash-4.2$ pg_ctl -D /var/lib/pgsql/data start

-bash-4.2$ psql -p 5432

新密码:

postgres=# \password postgres

创建msf数据库:

postgres=# create user msf with password 'msf';

postgres=# create database msf owner msf;

postgres=# alter role msf login;

退出数据库:

\q

 

修改配置文件:

[root@localhost ~]# find / -name pg_hba.conf

[root@localhost ~]# vi /var/lib/pgsql/data/pg_hba.conf

最重要的环节:

 

 

 

 

重启数据库:

[root@localhost ~]# su - postgres

-bash-4.2$ pg_ctl -D /var/lib/pgsql/data restart

 

切换root用户,测试连接是否正常:

[root@localhost ~]# psql -U msf -d msf -h 127.0.0.1 -p 5432

 

修改msf配置链接数据文件:

[root@localhost ~]# find / -name database.yml.example

 

/opt/metasploit/apps/pro/ui/config/database.yml.example

 

/opt/metasploit/apps/pro/vendor/bundle/ruby/2.6.0/gems/metasploit-framework-4.17.73/config/database.yml.example

 

/opt/metasploit/apps/pro/vendor/bundle/ruby/2.6.0/gems/metasploit-credential-2.0.14/spec/dummy/config/database.yml.example

 

/opt/metasploit/apps/pro/vendor/bundle/ruby/2.6.0/gems/metasploit_data_models-2.0.17/spec/dummy/config/database.yml.example

 

/opt/metasploit/apps/pro/vendor/bundle/ruby/2.6.0/gems/metasploit-model-2.0.4/spec/dummy/config/database.yml.example

 

[root@localhost ~]# cp /opt/metasploit/apps/pro/vendor/bundle/ruby/2.6.0/gems/metasploit-framework-4.17.73/config/database.yml.example /opt/metasploit/apps/pro/vendor/bundle/ruby/2.6.0/gems/metasploit-framework-4.17.73/config/database.yml

 

[root@localhost ~]# vi /opt/metasploit/apps/pro/vendor/bundle/ruby/2.6.0/gems/metasploit-framework-4.17.73/config/database.yml

 

修改配置文件内容:

development: &pgsql

 

adapter: postgresql

 

database: msf

 

username: msf

 

password: msf

 

host: localhost

 

port: 5432

 

pool: 200

 

timeout: 5

重启msf、重启postgresql

登陆msf,查看状态即可:

db_connect msf:msf@localhost/msf

 

db_connect msf:msf@127.0.0.1/msf

 

 

posted @ 2022-05-16 22:02  逆向菜狗  阅读(12)  评论(0编辑  收藏  举报