본문 바로가기
SECURITY ::/Etc

[bWAPP] 모의해킹 실습 사이트 환경 구축 방법

by bbombi 2024. 4. 29.

 

(윈도우 파워쉘에서 진행함)

 

 

1. wsl 에서 linux 설치

PS C:\WINDOWS\system32> wsl.exe --list --online
다음은 설치할 수 있는 유효한 배포판 목록입니다.
'wsl.exe --install <Distro>'를 사용하여 설치합니다.

NAME                                   FRIENDLY NAME
Ubuntu                                 Ubuntu
Debian                                 Debian GNU/Linux
kali-linux                             Kali Linux Rolling
Ubuntu-18.04                           Ubuntu 18.04 LTS
Ubuntu-20.04                           Ubuntu 20.04 LTS
Ubuntu-22.04                           Ubuntu 22.04 LTS
OracleLinux_7_9                        Oracle Linux 7.9
OracleLinux_8_7                        Oracle Linux 8.7
OracleLinux_9_1                        Oracle Linux 9.1
openSUSE-Leap-15.5                     openSUSE Leap 15.5
SUSE-Linux-Enterprise-Server-15-SP4    SUSE Linux Enterprise Server 15 SP4
SUSE-Linux-Enterprise-15-SP5           SUSE Linux Enterprise 15 SP5
openSUSE-Tumbleweed                    openSUSE Tumbleweed

// 설치 후 ID/PW 설정
PS C:\WINDOWS\system32> wsl.exe --install kali-linux
Kali Linux Rolling이(가) 이미 설치되어 있습니다.
Kali Linux Rolling을(를) 시작하는 중...
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: bibi
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
┏━(Message from Kali developers)
┃
┃ This is a minimal installation of Kali Linux, you likely
┃ want to install supplementary tools. Learn how:
┃ ⇒ https://www.kali.org/docs/troubleshooting/common-minimum-setup/
┃
┗━(Run: “touch ~/.hushlogin” to hide this message)
┌──(bibi㉿LAPTOP-)-[~]
└─$

 

 

 

2. 도커 설치 및 실행

// 저장소 업데이트
──(bibi㉿LAPTOP-)-[~]
└─$ sudo apt-get update

// 도커 설치
┌──(bibi㉿LAPTOP-)-[~]
└─$ sudo apt install docker.io

// 도커 실행
┌──(bibi㉿LAPTOP-)-[~]
└─$ sudo service docker start
Starting Docker: docker.

 

 

 

3. bWAPP 서비스 구축 및 포트 설정

// 도커허브 검색 
// STARS가 높을수록 상위에 위치
┌──(bibi㉿LAPTOP-)-[/mnt/c/WINDOWS/system32]
└─$ sudo docker search bwapp
NAME                            DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
raesene/bwapp                   Instance of the OWASP bWAPP project             50                   [OK]

// raesene/bwapp pull하기
┌──(bibi㉿LAPTOP-)-[/mnt/c/WINDOWS/system32]
└─$ sudo docker pull raesene/bwapp

// port 설정 및 실행
┌──(bibi㉿LAPTOP-)-[/mnt/c/WINDOWS/system32]
└─$ sudo docker run -d -p 82:80 raesene/bwapp
cc20852f65f3e1eded2498eec92dab185238653a5726038fbcca375080f059d0

 

 

 

4. 브라우저 url 창에 localhost:82 로 접근

 

 

 

5. http://localhost:82/install.php 로 접속해서  here 클릭, Database 생성

 

 

 

6. 로그인

-> ID : bee / PW : bug

 

 

 

7. 로그 관리 및 서버 접속  

// bwapp 서비스 열람 (컨테이너아이디 등 정보 확인 가능)
┌──(bibi㉿LAPTOP-)-[/mnt/c/WINDOWS/system32]
└─$ sudo docker ps -a
CONTAINER ID   IMAGE           COMMAND     CREATED         STATUS         PORTS                                         NAMES
cc20852f65f3   raesene/bwapp   "/run.sh"   4 minutes ago   Up 4 minutes   3306/tcp, 0.0.0.0:82->80/tcp, :::82->80/tcp   brave_bohr

// bwapp 서버 접속, bwapp 서버의 log 디렉토리 위치는 /var/log
┌──(bibi㉿LAPTOP-)-[/mnt/c/WINDOWS/system32]
└─$ sudo docker exec -i -t brave_bohr /bin/bash
root@cc20852f65f3:/# cd /var/log
root@cc20852f65f3:/var/log# ls -al
total 396
drwxrwxr-x 1 root  syslog   4096 Feb 15  2016 .
drwxr-xr-x 1 root  root     4096 Feb 15  2016 ..
-rw-r--r-- 1 root  root     9434 Feb 15  2016 alternatives.log
drwxr-x--- 1 root  adm      4096 Feb 15  2016 apache2
drwxr-xr-x 1 root  root     4096 Feb 15  2016 apt
-rw-r--r-- 1 root  root    47816 Jan 19  2016 bootstrap.log
-rw-rw---- 1 root  utmp        0 Jan 19  2016 btmp
-rw-r----- 1 root  adm        31 Jan 19  2016 dmesg
-rw-r--r-- 1 root  root   253776 Feb 15  2016 dpkg.log
-rw-r--r-- 1 root  root     3296 Feb 15  2016 faillog
drwxr-xr-x 2 root  root     4096 Jan 19  2016 fsck
-rw-rw-r-- 1 root  utmp    30076 Feb 15  2016 lastlog
drwxr-s--- 1 mysql adm      4096 Feb 15  2016 mysql
-rw-r----- 1 mysql adm         0 Feb 15  2016 mysql.err
-rw-r----- 1 mysql adm         0 Feb 15  2016 mysql.log
drwxr-xr-x 1 root  root     4096 Apr  8 01:37 supervisor
drwxr-xr-x 2 root  root     4096 Apr 11  2014 upstart
-rw-rw-r-- 1 root  utmp        0 Jan 19  2016 wtmp
root@cc20852f65f3:/var/log#

 

 

 

8. 도커 이미지 확인 및 컨테이너 제거 방법

// 설치된 이미지 열람
┌──(bibi㉿LAPTOP-FPHAO6BM)-[/mnt/c/WINDOWS/system32]
└─$ sudo docker images
REPOSITORY      TAG       IMAGE ID       CREATED       SIZE
raesene/bwapp   latest    8be28fba48ec   8 years ago   441MB

// 컨테이너 중지
┌──(bibi㉿LAPTOP-FPHAO6BM)-[/mnt/c/WINDOWS/system32]
└─$ sudo docker stop cc20852f65f3
cc20852f65f3

// 컨테이너 제거
┌──(bibi㉿LAPTOP-FPHAO6BM)-[/mnt/c/WINDOWS/system32]
└─$ sudo docker rm cc20852f65f3
cc20852f65f3

 

 

 

cf) 실습 완료 후 wsl도 제거하고 싶으면

PS C:\WINDOWS\system32> wsl --unregister kali-linux
등록 취소 중입니다.
작업을 완료했습니다.

 

 

 

 

댓글