Metasploit在ubuntu系统下的安装配置

Metasploit是一款开源的安全漏洞检测工具,可以帮助安全和IT专业人士识别安全性问题,验证漏洞的有效性,并对审计目标的安全性进行评估,提供真正的有效的安全风险评估。

Metasploit目前主要是社区版metasploit framework和企业版 metasploit pro,企业版为linux的bin文件和windows的二进制文件,一键式安装,就不多说,我们主要讲一下metasploit framework在linux平台下的安装。

 Metasploit framework的运行需要必要的运行环境,目前支持的ruby版本是1.9.3-p551,postgresql 9.1以上版本,windows或者linux发行版,这里我们以ubuntu为例,讲解一下如何在ubuntu下安metasploit framework。

 系统环境:Ubuntu 14.04.1 LTS

由于系统需要其他版本的ruby来支持arachni或者wpscan之类的扫描器,需要有不同版本的ruby来支持,这里我们用rbenv来控制ruby的版本及不同的运行环境,ok,废话就不多说了,进入正题

1、安装rbenv

1

exploit@ubuntu:~$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv

#加入用户环境变量

1

2

exploit@ubuntu:~$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc

exploit@ubuntu:~$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc

更新环境变量

1

source ~/.bashrc

查看一下我们的rbenv的设置

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

exploit@ubuntu:~$ type rbenv

rbenv is a function

rbenv ()

{

    local command;

    command="$1";

    if [ "$#" -gt 0 ]; then

        shift;

    fi;

    case "$command" in

        rehash | shell)

            eval "`rbenv "sh-$command" "$@"`"

        ;;

        *)

            command rbenv "$command" "$@"

        ;;

    esac

}

 

安装ruby-build

1

exploit@ubuntu:~$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

 

查看可用的ruby版本

1 exploit@ubuntu:~$ rbenv install -l

 

…………

  1.9.3-p484

  1.9.3-p545

  1.9.3-p547

  1.9.3-p550

  1.9.3-p551

  2.0.0-dev

  2.0.0-preview1

+…………

 

安装合适版本的ruby

 

1 exploit@ubuntu:~$ rbenv install 1.9.3-p551

1

2

3

4

5

6

7

8

Downloading yaml-0.1.6.tar.gz...

-> https://dqw8nmjcqpjn7.cloudfront.net/7da6971b4bd08a986dd2a61353bc422362bd0edcc67d7ebaac68c95f74182749

Installing yaml-0.1.6...

Installed yaml-0.1.6 to /home/exploit/.rbenv/versions/1.9.3-p551

Downloading ruby-1.9.3-p551.tar.gz...

-> https://dqw8nmjcqpjn7.cloudfront.net/bb5be55cd1f49c95bb05b6f587701376b53d310eb1bb7c76fbd445a1c75b51e8

Installing ruby-1.9.3-p551...

Installed ruby-1.9.3-p551 to /home/exploit/.rbenv/versions/1.9.3-p551

# 设置当前使用的ruby版本并将gem的源改为淘宝镜像

1 exploit@ubuntu:~$ rbenv global 1.9.3-p551

 

查看当前的ruby版本

1 exploit@ubuntu:~$ ruby -v

 

ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]

ok,一切没问题

替换gem的更新远源,由于众所周知的原因,gem的源不稳定,还好万能的淘宝,架设了一个国内的镜像源,这里我们不删除官方的源

只增加国内的淘宝源

1 exploit@ubuntu:~$ gem sources -a https://ruby.taobao.org/

 

 

https://ruby.taobao.org/ added to sources

接下来,我们git回来framework的源文件

 

1 exploit@ubuntu:/pentest$ git clone https://github.com/rapid7/metasploit-framework framework3

 

Cloning into 'framework3'...

安装bundler

1 exploit@ubuntu:/pentest/framework3$ gem install bundler

 

1 exploit@ubuntu:/pentest/framework3$ bundle install

 

Fetching gem metadata from https://rubygems.org/………

根据你的网速,时间可能不一样,耐心等待完成。

接下来配置msf的环境变量,这样我们不用每次都在msf安装目录来执行我们的命令。

1 exploit@ubuntu:/pentest/framework3$ sudo -s

 

1 root@ubuntu:/pentest/framework3# for MSF in $(ls msf*); do ln -s /pentest/framework3/$MSF /usr/local/bin/$MSF;done

 

1 root@ubuntu:/pentest/framework3# msfconsole

 

[*] Starting the Metasploit Framework console…

