-
Notifications
You must be signed in to change notification settings - Fork 0
/
security.php
74 lines (60 loc) · 1.83 KB
/
security.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
define( 'DVWA_WEB_PAGE_TO_ROOT', '' );
require_once DVWA_WEB_PAGE_TO_ROOT . 'dvwa/includes/dvwaPage.inc.php';
dvwaPageStartup( array( 'authenticated') );
$page = dvwaPageNewGrab();
$page[ 'title' ] = 'DVWA Security' . $page[ 'title_separator' ].$page[ 'title' ];
$page[ 'page_id' ] = 'security';
$securityHtml = '';
if( isset( $_POST['seclev_submit'] ) ) {
// Anti-CSRF
checkToken( $_REQUEST[ 'user_token' ], $_SESSION[ 'session_token' ], 'security.php' );
$securityLevel = '';
switch( $_POST[ 'security' ] ) {
case 'v1':
$securityLevel = 'v1';
break;
case 'v2':
$securityLevel = 'v2';
break;
case 'v3':
$securityLevel = 'v3';
break;
default:
$securityLevel = 'v4';
break;
}
dvwaSecurityLevelSet( $securityLevel );
dvwaMessagePush( "Security level set to {$securityLevel}" );
dvwa_start_session();
dvwaPageReload();
}
$securityOptionsHtml = '';
$securityLevelHtml = '';
foreach( array( 'v1', 'v2', 'v3', 'v4' ) as $securityLevel ) {
$selected = '';
if( $securityLevel == dvwaSecurityLevelGet() ) {
$selected = ' selected="selected"';
$securityLevelHtml = "<p>Security level is currently: <em>$securityLevel</em>.<p>";
}
$securityOptionsHtml .= "<option value=\"{$securityLevel}\"{$selected}>" . ucfirst($securityLevel) . "</option>";
}
// Anti-CSRF
generateSessionToken();
$page[ 'body' ] .= "
<div class=\"body_padded\">
<h1>DVWA Security <img src=\"" . DVWA_WEB_PAGE_TO_ROOT . "dvwa/images/lock.png\" /></h1>
<br />
<h2>Security Level</h2>
{$securityHtml}
<form action=\"#\" method=\"POST\">
{$securityLevelHtml}
<select name=\"security\">
{$securityOptionsHtml}
</select>
<input type=\"submit\" value=\"Submit\" name=\"seclev_submit\">
" . tokenField() . "
</form>
</div>";
dvwaHtmlEcho( $page );
?>