I came across a site where you can do some excercises regarding cyber security.
From what I understand you have to do PHP injection. I looked online for examples but still I could not implement them.
Any help or tips would be appreciated, also if this is not the right place to ask this kind of questions please let me know.
The code:
<body>
<div class="corb-centered corb-php text-center">
<h3>
<a target="_blank" href="/index.php?source">source</a>
</h3>
<h3>
Start here : <a href="/index.php?code=echo 'hello foobar';">Hello foobar</a>
</h3>
<div class="text-left">
<h3>Output : </h3>
<pre><code><?php
if (isset($_GET['code'])) {
$new_func = create_function('', $_GET['code']);
if ($_GET['code'] === "echo 'hello foobar';") {
$new_func();
}
}
?></code></pre>
</div>
</div>
</body>
I've tried everything I know:
ls']); $new_func();//
ls']); $new_func(); print('
ls; $new_func();//
ls''); $new_func();//
...
create_functionis deprecated, as of PHP 7.2.0. This may be the problem (info here). Alternatively, you could useeval()to execute the given query parameter, instead of transforming it to an anonymous function.