Skip to content

Commit

Permalink
Removing PHPIDS
Browse files Browse the repository at this point in the history
The main project hasn't been updated for 10 years and the DVWA version
even longer so removing it to tidy the code up a bit.
  • Loading branch information
digininja committed Mar 1, 2023
1 parent c47b6ba commit 45cca57
Show file tree
Hide file tree
Showing 35 changed files with 32 additions and 260 deletions.
6 changes: 1 addition & 5 deletions about.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
define( 'DVWA_WEB_PAGE_TO_ROOT', '' );
require_once DVWA_WEB_PAGE_TO_ROOT . 'dvwa/includes/dvwaPage.inc.php';

dvwaPageStartup( array( 'phpids' ) );
dvwaPageStartup( array( ) );

$page = dvwaPageNewGrab();
$page[ 'title' ] = 'About' . $page[ 'title_separator' ].$page[ 'title' ];
Expand Down Expand Up @@ -38,16 +38,12 @@
<li>Robin Wood: " . dvwaExternalLinkUrlGet( 'https://digi.ninja/','digi.ninja' ) . "</li>
<li>Zhengyang Song: " . dvwaExternalLinkUrlGet( 'https://github.com/songzy12/','songzy12' ) . "</li>
</ul>
<ul>
<li>PHPIDS - Copyright (c) 2007 " . dvwaExternalLinkUrlGet( 'http://github.com/PHPIDS/PHPIDS', 'PHPIDS group' ) . "</li>
</ul>
<h2>License</h2>
<p>Damn Vulnerable Web Application (DVWA) is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.</p>
<p>The PHPIDS library is included, in good faith, with this DVWA distribution. The operation of PHPIDS is provided without support from the DVWA team. It is licensed under <a href=\"" . DVWA_WEB_PAGE_TO_ROOT . "instructions.php?doc=PHPIDS-license\">separate terms</a> to the DVWA code.</p>
<h2>Development</h2>
<p>Everyone is welcome to contribute and help make DVWA as successful as it can be. All contributors can have their name and link (if they wish) placed in the credits section. To contribute pick an Issue from the Project Home to work on or submit a patch to the Issues list.</p>
Expand Down
10 changes: 0 additions & 10 deletions config/config.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ $_DVWA[ 'recaptcha_private_key' ] = '';
# 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';

# Default locale
# Default locale for the help page shown with each session.
# The default is 'en'. You may wish to set this to either 'en' or 'zh'.
Expand Down
35 changes: 1 addition & 34 deletions dvwa/includes/dvwaPage.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

// Include configs
require_once DVWA_WEB_PAGE_TO_ROOT . 'config/config.inc.php';
require_once( 'dvwaPhpIds.inc.php' );

// Declare the $html variable
if( !isset( $html ) ) {
Expand All @@ -27,11 +26,6 @@
} else {
dvwaSecurityLevelSet( 'impossible' );
}

if( $_DVWA[ 'default_phpids_level' ] == 'enabled' )
dvwaPhpIdsEnabledSet( true );
else
dvwaPhpIdsEnabledSet( false );
}

// This will setup the session cookie based on
Expand Down Expand Up @@ -92,32 +86,8 @@ function dvwaPageStartup( $pActions ) {
dvwaRedirect( DVWA_WEB_PAGE_TO_ROOT . 'login.php' );
}
}

if( in_array( 'phpids', $pActions ) ) {
if( dvwaPhpIdsIsEnabled() ) {
dvwaPhpIdsTrap();
}
}
}


function dvwaPhpIdsEnabledSet( $pEnabled ) {
$dvwaSession =& dvwaSessionGrab();
if( $pEnabled ) {
$dvwaSession[ 'php_ids' ] = 'enabled';
}
else {
unset( $dvwaSession[ 'php_ids' ] );
}
}


function dvwaPhpIdsIsEnabled() {
$dvwaSession =& dvwaSessionGrab();
return isset( $dvwaSession[ 'php_ids' ] );
}


