diff options
| author | Sebastien Blot | 2017-09-20 10:11:01 +0200 |
|---|---|---|
| committer | Sebastien Blot | 2017-09-20 10:11:01 +0200 |
| commit | 868f96c759b6650d88ff9f4fbc5c048302134248 (patch) | |
| tree | c0de0af318bf77a8959164ef11aeeeb2b7bab294 /src/tests/deny_writable_execution_simulation.phpt | |
Initial import
Diffstat (limited to 'src/tests/deny_writable_execution_simulation.phpt')
| -rw-r--r-- | src/tests/deny_writable_execution_simulation.phpt | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/tests/deny_writable_execution_simulation.phpt b/src/tests/deny_writable_execution_simulation.phpt new file mode 100644 index 0000000..3278be8 --- /dev/null +++ b/src/tests/deny_writable_execution_simulation.phpt | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | --TEST-- | ||
| 2 | Readonly execution attempt (simulation mode) | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php | ||
| 5 | if (!extension_loaded("snuffleupagus")) print "skip"; | ||
| 6 | |||
| 7 | $filename = __DIR__ . '/test.txt'; | ||
| 8 | |||
| 9 | @unlink($filename); | ||
| 10 | |||
| 11 | file_put_contents($filename, 'a'); | ||
| 12 | chmod($filename, 0400); | ||
| 13 | |||
| 14 | if (is_writable($filename)) print "skip";; | ||
| 15 | @unlink($filename); | ||
| 16 | ?> | ||
| 17 | --INI-- | ||
| 18 | sp.configuration_file={PWD}/config/config_disable_writable_simulation.ini | ||
| 19 | --FILE-- | ||
| 20 | <?php | ||
| 21 | $dir = __DIR__; | ||
| 22 | |||
| 23 | // just in case | ||
| 24 | @unlink("$dir/non_writable_file.txt"); | ||
| 25 | @unlink("$dir/writable_file.txt"); | ||
| 26 | |||
| 27 | file_put_contents("$dir/writable_file.txt", '<?php echo "Code execution within a writable file.\n";'); | ||
| 28 | file_put_contents("$dir/non_writable_file.txt", '<?php echo "Code execution within a non-writable file.\n";'); | ||
| 29 | chmod("$dir/writable_file.txt", 0777); | ||
| 30 | chmod("$dir/non_writable_file.txt", 0400); | ||
| 31 | include "$dir/writable_file.txt"; | ||
| 32 | include "$dir/non_writable_file.txt"; | ||
| 33 | ?> | ||
| 34 | --EXPECTF-- | ||
| 35 | [snuffleupagus][0.0.0.0][readonly_exec][notice] Attempted execution of a writable file (%a/writable_file.txt). | ||
| 36 | Code execution within a writable file. | ||
| 37 | Code execution within a non-writable file. | ||
| 38 | --CLEAN-- | ||
| 39 | <?php | ||
| 40 | $dir = __DIR__; | ||
| 41 | chmod("$dir/non_writable_file.txt", 0777); | ||
| 42 | chmod("$dir/writable_file.txt", 0777); | ||
| 43 | unlink("$dir/non_writable_file.txt"); | ||
| 44 | unlink("$dir/writable_file.txt"); | ||
| 45 | ?> \ No newline at end of file | ||
