### Install Composer Dependencies Source: https://github.com/digininja/dvwa/blob/master/vulnerabilities/api/README.md Run this command in the \/vulnerabilities\/api directory to install necessary PHP packages for OpenAPI generation. Ensure Composer is installed and accessible. ```bash composer.phar install ``` -------------------------------- ### Manually Install DVWA Script Source: https://github.com/digininja/dvwa/blob/master/README.md Steps to manually download, make executable, and run the DVWA installation script. This method allows for script review before execution. ```sh wget https://raw.githubusercontent.com/IamCarron/DVWA-Script/main/Install-DVWA.sh ``` ```sh chmod +x Install-DVWA.sh ``` ```sh sudo ./Install-DVWA.sh ``` -------------------------------- ### MariaDB Service Status Example Source: https://github.com/digininja/dvwa/blob/master/README.md This is an example of the expected output when the MariaDB service is running correctly. The key indicator is 'Active: active (running)'. ```sh ● mariadb.service - MariaDB 10.5.19 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enabled) Active: active (running) since Thu 2024-03-14 16:04:25 GMT; 1 week 5 days ago ``` -------------------------------- ### Install API Module Vendor Files Source: https://github.com/digininja/dvwa/blob/master/README.md Installs vendor files for the API module using Composer. Navigate to the 'vulnerabilities/api' directory before running this command. ```sh composer.phar install ``` -------------------------------- ### Start MySQL/MariaDB Server Source: https://github.com/digininja/dvwa/blob/master/README.md Use this command to start the MySQL/MariaDB database server if it is not running. This is a common solution for 'Can't connect to local MySQL server' errors. ```sh sudo service mysql start ``` -------------------------------- ### Download and Run DVWA Install Script Source: https://github.com/digininja/dvwa/blob/master/README.md This one-liner downloads and executes the DVWA installation script from a trusted source. Use with caution and review the script if you have security concerns. ```sh sudo bash -c "$(curl --fail --show-error --silent --location https://raw.githubusercontent.com/IamCarron/DVWA-Script/main/Install-DVWA.sh)" ``` -------------------------------- ### Copy DVWA Configuration File Source: https://github.com/digininja/dvwa/blob/master/README.zh.md Copy the example configuration file to create your own configuration. This is a necessary step before modifying DVWA settings. ```bash cp config/config.inc.php.dist config/config.inc.php ``` -------------------------------- ### Install DVWA Dependencies on Debian Source: https://github.com/digininja/dvwa/blob/master/README.zh.md Install necessary packages for DVWA on Debian-based systems, including Apache, PHP modules, and MariaDB. ```bash apt update apt install -y apache2 mariadb-server mariadb-client php php-mysqli php-gd libapache2-mod-php ``` -------------------------------- ### Verify Docker and Docker Compose Installation Source: https://github.com/digininja/dvwa/blob/master/README.md Check if Docker and Docker Compose are installed and accessible by running their version commands. This is a prerequisite for using Docker to set up DVWA. ```text >>> docker version Client: [...] Version: 23.0.5 [...] Server: Docker Desktop 4.19.0 (106363) Engine: [...] Version: 23.0.5 [...] >>> docker compose version Docker Compose version v2.17.3 ``` -------------------------------- ### Start MySQL Server Source: https://github.com/digininja/dvwa/blob/master/README.pt.md If you encounter 'Can't connect to local MySQL server' errors, the database server might not be running. Use this command to start the MySQL service. ```bash sudo service mysql start ``` -------------------------------- ### Configure DVWA with Environment Variables Source: https://github.com/digininja/dvwa/blob/master/README.md Sets DVWA configuration options using environment variables, useful for Docker or Kubernetes deployments. This example sets the default security level to 'low'. ```yml environment: - DB_SERVER=db - DEFAULT_SECURITY_LEVEL=low ``` -------------------------------- ### Run DVWA with Docker Compose Source: https://github.com/digininja/dvwa/blob/master/README.md Command to start DVWA containers using Docker Compose. DVWA will be accessible at http://localhost:4280. ```sh docker compose up -d ``` -------------------------------- ### Configure DVWA for SQLite3 Source: https://github.com/digininja/dvwa/blob/master/README.md To switch the SQLi testing to use SQLite3 instead of MariaDB/MySQL, edit the DVWA configuration file and add or modify these lines. Ensure the 'php-sqlite3' package is installed and enabled. ```php $_DVWA["SQLI_DB"] = "sqlite"; $_DVWA["SQLITE_DB"] = "sqli.db"; ``` -------------------------------- ### DVWA Database Configuration Source: https://github.com/digininja/dvwa/blob/master/README.zh.md Default database connection settings for DVWA. Ensure these match your database setup. ```php $\_DVWA[ 'db_server'] = '127.0.0.1'; $\-DVWA[ 'db_port'] = '3306'; $\-DVWA[ 'db_user' ] = 'dvwa'; $\-DVWA[ 'db_password' ] = 'p@ssw0rd'; $\-DVWA[ 'db_database' ] = 'dvwa'; ``` -------------------------------- ### DVWA Database Server Configuration Source: https://github.com/digininja/dvwa/blob/master/README.md This line in the DVWA configuration file specifies the IP address or hostname of the database server. Ensure this is correct for your setup. ```php $_DVWA[ 'db_server' ] = '127.0.0.1'; ``` -------------------------------- ### Default DVWA Database Credentials Source: https://github.com/digininja/dvwa/blob/master/README.md Specifies the default database connection parameters used by DVWA. Ensure these match your database setup. ```php $_DVWA[ 'db_server'] = '127.0.0.1'; $_DVWA[ 'db_port'] = '3306'; $_DVWA[ 'db_user' ] = 'dvwa'; $_DVWA[ 'db_password' ] = 'p@ssw0rd'; $_DVWA[ 'db_database' ] = 'dvwa'; ``` -------------------------------- ### MariaDB Docker Memory Pressure Warning Source: https://github.com/digininja/dvwa/blob/master/README.md This warning indicates that the MariaDB Docker container may not start due to insufficient host memory or issues with cgroup memory pressure files. It suggests increasing host memory or configuring volume mounts. ```text [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.15+maria~ubu2204 started. [Warn] [Entrypoint]: /sys/fs/cgroup///memory.pressure not writable, functionality unavailable to MariaDB ``` -------------------------------- ### Disable DVWA Auto-Start with Docker Source: https://github.com/digininja/dvwa/blob/master/README.md To prevent DVWA from starting automatically when Docker runs, comment out or delete the 'restart: unless-stopped' lines in the 'compose.yml' file. Alternatively, use 'docker compose stop' or 'docker compose down'. ```yaml restart: unless-stopped ``` -------------------------------- ### Change DVWA Docker Port Binding Source: https://github.com/digininja/dvwa/blob/master/README.md Modify the port binding in the 'compose.yml' file to run DVWA on a different port. The example shows changing the host port from 4280 to 8806. For network access, remove '127.0.0.1:' or use a LAN IP. ```yaml ports: - 127.0.0.1:4280:80 ``` ```yaml ports: - 127.0.0.1:8806:80 ``` -------------------------------- ### Test Database Login from Command Line Source: https://github.com/digininja/dvwa/blob/master/README.md Verify database user credentials by attempting to log in directly from the command line. This helps isolate whether the issue is with the credentials themselves or the DVWA configuration. ```sh mysql -u dvwa -pp@ssw0rd -D dvwa ``` -------------------------------- ### Create MariaDB Database and User Source: https://github.com/digininja/dvwa/blob/master/README.md Commands to create a new database, user, and grant privileges for DVWA in MariaDB. This is necessary if you are not using the root user or if MariaDB is the default. ```mariadb MariaDB [(none)]> create database dvwa; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> create user dvwa@localhost identified by 'p@ssw0rd'; Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> grant all on dvwa.* to dvwa@localhost; Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) ``` -------------------------------- ### Allow HTTPD to Connect to Database on CentOS Source: https://github.com/digininja/dvwa/blob/master/README.md This command adjusts SELinux settings to permit the Apache web server (httpd) to establish connections to the database. Use this on CentOS systems if SELinux is causing connection issues. ```sh setsebool -P httpd_can_network_connect_db 1 ``` -------------------------------- ### Run Pytest Tests Source: https://github.com/digininja/dvwa/blob/master/tests/README.md Execute all tests in the project using pytest. Ensure you are in the document root directory. ```bash python3 -m pytest -s ``` -------------------------------- ### Enable Apache Rewrite Module Source: https://github.com/digininja/dvwa/blob/master/README.md Enables the 'mod_rewrite' Apache module, which is required for the API lab functionality. After enabling, Apache needs to be restarted. ```sh a2enmod rewrite ``` -------------------------------- ### Serve Local Files with Docker Compose Source: https://github.com/digininja/dvwa/blob/master/README.md Uncomment the volumes section in compose.yml to enable local file serving for development. This allows changes to local files to reflect in the container without rebuilding. ```yaml # volumes: # - ./:/var/www/html ``` -------------------------------- ### Database Error: Access denied for user Source: https://github.com/digininja/dvwa/blob/master/README.md This error indicates that the provided username or password in the DVWA configuration file does not match the database credentials. ```mariadb Database Error #1045: Access denied for user 'notdvwa'@'localhost' (using password: YES). ``` ```mariadb SQL: Access denied for user 'dvwa'@'localhost' to database 'notdvwa' ``` ```mariadb ERROR 1045 (28000): Access denied for user 'dvwa'@'localhost' (using password: YES) ``` ```mariadb ERROR 1044 (42000): Access denied for user 'dvwa'@'localhost' to database 'dvwa' ``` -------------------------------- ### Configure MariaDB Docker Compose for Memory Pressure Source: https://github.com/digininja/dvwa/blob/master/README.md This configuration snippet for a `compose.yml` file mounts the host's memory pressure cgroup file into the container. This can resolve startup issues related to memory management in Dockerized MariaDB. ```yaml - /sys/fs/cgroup/memory.pressure:/sys/fs/cgroup/memory.pressure ``` -------------------------------- ### Test MySQL User Login from Terminal Source: https://github.com/digininja/dvwa/blob/master/README.pt.md Verify if the database user and password are correct by attempting to log in directly via the MySQL terminal. Ensure there is no space after the '-p' flag. ```bash mysql -u dvwa -pp@ssw0rd -D dvwa ``` -------------------------------- ### Successful MariaDB Login Confirmation Source: https://github.com/digininja/dvwa/blob/master/README.md This output confirms that the provided username and password are correct and the user can successfully connect to the MariaDB server. ```mariadb Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 14 Server version: 10.3.22-MariaDB-0ubuntu0.19.10.1 Ubuntu 19.10 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [dvwa]> ``` -------------------------------- ### Clone DVWA Repository Source: https://github.com/digininja/dvwa/blob/master/README.zh.md Use this command to download the latest source code of DVWA from its official GitHub repository. ```bash git clone https://github.com/digininja/DVWA.git ``` -------------------------------- ### Create MariaDB Database and User for DVWA Source: https://github.com/digininja/dvwa/blob/master/README.zh.md SQL commands to create a new database and user for DVWA in MariaDB, granting necessary privileges. This is required if you are not using the MySQL root user. ```mysql mysql> create database dvwa; Query OK, 1 row affected (0.00 sec) mysql> create user dvwa@localhost identified by 'p@ssw0rd'; Query OK, 0 rows affected (0.01 sec) mysql> grant all on dvwa.* to dvwa@localhost; Query OK, 0 rows affected (0.01 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) ``` -------------------------------- ### Display All PHP Error Messages Source: https://github.com/digininja/dvwa/blob/master/README.md Ensure PHP displays all error messages by setting 'display_errors' and 'display_startup_errors' to 'on'. Restart the PHP service or Apache after making changes. ```php display_errors = on ``` ```php display_startup_errors = on ``` -------------------------------- ### Configure PHP for RFI and SQLi Vulnerabilities Source: https://github.com/digininja/dvwa/blob/master/README.zh.md Modify PHP settings to enable remote file inclusion (RFI) and SQL injection (SQLi) vulnerabilities. These settings are often required for specific DVWA challenges. ```ini allow_url_include = on allow_url_fopen = on safe_mode = off magic_quotes_gpc = off display_errors = off ``` -------------------------------- ### Configure Docker Compose for Local Build Source: https://github.com/digininja/dvwa/blob/master/README.md Modify the 'pull_policy' in 'compose.yml' to 'build' to enable building the Docker image from local changes. This is useful when developing DVWA locally. ```yaml pull_policy: build ``` -------------------------------- ### View Last 5 Lines of Apache Logs Source: https://github.com/digininja/dvwa/blob/master/README.md Use this command to view the last five lines of both Apache access and error logs on Debian-based systems. This is useful for debugging. ```sh tail -n 5 /var/log/apache2/access.log /var/log/apache2/error.log ``` -------------------------------- ### SQL Schema for Users and Logging Source: https://github.com/digininja/dvwa/blob/master/vulnerabilities/bac/README.md SQL statements to modify the users table and create tables for access and security logging. These are foundational for implementing and tracking access control and security events. ```sql -- Users table modifications ALTER TABLE users ADD COLUMN role VARCHAR(20) DEFAULT 'user'; ALTER TABLE users ADD COLUMN account_enabled TINYINT(1) DEFAULT 1; -- Access logging CREATE TABLE access_log ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, target_id INT NOT NULL, action VARCHAR(50) NOT NULL, timestamp DATETIME NOT NULL ); -- Security monitoring CREATE TABLE security_log ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, action VARCHAR(50) NOT NULL, target_id VARCHAR(50), timestamp DATETIME NOT NULL, ip_address VARCHAR(45) ); ``` -------------------------------- ### Check MySQL User Authentication Plugin Source: https://github.com/digininja/dvwa/blob/master/README.pt.md Query the 'mysql.user' table to determine the current authentication plugin for a specific user. This helps diagnose 'Unknown authentication method' errors. ```sql select Host,User, plugin from mysql.user where mysql.user.User = 'dvwa'; ``` -------------------------------- ### Configure MySQL Authentication Plugin Source: https://github.com/digininja/dvwa/blob/master/README.pt.md For newer MySQL versions where PHP cannot communicate with the database, modify the MySQL configuration to use 'mysql_native_password'. This requires editing the 'mysqld.cnf' file and restarting the service. ```bash sudo service mysql restart ``` -------------------------------- ### Database Server Not Running Error Source: https://github.com/digininja/dvwa/blob/master/README.md This error indicates that the MySQL/MariaDB server is not running, preventing DVWA from connecting. Ensure the database service is active. ```mariadb ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) ``` -------------------------------- ### Enable Remote File Inclusions in PHP Source: https://github.com/digininja/dvwa/blob/master/README.md Configure PHP to allow Remote File Inclusions (RFI) by setting 'allow_url_include' and 'allow_url_fopen' to 'on'. Restart the PHP service or Apache after making changes. ```php allow_url_include = on ``` ```php allow_url_fopen = on ``` -------------------------------- ### Updated MariaDB Docker Compose Volumes Source: https://github.com/digininja/dvwa/blob/master/README.md This shows a complete `volumes` section in a `compose.yml` file, including the necessary mount for memory pressure handling, alongside the standard MariaDB data volume. ```yaml volumes: - dvwa:/var/lib/mysql - /sys/fs/cgroup/memory.pressure:/sys/fs/cgroup/memory.pressure ``` -------------------------------- ### Restart Apache Service Source: https://github.com/digininja/dvwa/blob/master/README.md Restarts the Apache web server to apply configuration changes, such as enabling new modules. ```sh apachectl restart ``` -------------------------------- ### View DVWA Docker Container Logs Source: https://github.com/digininja/dvwa/blob/master/README.md Access DVWA logs from the terminal by navigating to the DVWA directory and using the 'docker compose logs' command. Logs can be viewed directly or exported to a file. ```bash docker compose logs ``` ```bash docker compose logs > dvwa.log ``` -------------------------------- ### Check MariaDB Service Status Source: https://github.com/digininja/dvwa/blob/master/README.md This command checks the current status of the MariaDB service. Look for 'active (running)' to confirm the server is operational. ```sh systemctl status mariadb.service ``` -------------------------------- ### Set MySQL User Authentication to mysql_native_password Source: https://github.com/digininja/dvwa/blob/master/README.pt.md If the 'caching_sha2_password' plugin is in use and causing issues, alter the user to use 'mysql_native_password'. Replace 'p@ssw0rd' with your actual password. ```sql ALTER USER dvwa@localhost IDENTIFIED WITH mysql_native_password BY 'p@ssw0rd'; ``` -------------------------------- ### Stop MariaDB Service Source: https://github.com/digininja/dvwa/blob/master/README.md Use this command to stop the MariaDB service. This might be necessary for maintenance or troubleshooting before restarting. ```sh sudo systemctl stop mariadb.service ``` -------------------------------- ### URL Test Script Source: https://github.com/digininja/dvwa/blob/master/tests/README.md This script, located in test_url.py, identifies and verifies the liveness of all fully qualified URLs found within PHP scripts. It's useful for detecting dead links in documentation and references. ```python # This test will find all fully qualified URLs mentioned in any PHP script and will check if the URL is still alive. This helps weed out dead links from documentation and references. ``` -------------------------------- ### Alter MySQL User Authentication Method Source: https://github.com/digininja/dvwa/blob/master/README.md Run this SQL command to change the authentication method for a user to `mysql_native_password`, which is often more compatible with older PHP versions. ```sql mysql> ALTER USER dvwa@localhost IDENTIFIED WITH mysql_native_password BY 'p@ssw0rd'; ``` -------------------------------- ### Disable DVWA Authentication Source: https://github.com/digininja/dvwa/blob/master/README.md Set this configuration to allow tools that do not work well with authentication to be used with DVWA. Ensure the default security level is also set appropriately. ```php $_DVWA[ 'disable_authentication' ] = true; ``` ```php $_DVWA[ 'default_security_level' ] = 'low'; ``` -------------------------------- ### MySQL Authentication Method Error Source: https://github.com/digininja/dvwa/blob/master/README.md This error indicates a mismatch between the MySQL server's authentication plugin and what PHP client expects. It's common with newer MySQL versions. ```text Database Error #2054: The server requested authentication method unknown to the client. ``` -------------------------------- ### Connection Refused Error in DVWA Source: https://github.com/digininja/dvwa/blob/master/README.md A 'Connection refused' error typically means the database server is not running or the IP address in the DVWA configuration is incorrect. Verify the database server's status and configuration. ```php Fatal error: Uncaught mysqli_sql_exception: Connection refused in /var/sites/dvwa/non-secure/htdocs/dvwa/includes/dvwaPage.inc.php:535 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.