function dvwaLogin( $pUsername ) {
$dvwaSession =& dvwaSessionGrab();
$dvwaSession[ 'username' ] = $pUsername;
Expand Down Expand Up @@ -324,7 +294,6 @@ function dvwaHtmlEcho( $pPage ) {
}
// -- END (security cookie)

$phpIdsHtml = '<em>PHPIDS:</em> ' . ( dvwaPhpIdsIsEnabled() ? 'enabled' : 'disabled' );
$userInfoHtml = '<em>Username:</em> ' . ( dvwaCurrentUser() );
$securityLevelHtml = "<em>Security Level:</em> {$securityLevelHtml}";
$localeHtml = '<em>Locale:</em> ' . ( dvwaLocaleGet() );
Expand All @@ -338,7 +307,7 @@ function dvwaHtmlEcho( $pPage ) {

$systemInfoHtml = "";
if( dvwaIsLoggedIn() )
$systemInfoHtml = "<div align=\"left\">{$userInfoHtml}<br />{$securityLevelHtml}<br />{$localeHtml}<br />{$phpIdsHtml}<br />{$sqliDbHtml}</div>";
$systemInfoHtml = "<div align=\"left\">{$userInfoHtml}<br />{$securityLevelHtml}<br />{$localeHtml}<br />{$sqliDbHtml}</div>";
if( $pPage[ 'source_button' ] ) {
$systemInfoHtml = dvwaButtonSourceHtmlGet( $pPage[ 'source_button' ] ) . " $systemInfoHtml";
}
Expand Down Expand Up @@ -636,7 +605,6 @@ function tokenField() { # Return a field for the (CSRF) token

// Setup Functions --
$PHPUploadPath = realpath( getcwd() . DIRECTORY_SEPARATOR . DVWA_WEB_PAGE_TO_ROOT . "hackable" . DIRECTORY_SEPARATOR . "uploads" ) . DIRECTORY_SEPARATOR;
$PHPIDSPath = realpath( getcwd() . DIRECTORY_SEPARATOR . DVWA_WEB_PAGE_TO_ROOT . "external" . DIRECTORY_SEPARATOR . "phpids" . DIRECTORY_SEPARATOR . dvwaPhpIdsVersionGet() . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "IDS" . DIRECTORY_SEPARATOR . "tmp" . DIRECTORY_SEPARATOR . "phpids_log.txt" );
$PHPCONFIGPath = realpath( getcwd() . DIRECTORY_SEPARATOR . DVWA_WEB_PAGE_TO_ROOT . "config");


Expand All @@ -652,7 +620,6 @@ function tokenField() { # Return a field for the (CSRF) token

$DVWAUploadsWrite = '[User: ' . get_current_user() . '] Writable folder ' . $PHPUploadPath . ': <span class="' . ( is_writable( $PHPUploadPath ) ? 'success">Yes' : 'failure">No' ) . '</span>'; // File Upload
$bakWritable = '[User: ' . get_current_user() . '] Writable folder ' . $PHPCONFIGPath . ': <span class="' . ( is_writable( $PHPCONFIGPath ) ? 'success">Yes' : 'failure">No' ) . '</span>'; // config.php.bak check // File Upload
$DVWAPHPWrite = '[User: ' . get_current_user() . '] Writable file ' . $PHPIDSPath . ': <span class="' . ( is_writable( $PHPIDSPath ) ? 'success">Yes' : 'failure">No' ) . '</span>'; // PHPIDS

$DVWAOS = 'Operating system: <em>' . ( strtoupper( substr (PHP_OS, 0, 3)) === 'WIN' ? 'Windows' : '*nix' ) . '</em>';
$SERVER_NAME = 'Web Server SERVER_NAME: <em>' . $_SERVER[ 'SERVER_NAME' ] . '</em>'; // CSRF
Expand Down
101 changes: 0 additions & 101 deletions dvwa/includes/dvwaPhpIds.inc.php

This file was deleted.

32 changes: 0 additions & 32 deletions ids_log.php

This file was deleted.

3 changes: 1 addition & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
define( 'DVWA_WEB_PAGE_TO_ROOT', '' );
require_once DVWA_WEB_PAGE_TO_ROOT . 'dvwa/includes/dvwaPage.inc.php';

dvwaPageStartup( array( 'authenticated', 'phpids' ) );
dvwaPageStartup( array( 'authenticated' ) );

$page = dvwaPageNewGrab();
$page[ 'title' ] = 'Welcome' . $page[ 'title_separator' ].$page[ 'title' ];
Expand All @@ -20,7 +20,6 @@
<h2>General Instructions</h2>
<p>It is up to the user how they approach DVWA. Either by working through every module at a fixed level, or selecting any module and working up to reach the highest level they can before moving onto the next one. There is not a fixed object to complete a module; however users should feel that they have successfully exploited the system as best as they possible could by using that particular vulnerability.</p>
<p>Please note, there are <em>both documented and undocumented vulnerability</em> with this software. This is intentional. You are encouraged to try and discover as many issues as possible.</p>
<p>DVWA also includes a Web Application Firewall (WAF), PHPIDS, which can be enabled at any stage to further increase the difficulty. This will demonstrate how adding another layer of security may block certain malicious actions. Note, there are also various public methods at bypassing these protections (so this can be seen as an extension for more advanced users)!</p>
<p>There is a help button at the bottom of each page, which allows you to view hints & tips for that vulnerability. There are also additional links for further background reading, which relates to that security issue.</p>
<hr />
<br />
Expand Down
3 changes: 1 addition & 2 deletions instructions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require_once DVWA_WEB_PAGE_TO_ROOT . 'dvwa/includes/dvwaPage.inc.php';
require_once DVWA_WEB_PAGE_TO_ROOT . 'dvwa/includes/Parsedown.php';

dvwaPageStartup( array( 'phpids' ) );
dvwaPageStartup( array( ) );

$page = dvwaPageNewGrab();
$page[ 'title' ] = 'Instructions' . $page[ 'title_separator' ].$page[ 'title' ];
Expand All @@ -15,7 +15,6 @@
'PDF' => array( 'type' => 'html' ,'legend' => 'PDF Guide', 'file' => 'docs/pdf.html' ),
'changelog' => array( 'type' => 'markdown', 'legend' => 'Change Log', 'file' => 'CHANGELOG.md' ),
'copying' => array( 'type' => 'markdown', 'legend' => 'Copying', 'file' => 'COPYING.txt' ),
'PHPIDS-license' => array( 'type' => 'markdown', 'legend' => 'PHPIDS License', 'file' => DVWA_WEB_PAGE_TO_PHPIDS . 'LICENSE' ),
);

$selectedDocId = isset( $_GET[ 'doc' ] ) ? $_GET[ 'doc' ] : '';
Expand Down
2 changes: 1 addition & 1 deletion login.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
define( 'DVWA_WEB_PAGE_TO_ROOT', '' );
require_once DVWA_WEB_PAGE_TO_ROOT . 'dvwa/includes/dvwaPage.inc.php';

dvwaPageStartup( array( 'phpids' ) );
dvwaPageStartup( array( ) );

dvwaDatabaseConnect();

Expand Down
2 changes: 1 addition & 1 deletion logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
define( 'DVWA_WEB_PAGE_TO_ROOT', '' );
require_once DVWA_WEB_PAGE_TO_ROOT . 'dvwa/includes/dvwaPage.inc.php';

dvwaPageStartup( array( 'phpids' ) );
dvwaPageStartup( array( ) );

if( !dvwaIsLoggedIn() ) { // The user shouldn't even be on this page
// dvwaMessagePush( "You were not logged in" );
Expand Down
2 changes: 1 addition & 1 deletion phpinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
define( 'DVWA_WEB_PAGE_TO_ROOT', '' );
require_once DVWA_WEB_PAGE_TO_ROOT . 'dvwa/includes/dvwaPage.inc.php';

dvwaPageStartup( array( 'authenticated', 'phpids' ) );
dvwaPageStartup( array( 'authenticated') );

phpinfo();

Expand Down
Loading

0 comments on commit 45cca57

Please sign in to comment.