<?php
if (isset($_GET['ip'])) {
$ip = $_GET['ip'];
if (strpos($ip, " ")) {
die("Spaces not allowed in the IP!");
}
$ip = str_replace("'", "\\'", $ip);
$cmd = "ping -c1 -t1 '$ip'";
if ($_GET['debug']) { echo "$cmd\n"; }
echo shell_exec($cmd);
die();
}
?>
The code above was running on the site. No spaces, no quotes. HMMMM!
Took some time to figure out how bash would bypass \' and accept quotes since without breaking the quotes it would be impossible to run multiple commands here.