forked from webpwnized/mutillidae
-
Notifications
You must be signed in to change notification settings - Fork 1
/
user-info.php
executable file
·245 lines (219 loc) · 8.18 KB
/
user-info.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<?php
try{
switch ($_SESSION["security-level"]){
case "0": // This code is insecure
$lEnableHTMLControls = FALSE;
$lFormMethod = "GET";
$lEnableJavaScriptValidation = FALSE;
$lProtectAgainstMethodTampering = FALSE;
$lEncodeOutput = FALSE;
break;
case "1": // This code is insecure
$lEnableHTMLControls = TRUE;
$lFormMethod = "GET";
$lEnableJavaScriptValidation = TRUE;
$lProtectAgainstMethodTampering = FALSE;
$lEncodeOutput = FALSE;
break;
case "2":
case "3":
case "4":
case "5": // This code is fairly secure
$lEnableHTMLControls = TRUE;
$lFormMethod = "POST";
$lEnableJavaScriptValidation = TRUE;
$lProtectAgainstMethodTampering = TRUE;
$lEncodeOutput = TRUE;
break;
}//end switch
$lFormSubmitted = FALSE;
if (isset($_POST["user-info-php-submit-button"]) || isset($_REQUEST["user-info-php-submit-button"])) {
$lFormSubmitted = TRUE;
}// end if
if ($lFormSubmitted){
if ($lProtectAgainstMethodTampering) {
$lUserInfoSubmitButton = $_POST["user-info-php-submit-button"];
$lUsername = $_POST["username"];
$lPassword = $_POST["password"];
}else{
$lUserInfoSubmitButton = $_REQUEST["user-info-php-submit-button"];
$lUsername = $_REQUEST["username"];
$lPassword = $_REQUEST["password"];
}// end if $lProtectAgainstMethodTampering
}//aa end if $lFormSubmitted
} catch (Exception $e) {
echo $CustomErrorHandler->FormatError($e, $lQueryString);
}// end try;
?>
<script type="text/javascript">
<?php
if($lEnableJavaScriptValidation){
echo "var lValidateInput = \"TRUE\"" . PHP_EOL;
}else{
echo "var lValidateInput = \"FALSE\"" . PHP_EOL;
}// end if
?>
function onSubmitOfForm(/*HTMLFormElement*/ theForm){
try{
var lUnsafeCharacters = /[`~!@#$%^&*()-_=+\[\]{}\\|;':",./<>?]/;
if(lValidateInput == "TRUE"){
if (theForm.username.value.length > 15 ||
theForm.password.value.length > 15){
alert('Username too long. We dont want to allow too many characters.\n\nSomeone might have enough room to enter a hack attempt.');
return false;
}// end if
if (theForm.username.value.search(lUnsafeCharacters) > -1 ||
theForm.password.value.search(lUnsafeCharacters) > -1){
alert('Dangerous characters detected. We can\'t allow these. This all powerful blacklist will stop such attempts.\n\nMuch like padlocks, filtering cannot be defeated.\n\nBlacklisting is l33t like l33tspeak.');
return false;
}// end if
}// end if(lValidateInput)
return true;
}catch(e){
alert("Error: " + e.message);
}// end catch
}// end function onSubmitOfForm(/*HTMLFormElement*/ theForm)
</script>
<!-- Bubble hints code -->
<?php
try{
$lReflectedXSSExecutionPointBallonTip = $BubbleHintHandler->getHint("ReflectedXSSExecutionPoint");
$lSQLInjectionPointBallonTip = $BubbleHintHandler->getHint("SQLInjectionPoint");
} catch (Exception $e) {
echo $CustomErrorHandler->FormatError($e, "Error attempting to execute query to fetch bubble hints.");
}// end try
?>
<script type="text/javascript">
$(function() {
$('[ReflectedXSSExecutionPoint]').attr("title", "<?php echo $lReflectedXSSExecutionPointBallonTip; ?>");
$('[ReflectedXSSExecutionPoint]').balloon();
$('[SQLInjectionPoint]').attr("title", "<?php echo $lSQLInjectionPointBallonTip; ?>");
$('[SQLInjectionPoint]').balloon();
});
</script>
<div class="page-title">User Lookup (SQL)</div>
<?php include_once (__ROOT__.'/includes/back-button.inc');?>
<?php include_once (__ROOT__.'/includes/hints/hints-menu-wrapper.inc'); ?>
<span>
<a style="text-decoration: none; cursor: pointer;" href="./webservices/soap/ws-user-account.php">
<img style="vertical-align: middle;" src="./images/ajax_logo-75-79.jpg" height="75px" width="78px" />
<span style="font-weight:bold;">Switch to SOAP Web Service version</span>
</a>
</span>
<span>
<a style="text-decoration: none; cursor: pointer;" href="index.php?page=user-info-xpath.php">
<img style="vertical-align: middle;" src="./images/xml-logo-64-64.png" />
<span style="font-weight:bold;">Switch to XPath version</span>
</a>
</span>
<form action="./index.php?page=user-info.php"
method="<?php echo $lFormMethod; ?>"
enctype="application/x-www-form-urlencoded"
onsubmit="return onSubmitOfForm(this);"
>
<input type="hidden" name="page" value="user-info.php" />
<table style="margin-left:auto; margin-right:auto;">
<tr id="id-bad-cred-tr" style="display: none;">
<td colspan="2" class="error-message">
Authentication Error: Bad user name or password
</td>
</tr>
<tr><td></td></tr>
<tr>
<td colspan="2" class="form-header">Please enter username and password<br/> to view account details</td>
</tr>
<tr><td></td></tr>
<tr>
<td class="label">Name</td>
<td>
<input SQLInjectionPoint="1" type="text" name="username" size="20" autofocus="autofocus"
<?php
if ($lEnableHTMLControls) {
echo('minlength="1" maxlength="20" required="required"');
}// end if
?>
/>
</td>
</tr>
<tr>
<td class="label">Password</td>
<td>
<input SQLInjectionPoint="1" type="password" name="password" size="20"
<?php
if ($lEnableHTMLControls) {
echo('minlength="1" maxlength="20" required="required"');
}// end if
?>
/>
</td>
</tr>
<tr><td></td></tr>
<tr>
<td colspan="2" style="text-align:center;">
<input name="user-info-php-submit-button" class="button" type="submit" value="View Account Details" />
</td>
</tr>
<tr><td></td></tr>
<tr>
<td colspan="2" style="text-align:center; font-style: italic;">
Dont have an account? <a href="?page=register.php">Please register here</a>
</td>
</tr>
</table>
</form>
<?php
if ($lFormSubmitted){
try {
try {
$LogHandler->writeToLog("Recieved request to display user information for: " . $lUsername);
} catch (Exception $e) {
//do nothing
}// end try
$lQueryResult = $SQLQueryHandler->getUserAccount($lUsername, $lPassword);
$lResultsFound = FALSE;
$lRecordsFound = 0;
if (isset($lQueryResult->num_rows)){
if ($lQueryResult->num_rows > 0) {
$lResultsFound = TRUE;
$lRecordsFound = $lQueryResult->num_rows;
}//end if
}//end if
/* Print out table header */
if($lEncodeOutput){
$lUsername = $Encoder->encodeForHTML($lUsername);
}// end if
echo ' <div class="report-header">
Results for "<span ReflectedXSSExecutionPoint="1" style="color:#770000;">'
.$lUsername.
'</span>".'.$lRecordsFound.' records found.
</div>';
/* Print out results */
if ($lResultsFound){
while($row = $lQueryResult->fetch_object()){
try {
$LogHandler->writeToLog("user-info.php: Displayed user-information for: " . $row->username);
} catch (Exception $e) {
// do nothing
}//end try
if(!$lEncodeOutput){
$lUsername = $row->username;
$lPassword = $row->password;
$lSignature = $row->mysignature;
}else{
$lUsername = $Encoder->encodeForHTML($row->username);
$lPassword = $Encoder->encodeForHTML($row->password);
$lSignature = $Encoder->encodeForHTML($row->mysignature);
}// end if
echo "<span style=\"font-weight:bold;\">Username=</span><span ReflectedXSSExecutionPoint=\"1\">{$lUsername}</span><br/>";
echo "<span style=\"font-weight:bold;\">Password=</span><span ReflectedXSSExecutionPoint=\"1\">{$lPassword}</span><br/>";
echo "<span style=\"font-weight:bold;\">Signature=</span><span ReflectedXSSExecutionPoint=\"1\">{$lSignature}</span><br/><br/>";
}// end while
} else {
echo '<script>document.getElementById("id-bad-cred-tr").style.display=""</script>';
}// end if ($lResultsFound)
} catch (Exception $e) {
echo $CustomErrorHandler->FormatError($e, "Error attempting to display user information");
}// end try;
}// end if (isset($_POST))
?>