forked from webpwnized/mutillidae
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpassword-generator.php
executable file
·108 lines (95 loc) · 3.34 KB
/
password-generator.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/*
* Vulnerabilities
* Reflected Cross-site Scripting
* JavaScript Injection
* Method Tampering
* DOM-based Cross-site Scripting
*/
try {
$lUsernameForJS = "";
$lPasswordJSMessage = "";
switch ($_SESSION["security-level"]){
case "0": // This code is insecure.
case "1": // This code is insecure.
// Grab inputs insecurely. $_REQUEST allows any input paramter. Not just POST.
if (isset($_REQUEST["username"])){
$lUsernameForJS = $_REQUEST["username"]; // allow javascript and xss injection
}//end if
break;
case "2":
case "3":
case "4":
case "5": // This code is fairly secure
/* Protect against one form of patameter pollution
* by grabbing inputs only from GET parameters. */
if (isset($_GET["username"])){
$lUsernameForJS = $Encoder->encodeForJavaScript($_GET["username"]);
}
break;
}// end switch
if (strlen($lUsernameForJS) > 0) {
$lPasswordJSMessage = "This password is for {$lUsernameForJS}";
}
} catch (Exception $e) {
echo $CustomErrorHandler->FormatError($e, "Input: " . $lUsernameForHTML);
}// end try
?>
<script>
function onSubmitOfGeneratorForm(/*HTMLFormElement*/ theForm){
try{
var lPasswordText = "";
var lPasswordCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_-+=[]{}\|;',./:?";
for( var i=0; i < 15; i++ ){
lPasswordText += lPasswordCharset.charAt(Math.floor(Math.random() * lPasswordCharset.length));
}// end for i
document.getElementById("idPasswordInput").innerHTML = "Password: <span style=\"color:red;border-width:1px;border-color:black;\">" + lPasswordText + "</span>";
document.getElementById("idPasswordTableRow").style.display = "";
return false;
}catch(e){
alert("Error: " + e.message);
}// end catch
}// end function onSubmitOfGeneratorForm(/*HTMLFormElement*/ theForm)
</script>
<div class="page-title">Password Generator</div>
<?php include_once (__SITE_ROOT__.'/includes/back-button.inc');?>
<?php include_once (__SITE_ROOT__.'/includes/hints/hints-menu-wrapper.inc'); ?>
<div id="id-generator-form-div">
<form enctype="application/x-www-form-urlencoded"
id="idGeneratorForm">
<table>
<tr>
<td class="form-header">Password Generator</td>
</tr>
<tr><td></td></tr>
<tr>
<td class="label" style="text-align: center;">
Making strong passwords is important.
<br/>
Click the button below to generate a password.
</td>
</tr>
<tr><td></td></tr>
<tr style="text-align: center;">
<td id="idUsernameInput" class="label"></td>
</tr>
<tr id="idPasswordTableRow" style="display: none;">
<td class="label" id="idPasswordInput"></td>
</tr>
<tr><td></td></tr>
<tr>
<td style="text-align:center;">
<input name="password-generator-php-submit-button" autofocus="autofocus" class="button" type="button" value="Generate Password" onclick="onSubmitOfGeneratorForm(this.form);" />
</td>
</tr>
<tr><td></td></tr>
</table>
</form>
</div>
<script>
try{
document.getElementById("idUsernameInput").innerHTML = "<?php echo $lPasswordJSMessage; ?>";
}catch(e){
alert("Error: " + e.message);
}// end catch
</script>