Docker: запуск Kali Linux и установка Metasploit Framework

Thank you for reading this post, don't forget to subscribe!

Нахо­дим под­хо­дя­щий образ (есть обра­зы Kali Linux и с уже пред­уста­нов­лен­ным Metasploit, тут уста­нов­ка будет выпол­нять­ся вручную):

Запус­ка­ем его:

01 # docker run -t -i kalilinux/kali-linux-docker
02 Unable to find image 'kalilinux/kali-linux-docker:latest' locally
03 latest: Pulling from kalilinux/kali-linux-docker
04 e1bfb89993bf: Pull complete
05 b4be4f2256bf: Pull complete
06 93d580d5b6d4: Pull complete
07 7267bc58e014: Pull complete
08 2c00b1e4f611: Pull complete
09 a5acfcddcae4: Pull complete
10 e3177c843499: Pull complete
11 198c6df71ab3: Already exists
12 Digest: sha256:fcc3e894b9d03b20e37f3e4748dbca798a8e1a50ec7b9ddfa1e9dbd1b208efa1
13 Status: Downloaded newer image for kalilinux/kali-linux-docker:latest
14 root@142c0796e2df:/#

Про­ве­ря­ем вер­сию Kali Linux:

1 # cat /etc/issue
2 Kali GNU/Linux 2.0 n l

 

Обнов­ля­ем кеш apt и пакеты:

1 # apt-get update && apt-get upgrade

Ищем и уста­нав­ли­ва­ем пакет Metasploit Framework:

1 # apt-cache search .*metasploit.*
2 ...
3 metasploit-framework - Framework for exploit development and vulnerability research
4 ...
1 # apt-get install metasploit-framework

 

Пове­ря­ем PostgreSQL, кото­рый явля­ет­ся базой дан­ных для Metasploit Framework:

1 # service postgresql status
2 9.4/main (port 5432): online

 

Про­ве­ря­ем порт:

1 # netstat -anp | grep 5432
2 tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      -
3 tcp6       0      0 ::1:5432                :::*                    LISTEN      -
4 unix  2      [ ACC ]     STREAM     LISTENING     3116031  -                   /var/run/postgresql/.s.PGSQL.5432

 

Ини­ци­а­ли­зи­ру­ем базу:

1 # msfdb init
2 Creating database user 'msf'
3 Enter password for new role:
4 Enter it again:
5 Creating databases 'msf' and 'msf_test'
6 Creating configuration file in /usr/share/metasploit-framework/config/database.yml
7 Creating initial database schema

 

Запус­ка­ем Metasploit:

01 root@142c0796e2df:/# msfconsole
02 [*] The initial module cache will be built in the background, this can take 2-5 minutes...
03
04 # cowsay++
05  ____________
06 < metasploit >
07  ------------
08           ,__,
09           (oo)____
10            (__)    )
11               ||--|| *
12
13
14 Payload caught by AV? Fly under the radar with Dynamic Payloads in
15 Metasploit Pro -- learn more on http://rapid7.com/metasploit
16
17        =[ metasploit v4.11.4-2015090201                   ]
18 + -- --=[ 1476 exploits - 852 auxiliary - 239 post        ]
19 + -- --=[ 432 payloads - 37 encoders - 8 nops             ]
20 + -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ]

 

Про­ве­ря­ем состо­я­ние базы:

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

 

Обнов­ля­ем кеш:

1 msf > db_rebuild_cache
2 [*] Purging and rebuilding the module cache in the background...

 

И про­бу­ем что-то поис­кать, что бы убе­дить­ся, что Metasploit работает:

01 msf > search ssl
02 ...
03 Matching Modules
04 ================
05
06    Name                                                        Disclosure Date  Rank       Description
07    ----                                                        ---------------  ----       -----------
08    auxiliary/dos/http/sonicwall_ssl_format                     2009-05-29       normal     SonicWALL SSL-VPN Format String Vulnerability
09    auxiliary/dos/ssl/dtls_changecipherspec                     2000-04-26       normal     OpenSSL DTLS ChangeCipherSpec Remote DoS
10    auxiliary/dos/ssl/dtls_fragment_overflow                    2014-06-05       normal     OpenSSL DTLS Fragment Buffer Overflow DoS
11    auxiliary/dos/ssl/openssl_aesni                             2013-02-05       normal     OpenSSL TLS 1.1 and 1.2 AES-NI DoS
12    ...

 

Выхо­дим в кон­соль машины-хоста:

1 # exit

 

Сохра­ня­ем образ:

1 # docker ps -a
2 CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS                      PORTS                    NAMES
3 142c0796e2df        kalilinux/kali-linux-docker   "/bin/bash"              36 minutes ago      Exited (0) 20 seconds ago                            silly_kilby
1 # docker commit 142c0796e2df kali_metasp:4.11.4
2 c1bb3814e27fe1c64e8d2887e48b240bce7cb4d247c14ec626bddceb6ab1c422

Про­ве­ря­ем:

1 # docker images
2 REPOSITORY                       TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
3 kali_metasp                      4.11.4              c1bb3814e27f        2 minutes ago       1.43 GB

 

Запус­ка­ем кон­тей­нер с новым образом:

1 # docker run -t -i c1bb3814e27f
2 root@56cb15c46eb0:/#

 

Запус­кам PostgreSQL и захо­дим в кон­соль Metasploit:

1 # service postgresql start
2 [ ok ] Starting PostgreSQL 9.4 database server: main.
1 # msfconsole

Гото­во.