Created
January 24, 2020 23:28
-
-
Save InsiderPhD/69cf3acf91c84123e0a9fbb18e83493e to your computer and use it in GitHub Desktop.
RCE PHP Demo for YT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Katie's Maths</h1> | |
<p>Type in an equation and let me do the hard work!</p> | |
<form method="post" action="code.php"> | |
<input type="text" name="code" value="1+1"> | |
<button type="submit" name="submit">Submit</button> | |
</form> | |
<hr> | |
<h1>Results</h1> | |
<?php | |
if(isset($_POST["code"])) | |
{ | |
// eval allows any PHP code to be executed | |
// the intended output is $math = 1+1; | |
// echo $math | |
eval("\$maths = " . $_POST["code"] . ";"); | |
echo $_POST["code"] . "=" .$maths; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Test</h1> | |
<p>Connection problems? Use this tool to ping our servers!</p> | |
<form action="command.php" method="post"> | |
<select name="cmd"> | |
<option value="ping 8.8.8.8">US West</option> | |
<option value="ping 8.8.4.4">US East</option> | |
<option value="ping 1.1.1.1">Europe</option> | |
</select> | |
<button name="submit" type="submit">Submit</button> | |
</form> | |
<hr> | |
<h1>Results</h1> | |
<?php | |
// this is an example of command injection | |
// Some styling | |
echo "<div style='background-color: black; color: lawngreen; font-family: monospace; padding: 5px;'>"; | |
if(isset($_POST["cmd"])){ | |
$exec = []; | |
// exec allows us to run a command and then save the output to $exec | |
exec($_POST["cmd"], $exec); | |
// $exec is an array with each line as an option | |
foreach ($exec as $line) | |
{ | |
echo "<p>" . $line . "</p>"; | |
} | |
} | |
?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment