Metasploit 설치 및 초기 설정

LinuxBeginner
지금 연습하기

소개

Metasploit 설치 및 초기 설정 실습에 오신 것을 환영합니다. Metasploit Framework 는 원격 대상 시스템에 대한 익스플로잇 코드를 개발, 테스트 및 실행하는 데 사용되는 강력한 오픈 소스 도구입니다. 이는 침투 테스트 및 보안 연구에 가장 널리 사용되는 도구 중 하나입니다.

본 실습에서는 Ubuntu 시스템에 Metasploit 을 설치하고 실행하는 전체 과정을 안내합니다. 시스템 패키지 업데이트부터 시작하여 Metasploit Framework 설치, 필수 PostgreSQL 데이터베이스 구성, 그리고 마지막으로 Metasploit 콘솔 실행까지 진행하게 됩니다. 실습이 끝날 때쯤이면 사용 준비가 완료된 완벽하게 작동하는 Metasploit 환경을 갖추게 될 것입니다.

apt update 및 apt upgrade 를 사용하여 Ubuntu 패키지 업데이트

이 단계에서는 시스템의 패키지 목록을 업데이트하고 오래된 패키지를 업그레이드합니다. 이는 잠재적인 충돌을 방지하는 데 도움이 되도록 최신 보안 패치 및 종속성을 확보하기 위해 새 소프트웨어를 설치하기 전에 수행해야 하는 중요한 첫 번째 단계입니다.

먼저, apt update 명령을 사용하여 저장소에서 패키지 목록을 업데이트합니다. 이 작업은 관리자 권한이 필요하므로 sudo가 필요합니다.

sudo apt update

Ubuntu 소스에서 패키지 목록을 가져오는 출력이 표시됩니다.

Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
...
Fetched 1,589 kB in 2s (924 kB/s)
Reading package lists... Done
Building dependency tree... Done

시스템이 최신 상태가 되었으므로 이제 Metasploit 을 설치할 준비가 되었습니다.

공식 설치 스크립트를 사용하여 Metasploit Framework 설치

이 단계에서는 Rapid7 에서 제공하는 공식 설치 스크립트를 사용하여 Metasploit Framework 를 설치합니다. 이 스크립트는 Metasploit 저장소 (repository) 를 시스템에 추가하고 프레임워크의 최신 버전을 설치합니다.

먼저, 설치 스크립트를 임시 위치로 다운로드합니다:

curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > /tmp/msfinstall

다음으로, 스크립트에 실행 권한을 부여합니다:

chmod 755 /tmp/msfinstall

이제 관리자 권한으로 설치 스크립트를 실행합니다:

sudo /tmp/msfinstall

스크립트는 Metasploit Framework 저장소를 패키지 소스에 추가하고, 패키지 캐시를 업데이트하며, 종속성과 함께 metasploit-framework 패키지를 설치합니다. 다음과 유사한 출력을 보게 될 것입니다:

  % Total    % Received % Xferd  Average Speed   Time    Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6144  100  6144    0     0  34855      0 --:--:-- --:--:-- --:--:-- 34909
Adding metasploit-framework to your repository list..Updating package cache..OK
Checking for and installing update..
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  metasploit-framework
...
Setting up metasploit-framework (6.4.x~...) ...
update-alternatives: using /opt/metasploit-framework/bin/msfconsole to provide /usr/bin/msfconsole (msfconsole) in auto mode
...
Run msfconsole to get started

설치가 완료되면 Metasploit Framework 가 시스템에 설치됩니다.

Metasploit 콘솔 실행 및 초기 설정 완료

마지막 단계에서는 Metasploit 을 처음 실행하여 초기 설정 프로세스를 시작합니다. 여기에는 호스트 데이터, 취약점 및 수집된 증거를 포함하여 프로젝트에 대한 정보를 저장하는 데 Metasploit 이 사용하는 데이터베이스 설정이 포함됩니다.

