-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathsecondorder_home.php
149 lines (118 loc) · 2.6 KB
/
secondorder_home.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
<!-- Enable debug using ?debug=true" -->
<?php
ob_start();
session_start();
include("db_config.php");
if (!$_SESSION["id"]){
header('Location:Login1.php?msg=1');
}
ini_set('display_errors', 1);
?>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Second Order Home - SQL Injection Training App</title>
<link href="./css/htmlstyles.css" rel="stylesheet">
</head>
<body>
<div class="container-narrow">
<div class="jumbotron">
<p class="lead" style="color:white">
Second Order SQL Injection example - Home</a>
</p>
</div>
<?php
$q = "Select * from users where id = ".$_SESSION["id"];
if (isset($_GET['debug']))
{
if ($_GET['debug']=="true")
{
echo "<pre>".$q."</pre><br /><br />";
}
}
$result = mysqli_query($con,$q);
if (!$result)
{
die("".mysqli_error($con));
}
$row = mysqli_fetch_array($result);
if ($row){
$_SESSION["username"] = $row[1];
$_SESSION["name"] = $row[3];
$_SESSION["descr"] = $row[4];
}
?>
<div class="response">
<p style="color:white">
<table class="response">
<form method="POST" autocomplete="off">
<tr>
<td>
Username:
</td>
<td>
<?php echo $_SESSION["username"]; ?>
</td>
</tr>
<tr>
<td>
Name:
</td>
<td>
<?php echo $_SESSION["name"]; ?>
</td>
</tr>
<tr>
<td>
Description:
</td>
<td>
<?php echo $_SESSION["descr"]; ?>
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
<tr>
<td>
<input type="button" onclick="javascript:window.location.assign('secondorder_changepass.php')" value="Change Password"/>
</td>
</tr>
</table>
</p>
</form>
</div>
<br />
<div class="row marketing">
<div class="col-lg-6">
<?php
//echo md5("pa55w0rd");
if (!empty($_REQUEST['uid'])) {
session_start();
$username = $_REQUEST['uid'];
$pass = $_REQUEST['password'];
$fname = $_REQUEST['name'];
$descr = $_REQUEST['descr'];
$q = "INSERT INTO users (username, password, fname, description) values ('".$username."','".md5($pass)."','".$fname."','".$descr."')" ;
//echo $q;
if (!mysqli_query($con,$q))
{
die('Error: ' . mysqli_error($con));
}
$_SESSION["username"] = $username;
$_SESSION["fname"] = $fname;
ob_clean();
header('Location:searchproducts.php');
}
?>
</div>
</div>
<div class="footer">
<p><h4><a href="index.php">Home</a><h4></p>
</div>
<div class="footer">
<p>Riyaz Walikar | @riyazwalikar | [email protected]</p>
</div>
</div> <!-- /container -->
</body>
</html>