-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathxss_stored_blog.php
145 lines (115 loc) · 4.01 KB
/
xss_stored_blog.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
<?php
include "includer.php";
$newconn = new ConnectDB($sn,$un,$pss,$db);
function checkInputsql($data){
return sqli_check_1($data);
}
function checkInputxss($data)
{
switch($_COOKIE['security_level'])
{
case "0" :
$data = no_check($data);
break;
case "1" :
$data = xss_check_4($data);
break;
case "2" :
$data = xss_check_3($data);
break;
default :
$data = no_check($data);
break;
}
return $data;
}
$message = "";
if(isset($_POST['entry_add'])){
$entry = $_POST['entry'];
$owner = $_SESSION['login'];
if($entry!=""){
$sql = "INSERT INTO blog (owner, date, entry) VALUES ('" . checkInputsql($owner) . "',now(),'" . checkInputsql($entry) . "')";
$result = $newconn->conn->query($sql);
if(!$result){
die("Error: " . print_r($newconn->conn->errorInfo())."<br><br>");
}
$message = "<font color=\"green\">Your entry was added to our blog!</font>";
}
else
$message = "<font color=\"red\">Please enter some text...</font>";
}
else if(isset($_POST['entry_delete'])){
$sql = "DELETE from blog WHERE owner = '" . checkInputsql($_SESSION["login"]) . "'";
$result = $newconn->conn->query($sql);
if(!$result){
die("Error: " . print_r($newconn->conn->errorInfo())."<br><br>");
}
$message = "<font color=\"green\">All your entries were deleted!</font>";
}
?>
<div class="container">
<h1>XSS(Cross Site Script) - Stored(Blog)</h1>
<form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="POST">
<table>
<tr>
<td colspan="6">
<p><textarea name="entry" id="entry" cols="80" rows="3"></textarea></p>
</td>
</tr>
<tr>
<td width="79" align="left">
<button type="submit" name="blog" value="submit">Submit</button>
</td>
<td width="85" align="center">
<label for="entry_add">Add:</label>
<input type="checkbox" id="entry_add" name="entry_add" value="" checked="on">
</td>
<td width="100" align="center">
<label for="entry_all">Show all:</label>
<input type="checkbox" id="entry_all" name="entry_all" value="">
</td>
<td width="106" align="center">
<label for="entry_delete">Delete:</label>
<input type="checkbox" id="entry_delete" name="entry_delete" value="">
</td>
<td width="7"></td>
<!--<td align="left"><php echo $message;?></td>-->
</tr>
</table>
</form><br>
<table id="table_green">
<tr height="30" bgcolor="green" align="center">
<td width="20">#</td>
<td width="100"><b>Owner</b></td>
<td width="100"><b>Date</b></td>
<td width="400"><b>Entry</b></td>
</tr>
<?php
if(isset($_POST['entry_all']))
$sql = "SELECT * from blog";
else
$sql = "SELECT * from blog WHERE owner='".checkInputsql($_SESSION['login'])."'";
$result = $newconn->conn->query($sql);
if(!$result){
?>
<tr height="50">
<td colspan="4" width="665"><?php die("Error: " . print_r($newconn->conn->errorInfo()));?></td>
</tr>
<?php
}
if($result->rowCount() != 0){
#echo "DATA GELIYOR";
foreach( new RecursiveArrayIterator($result->fetchAll()) as $row){
?>
<tr height="40">
<td align="center"><?php echo $row['id']; ?></td>
<td><?php echo $row['owner']; ?></td>
<td><?php echo $row['date']; ?></td>
<td><?php echo checkInputxss($row['entry']); ?></td>
</tr>
<?php
}
}
?>
</table>
</div>