콘솔을 시작하려면 터미널에 msfconsole을 입력하고 Enter 키를 누르기만 하면 됩니다.

msfconsole

Metasploit 을 처음 실행하면 초기 설정 마법사가 표시됩니다.

 ** Welcome to Metasploit Framework Initial Setup **
    Please answer a few questions to get started.


Would you like to use and setup a new database (recommended)?

계속 진행하려면 yes를 입력하고 Enter 키를 누릅니다.

Would you like to use and setup a new database (recommended)? yes
Running the 'init' command for the database:
Creating database at /home/labex/.msf4/db
Creating db socket file at /tmp
Starting database at /home/labex/.msf4/db...waiting for server to start.... done
server started
success
Creating database users
Writing client authentication configuration file /home/labex/.msf4/db/pg_hba.conf
Stopping database at /home/labex/.msf4/db
Starting database at /home/labex/.msf4/db...waiting for server to start.... done
server started
success
Creating initial database schema
Database initialization successful
Database initialization successful

 ** Metasploit Framework Initial Setup Complete **

설정이 완료되면 익숙한 Metasploit 배너와 프롬프트가 표시됩니다.

Metasploit tip: Display the Framework log using the log command, learn
more with help log

Call trans opt: received. 2-19-98 13:24:18 REC:Loc

     Trace program: running

           wake up, Neo...
        the matrix has you
      follow the white rabbit.

          knock, knock, Neo.

                        (`.         ,-,
                        ` `.    ,;' /
                         `.  ,'/ .'
                          `. X /.'
                .-;--''--.._` ` (
              .'            /   `
             ,           ` '   Q '
             ,         ,   `._    \
          ,.|         '     `-.;_'
          :  . `  ;    `  ` --,.._;
           ' `    ,   )   .'
              `._ ,  '   /_
                 ; ,''-,;' ``-
                  ``-..__``--`

                             https://metasploit.com


       =[ metasploit v6.4.x-dev-                               ]
+ -- --=[ 2,564 exploits - 1,315 auxiliary - 1,680 payloads     ]
+ -- --=[ 431 post - 49 encoders - 13 nops - 9 evasion          ]

Metasploit Documentation: https://docs.metasploit.com/
The Metasploit Framework is a Rapid7 Open Source Project

msf >

데이터베이스가 올바르게 연결되었는지 확인하려면 Metasploit 콘솔 내에서 db_status 명령을 실행합니다.

db_status

예상되는 출력은 다음과 같습니다.

[*] Connected to msf. Connection type: postgresql.

이는 Metasploit 인스턴스가 PostgreSQL 데이터베이스에 성공적으로 연결되었음을 확인합니다. Metasploit 콘솔을 종료하려면 단순히 exit를 입력합니다.

exit

요약

축하합니다! Ubuntu 시스템에 Metasploit Framework 설치 및 초기 설정을 성공적으로 완료했습니다.

이 실습 (lab) 을 통해 다음을 수행하는 방법을 배웠습니다.

  • apt를 사용하여 시스템 패키지를 업데이트하고 업그레이드하는 방법.
  • Rapid7 에서 제공하는 공식 설치 스크립트를 사용하여 Metasploit Framework 를 설치하는 방법.
  • Metasploit 콘솔 (msfconsole) 을 처음 실행하여 초기 데이터베이스 설정을 자동으로 시작하는 방법.
  • Metasploit 콘솔 내에서 데이터베이스 연결을 확인하는 방법.

이제 강력하고 완벽하게 작동하는 침투 테스트 도구를 사용할 수 있게 되었습니다. Metasploit Framework 는 자체 PostgreSQL 데이터베이스 인스턴스로 구성되었으며 사용 준비가 완료되었습니다. 이제 보안 테스트 및 연구를 위한 광범위한 기능을 탐색할 수 있는 보다 고급 실습으로 넘어갈 준비가 되었습니다.