-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
47 lines (36 loc) · 1.29 KB
/
test.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
<?php
if (isset($_POST['header'])) {
$valHeaders = str_replace(PHP_EOL, '', $_POST['header']);
$valHeaders = str_replace(PHP_EOL, '', $valHeaders);
$vals2 = explode("\n", str_replace(["\r\n", "\n\r", "\r"], "\n", $valHeaders));
$vals = [];
$vals[] = 'Content-Security-Policy-Report-Only: ';
$vals[] = "report-uri http://0.0.0.0:8080/report.php;";
$csp = '';
foreach ($vals as $v) {
$csp .= $v;
}
foreach ($vals2 as $v) {
$csp .= $v;
}
header($csp);
}
?>
<!DOCTYPE html>
<html>
<head>
<?php if (isset($_POST['head'])) echo ($_POST['head']); ?>
</head>
<body>
<form method="POST" id="form">
<h3>Header (es: script-src 'none';) </h3>
<textarea rows="10" cols="88" name='header'><?php if (isset($_POST['header'])) echo ($_POST['header']); ?></textarea>
<h3>Tag Head (es: <script nonce='AABBCCDD'>foo(); </script>)</h3>
<textarea rows="10" cols="88" name='head'><?php if (isset($_POST['head'])) echo ($_POST['head']); ?></textarea>
<h3>Tag Body (Some html tag)</h3>
<textarea rows="10" cols="88" name='body'><?php if (isset($_POST['body'])) echo ($_POST['body']); ?></textarea>
<br>
<?php if (isset($_POST['body'])) echo ($_POST['body']); ?>
</form>
</body>
</html>