본문 바로가기

Ryu's Tech

DVWA 설치 [Damn Vulnerable Web Application] 웹 취약점 테스트용

Table of Contents


DVWA 설치 설치를 하려는데 이렇게 하는것이 맞는것인가 의문이 들긴 합니다.
lamp 버전등을 좀 하위버전으로 해야할 것 같기는 한데 일단 전체적인 절차는 동일할 겁니다.

기본 환경구축

OS 설치

CentOS7-1611-minimal 버전 설치 (vmware workstation, 2cpu, 4gb ram)

업데이트 및 wget 설치

하긴 했는데 업데이트를 안하는게 맞을것도 같네요. 취약점 테스트인데 너무 최신으로 올린 건 아닌지 ㅋㅋ 아무튼 일단 쭉 진행합니다.

yum install -y wget
yum update -y

LAMP 설치


yum install -y httpd mariadb-server mariadb php php-mysql
systemctl start mariadb httpd
systemctl enable httpd.service mariadb.service

DB 설정


mysql_secure_installation
아래 순서대로 입력해주면됩니다.

[Enter]
y
[NEW PASSWORD]
[NEW PASSWORD]
y
y
y
y

방화벽 포트 추가


firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

DVWA

다운로드

http://www.dvwa.co.uk/ 접속


압축풀기


yum install -y unzip
unzip master.zip

웹서버 위치로 이동


cd DVWA-master/
mv DVWA-master/* /var/www/html/
mv DVWA-master/.gitignore /var/www/html/
mv DVWA-master/.htaccess /var/www/html/

접속

해당 주소로 접속해보면 config 파일 설정을 해주라고 합니다.

config 파일 설정


cp /var/www/html/config/config.inc.php.dist /var/www/html/config/config.inc.php
먼저 위처럼 파일을 복사한 뒤 config.ini.php 파일을 편집하면 됩니다.  


# If you are having problems connecting to the MySQL database and all of the variables below are correct
# try changing the 'db_server' variable from localhost to 127.0.0.1. Fixes a problem due to sockets.
# Thanks to @digininja for the fix.

# Database management system to use
$DBMS = 'MySQL';
#$DBMS = 'PGSQL'; // Currently disabled

# Database variables
# WARNING: The database specified under db_database WILL BE ENTIRELY DELETED during setup.
# Please use a database dedicated to DVWA.
#
# If you are using MariaDB then you cannot use root, you must use create a dedicated DVWA user.
# See README.md for more information on this.
$_DVWA = array();
$_DVWA[ 'db_server' ] = '127.0.0.1';
$_DVWA[ 'db_database' ] = 'dvwa';
$_DVWA[ 'db_user' ] = 'root';
$_DVWA[ 'db_password' ] = '[PASSWORD]';

# Only used with PostgreSQL/PGSQL database selection.
$_DVWA[ 'db_port '] = '5432';

# ReCAPTCHA settings
# Used for the 'Insecure CAPTCHA' module
# You'll need to generate your own keys at: https://www.google.com/recaptcha/admin/create
$_DVWA[ 'recaptcha_public_key' ] = '';
$_DVWA[ 'recaptcha_private_key' ] = '';

# Default security level
# Default value for the secuirty level with each session.
# The default is 'impossible'. You may wish to set this to either 'low', 'medium', 'high' or impossible'.
$_DVWA[ 'default_security_level' ] = 'impossible';

# Default PHPIDS status
# PHPIDS status with each session.
# The default is 'disabled'. You can set this to be either 'enabled' or 'disabled'.
$_DVWA[ 'default_phpids_level' ] = 'disabled';

# Verbose PHPIDS messages
# Enabling this will show why the WAF blocked the request on the blocked request.
# The default is 'disabled'. You can set this to be either 'true' or 'false'.
$_DVWA[ 'default_phpids_verbose' ] = 'false';


DB 설정

db는 아까 입력한 패스워드만 넣어주시면 됩니다.

$_DVWA[ 'db_password' ] = '[PASSWORD]';

재접속 및 부가 설정

다시 접속해보면 아래와 같이 나오는데 붉은 표시를 수정해서 다 녹색으로 만들어 보겠습니다.

일부 설정 수정 및 php-gd 설치


yum install -y php-gd
sed -i 's/allow_url_include = off/allow_url_include = on/g' /etc/php.ini
chmod 777 /var/www/html/hackable/uploads
chmod 666 /var/www/html/external/phpids/0.6/lib/IDS/tmp/phpids_log.txt
systemctl restart httpd

Recaptcha 설정

아래 사이트로 접속해서 로그인해서 절차대로 진행하면 바로 나옵니다. https://www.google.com/recaptcha/admin/create capcha 얻기

재재접속

DB 생성

위와 같이 나오면 create/reset database 를 누르시면 자동으로 db를 만들고 아래 로그인 화면으로 넘어가게 됩니다.

로그인

admin/password 로 로그인하시면 됩니다.   버전을 좀 더 낮춰서 해봐야겠네요 sql injection도 error log가 화면에 안나오고 둘다 blind 상태로 나오네요.
아무튼 이렇게 DVWA 설치가 끝났네요.