Skip to content

Commit

Permalink
Added platform check for ping command
Browse files Browse the repository at this point in the history
  • Loading branch information
interference-security committed Mar 19, 2018
1 parent a2ba636 commit 01d36bd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion class/CommandExecution.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ public function onOpen(ConnectionInterface $conn)
public function onMessage(ConnectionInterface $from, $msg)
{
echo "Received: command execution : " . $msg . "\n";
$reply_data = shell_exec('ping -c 3 '.$msg);
$reply_data = "Nothing";
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
$reply_data = shell_exec('ping -n 3 '.$msg);
}
else
{
$reply_data = shell_exec('ping -c 3 '.$msg);
}
$from->send($reply_data);
}

Expand Down

0 comments on commit 01d36bd

Please sign in to comment.