Skip to content

Instantly share code, notes, and snippets.

@willitscale
Last active February 7, 2019 17:18
Show Gist options
  • Save willitscale/7f491e3901f583b00913ef176023da3a to your computer and use it in GitHub Desktop.
Save willitscale/7f491e3901f583b00913ef176023da3a to your computer and use it in GitHub Desktop.
Deadly Bug
<?php
if (empty($_POST['hmac']) || empty($_POST['host'])) {
header('HTTP/1.0 400 Bad Request');
exit;
}
$secret = '123';
if (!empty($_POST['nonce'])) {
$secret = hash_hmac('sha256', $_POST['nonce'], $secret);
}
$hmac = hash_hmac('sha256', $_POST['host'], $secret);
if ($hmac !== $_POST['hmac']) {
header('HTTP/1.0 403 Forbidden');
exit;
}
echo exec('host ' . $_POST['host']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment