Linux(CentOS)安装msf

目录

一、安装MSF

1.1 在线安装

1.2 离线安装

二、安装Postgresql数据库


一、安装MSF

1.1 在线安装

需要挂梯子!挂完梯子需要reboot重启,多试几次就可以,国内网络我试了很久都不行。没条件没梯子的看1.2离线安装

cd /opt
curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && chmod 755 msfinstall && ./msfinstall

测试msf,安装成功。

[root@msf-18 opt]# msfconsole
Metasploit tip: Enable verbose logging with set VERBOSE true
                                                  

                 _---------.
             .' #######   ;."
  .---,.    ;@             @@`;   .---,..
." @@@@@'.,'@@            @@@@@',.'@@@@ ".
'-.@@@@@@@@@@@@@          @@@@@@@@@@@@@ @;
   `.@@@@@@@@@@@@        @@@@@@@@@@@@@@ .'
     "--'.@@@  -.@        @ ,'-   .'--"
          ".@' ; @       @ `.  ;'
            |@@@@ @@@     @    .
             ' @@@ @@   @@    ,
              `.@@@@    @@   .
                ',@@     @   ;           _____________
                 (   3 C    )     /|___ / Metasploit! \
                 ;@'. __*__,."    \|--- \_____________/
                  '(.,...."/


       =[ metasploit v6.3.34-dev-                         ]
+ -- --=[ 2356 exploits - 1227 auxiliary - 413 post       ]
+ -- --=[ 1387 payloads - 46 encoders - 11 nops           ]
+ -- --=[ 9 evasion                                       ]

Metasploit Documentation: https://docs.metasploit.com/

msf6 > 

1.2 离线安装

msf官网:Metasploit | Penetration Testing Software, Pen Testing Security | Metasploit

msf文档:Nightly Installers | Metasploit Documentation Penetration Testing Software, Pen Testing Security

msf离线rpm包下载(CentOS/RedHat):Directory Tree

下载离线安装包并安装

cd /opt
wget https://rpm.metasploit.com/metasploit-omnibus/pkg/metasploit-framework-6.3.34%2B20230914102727~1rapid7-1.el6.x86_64.rpm 
yum install metasploit-framework-6.3.34+20230914102727~1rapid7-1.el6.x86_64.rpm
=====================================================================================================================
 Package
   Arch   Version                             Repository                                                        Size
=====================================================================================================================
Installing:
 metasploit-framework
   x86_64 6.3.34+20230914102727~1rapid7-1.el6 /metasploit-framework-6.3.34+20230914102727~1rapid7-1.el6.x86_64 747 M

Transaction Summary
=====================================================================================================================
Install  1 Package

安装ruby

yum install ruby

ruby -v
[root@msf-18 opt]# msfconsole
Metasploit tip: You can pivot connections over sessions started with the 
ssh_login modules

*Neutrino_Cannon*PrettyBeefy*PostalTime*binbash*deadastronauts*EvilBunnyWrote*L1T*Mail.ru*() { :;}; echo vulnerable*
*Team sorceror*ADACTF*BisonSquad*socialdistancing*LeukeTeamNaam*OWASP Moncton*Alegori*exit*Vampire Bunnies*APT593*
******

##还没安装数据库,所以是未连接状态
msf6 > db_status
[*] postgresql selected, no connection
msf6 > quit

二、安装Postgresql数据库

不管是在线安装还是离线安装都需要安装Postgresql,安装Postgresql的步骤是一致的,容易出错,请按照步骤执行,不安装数据库也可以正常使用msf,只不过使用过程中产生的数据不会保存

卸载Postgresql

rpm -qa | grep postgresql    ##查看是否安装
yum remove postgresql*      ##卸载
##导入yum源
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

##安装Postgresql数据库客户端与服务端,安装12版本,注意不要使用其它源,否则yum安装默认是9.5版本。
yum install -y postgresql12 postgresql12-server

查询是否安装

##查询是否安装
[root@msf-18 opt]# rpm -qa | grep postgresql
postgresql12-server-12.16-1PGDG.rhel7.x86_64
postgresql12-12.16-1PGDG.rhel7.x86_64
postgresql12-libs-12.16-1PGDG.rhel7.x86_64

初始化数据库 

##初始化数据库
[root@msf-18 opt]# /usr/pgsql-12/bin/postgresql-12-setup initdb 
Initializing database ... OK

 启动和设置开机自启动

##启动和设置开机自启动
[root@msf-18 opt]# systemctl start postgresql-12
[root@msf-18 opt]# systemctl enable postgresql-12
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-12.service to /usr/lib/systemd/system/postgresql-12.service.

PostgreSQL安装成功之后,会默认创建一个名为postgres的Linux用户,初始化数据库后,会有名为postgres的数据库,来存储数据库的基础信息。

进入数据库shell设置数据库密码

退出sql shell是\q

退出bash-4.2是exit

退出msf是quit

[root@msf-18 opt]# su postgres
bash-4.2$ psql
psql (12.16)
输入 "help" 来获取帮助信息.

postgres=# ALTER USER postgres WITH PASSWORD '123456';
ALTER ROLE
postgres=# \q
bash-4.2$ exit
exit

[root@msf-18 opt]# 

使用msf用户初始化数据库,注意不要使用root用户初始化

[root@msf-18 opt]# cd /opt/metasploit-framework/bin/

[root@msf-18 bin]# useradd msf
[root@msf-18 bin]# su msf

[msf@msf-18 bin]$ ./msfdb init
Clearing http web data service credentials in msfconsole
Running the 'init' command for the database:
Creating database at /home/msf/.msf4/db
Creating db socket file at /tmp
Starting database at /home/msf/.msf4/db...success
******

创建完成后在msf用户目录会生成一个.msf目录里面会有一个database.yml文件,然后,我们这时从msf账户切换到root用户,执行以下操作将原配置文件覆盖。

[msf@msf-18 .msf4]$ ls -a /home/msf/.msf4/
.  ..  bootsnap_cache  data  database.yml  db  history  initial_setup_complete  local  logos  logs  loot  modules  plugins  store
[msf@msf-18 .msf4]$ su root
密码:
[root@msf-18 .msf4]# cp /home/msf/.msf4/database.yml /opt/metasploit-framework/embedded/framework/config/

开始使用,每次启动msf的图案是随机的。

[root@msf-18 .msf4]# msfconsole
Metasploit tip: Writing a custom module? After editing your module, why not try 
the reload command
                                                  
                          ########                  #
                      #################            #
                   ######################         #
                  #########################      #
                ############################
               ##############################
               ###############################
              ###############################
              ##############################
                              #    ########   #
                 ##        ###        ####   ##
                                      ###   ###
                                    ####   ###
               ####          ##########   ####
               #######################   ####
                 ####################   ####
                  ##################  ####
                    ############      ##
                       ########        ###
                      #########        #####
                    ############      ######
                   ########      #########
                     #####       ########
                       ###       #########
                      ######    ############
                     #######################
                     #   #   ###  #   #   ##
                     ########################
                      ##     ##   ##     ##
                            https://metasploit.com


       =[ metasploit v6.3.34-dev-                         ]
+ -- --=[ 2356 exploits - 1227 auxiliary - 413 post       ]
+ -- --=[ 1387 payloads - 46 encoders - 11 nops           ]
+ -- --=[ 9 evasion                                       ]

Metasploit Documentation: https://docs.metasploit.com/

msf6 > 

查看数据库状态,数据库连接成功,退出msf命令是quit

msf6 > db_status
[*] Connected to msf. Connection type: postgresql.

参考文档:

在线安装

云服务器在CentOS7中安装msf工具_centos安装msf_剁椒鱼头没剁椒的博客-CSDN博客

离线安装

Linux CentOS 安装Metasploit 6.1_centos 安装msf_白帽小伞的博客-CSDN博客

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
安装msf的步骤如下: 1. 首先,你需要将msf安装到你的CentOS实验机上。你可以按照网上的教程进行安装,确保教程详细并记录了每一步操作。\[1\] 2. 下载msf安装脚本。你可以使用以下命令下载脚本: ``` curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall chmod 755 msfinstall ``` 3. 执行安装脚本。使用以下命令执行脚本: ``` ./msfinstall ``` 4. 安装过程可能需要一些时间,特别是在下载过程中。如果下载速度较慢,你可以尝试多次执行命令,直到下载完成。\[2\] 5. 安装完成后,msf用户目录下会生成一个名为.msf的文件夹,里面包含一个database.yml文件。你需要将这个文件复制到msf安装目录下。首先切换到root用户,然后使用以下命令复制文件: ``` cp /home/msf/.msf4/database.yml /opt/metasploit-framework/embedded/framework/config/ ``` 这样,你就成功在CentOS安装msf。请确保按照教程的步骤进行操作,以确保安装过程顺利进行。 #### 引用[.reference_title] - *1* *3* [Centos7搭建MSF6(公网服务器搭建msf)](https://blog.csdn.net/weixin_43264067/article/details/129561169)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [云服务器在CentOS7中安装msf工具](https://blog.csdn.net/weixin_44268918/article/details/129771330)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值