1 Star 0 Fork 0

PeterTu_2019/DVWA

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
setup.php 3.60 KB
一键复制 编辑 原始数据 按行查看 历史
Robin Wood 提交于 2024-05-07 08:32 . Added PHP version checks.
<?php
define( 'DVWA_WEB_PAGE_TO_ROOT', '' );
require_once DVWA_WEB_PAGE_TO_ROOT . 'dvwa/includes/dvwaPage.inc.php';
dvwaPageStartup( array( ) );
$page = dvwaPageNewGrab();
$page[ 'title' ] = 'Setup' . $page[ 'title_separator' ].$page[ 'title' ];
$page[ 'page_id' ] = 'setup';
if( isset( $_POST[ 'create_db' ] ) ) {
// Anti-CSRF
if (array_key_exists ("session_token", $_SESSION)) {
$session_token = $_SESSION[ 'session_token' ];
} else {
$session_token = "";
}
checkToken( $_REQUEST[ 'user_token' ], $session_token, 'setup.php' );
if( $DBMS == 'MySQL' ) {
include_once DVWA_WEB_PAGE_TO_ROOT . 'dvwa/includes/DBMS/MySQL.php';
}
elseif($DBMS == 'PGSQL') {
// include_once DVWA_WEB_PAGE_TO_ROOT . 'dvwa/includes/DBMS/PGSQL.php';
dvwaMessagePush( 'PostgreSQL is not yet fully supported.' );
dvwaPageReload();
}
else {
dvwaMessagePush( 'ERROR: Invalid database selected. Please review the config file syntax.' );
dvwaPageReload();
}
}
// Anti-CSRF
generateSessionToken();
$database_type_name = "Unknown - The site is probably now broken";
if( $DBMS == 'MySQL' ) {
$database_type_name = "MySQL/MariaDB";
} elseif($DBMS == 'PGSQL') {
$database_type_name = "PostgreSQL";
}
$phpVersionWarning = "";
if (version_compare(phpversion(), '6', '<')) {
$phpVersionWarning = "<span class=\"failure\">Versions of PHP below 7.x are not supported, please upgrade.</span><br /><br />";
} elseif (version_compare(phpversion(), '7.3', '<')) {
$phpVersionWarning = "<span class=\"failure\">Versions of PHP below 7.3 may work but have known problems, please upgrade.</span><br /><br />";
}
$page[ 'body' ] .= "
<div class=\"body_padded\">
<h1>Database Setup <img src=\"" . DVWA_WEB_PAGE_TO_ROOT . "dvwa/images/spanner.png\" /></h1>
<p>Click on the 'Create / Reset Database' button below to create or reset your database.<br />
If you get an error make sure you have the correct user credentials in: <em>" . realpath( getcwd() . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.inc.php" ) . "</em></p>
<p>If the database already exists, <em>it will be cleared and the data will be reset</em>.<br />
You can also use this to reset the administrator credentials (\"<em>admin</em> // <em>password</em>\") at any stage.</p>
<hr />
<br />
<h2>Setup Check</h2>
{$SERVER_NAME}<br />
<br />
{$DVWAOS}<br />
<br />
PHP version: <em>" . phpversion() . "</em><br />
{$phpVersionWarning}
{$phpDisplayErrors}<br />
{$phpDisplayStartupErrors}<br />
{$phpURLInclude}<br/ >
{$phpURLFopen}<br />
{$phpGD}<br />
{$phpMySQL}<br />
{$phpPDO}<br />
<br />
Backend database: <em>{$database_type_name}</em><br />
{$MYSQL_USER}<br />
{$MYSQL_PASS}<br />
{$MYSQL_DB}<br />
{$MYSQL_SERVER}<br />
{$MYSQL_PORT}<br />
<br />
{$DVWARecaptcha}<br />
<br />
{$DVWAUploadsWrite}<br />
{$bakWritable}
<br />
<br />
<i><span class=\"failure\">Status in red</span>, indicate there will be an issue when trying to complete some modules.</i><br />
<br />
If you see disabled on either <i>allow_url_fopen</i> or <i>allow_url_include</i>, set the following in your php.ini file and restart Apache.<br />
<pre><code>allow_url_fopen = On
allow_url_include = On</code></pre>
These are only required for the file inclusion labs so unless you want to play with those, you can ignore them.
<br /><br /><br />
<!-- Create db button -->
<form action=\"#\" method=\"post\">
<input name=\"create_db\" type=\"submit\" value=\"Create / Reset Database\">
" . tokenField() . "
</form>
<br />
<hr />
</div>";
dvwaHtmlEcho( $page );
?>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/petertu_2019/DVWA.git
git@gitee.com:petertu_2019/DVWA.git
petertu_2019
DVWA
DVWA
master

搜索帮助