接下来,我们来建立msf的所使用的数据库

安装postgresql数据库

1 root@ubuntu:/pentest/framework3# apt-get install postgresql-server-dev-all

 

设置为开机自启动

创建msf的数据库用户名和密码:

首先切换到postgres用户下

1 root@ubuntu:/pentest/framework3# su postgres

 

创建msf的数据库用户名和密码:

1 postgres@ubuntu:/pentest/framework3$ createuser msf -P -S -R -D

 

创建msf的数据库

1 postgres@ubuntu:/pentest/framework3$ createdb -O msf msf

 

ok,接下来,我们来配置msf的数据库连接信息,切换到一般用户下

1 exploit@ubuntu:/pentest/framework3$ cd config/

 

1 exploit@ubuntu:/pentest/framework3/config$ mv database.yml.example database.yml

 

查看数据库的配置信息:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

# Please only use postgresql bound to a TCP port.

# Only postgresql is supportable for metasploit-framework

# these days. (No SQLite, no MySQL).

#

# To set up a metasploit database, follow the directions hosted at:

# https://fedoraproject.org/wiki/Metasploit_Postgres_Setup (Works on

# essentially any Linux distro, not just Fedora)

development: &pgsql

adapter: postgresql

database: metasploit_framework_development

username: metasploit_framework_development

password: __________________________________

host: localhost

port: 5432

pool: 5

timeout: 5

# You will often want to seperate your databases between dev

# mode and prod mode. Absent a production db, though, defaulting

# to dev is pretty sensible for many developer-users.

production: &production

<<: *pgsql

# Warning: The database defined as "test" will be erased and

# re-generated from your development database when you run "rake".

# Do not set this db to the same as development or production.

#

# Note also, sqlite3 is totally unsupported by Metasploit now.

test:

<<: *pgsql

database: metasploit_framework_test

username: metasploit_framework_test

password: ___________________________

库,所以,我们清除里面的所有信息,重新编辑

database.yml,写入以下信息保存

1

2

3

4

5

6

7

8

9

10

exploit@ubuntu:/pentest/framework3/config$ nano database.yml

production:

    adapter: postgresql

    database: msf

    username: msf

    password: msf

    host: 127.0.0.1

    port: 5432

    pool: 75

    timeout: 5

ok,配置保存,我们运行msfconsole看一下数据库是否正常连接

1 exploit@ubuntu:/pentest/framework3$ msfconsole

 

1 [*] Starting the Metasploit Framework console...NOTICE:  CREATE TABLE will create implicit sequence "hosts_id_seq" for serial column “hosts.id

 

#…………此处省略自动创建数据库过程

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

NOTICE:

 CREATE TABLE / PRIMARY KEY will create implicit index

"metasploit_credential_origin_cracked_passwords_pkey" for table

"metasploit_credential_origin_cracked_passwords"

\[*] The initial module cache will be built in the background, this can take 2-5 minutes...

\

             _---------.

             .' #######   ;."

  .---,.    ;@             @@`;   .---,..

." @@@@@'.,'@@            @@@@@',.'@@@@ ".

'-.@@@@@@@@@@@@@          @@@@@@@@@@@@@ @;

   `.@@@@@@@@@@@@        @@@@@@@@@@@@@@ .'

     "--'.@@@  -.@        @ ,'-   .'--"

          ".@' ; @       @ `.  ;'

            |@@@@ @@@     @    .

             ' @@@ @@   @@    ,

              `.@@@@    @@   .

                ',@@     @   ;           _____________

                 (   3 C    )     /|___ / Metasploit! \

                 ;@'. __*__,."    \|--- \_____________/

                  '(.,...."/

       =[ metasploit v4.11.0-dev [core:4.11.0.pre.dev api:1.0.0]]

+ -- --=[ 1380 exploits - 775 auxiliary - 223 post        ]

+ -- --=[ 349 payloads - 37 encoders - 8 nops             ]

+ -- --=[ Free Metasploit Pro trial: https://r-7.co/trymsp ]

msf >

查看数据库连接信息

 

1 2 msf > db_status  [*] postgresql connected to msf

 

查看其他的功能是否可以正常使用

1

2

3

4

5

6

msf > hosts

Hosts

=====

  

address  mac  name  os_name  os_flavor  os_sp  purpose  info  comments

-------  ---  ----  -------  ---------  -----  -------  ----  ———

ok,到这里我们已经完成了metasploit在ubuntu下的安装过程.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值