From cd30f3b0b90a79930aa39f8d68da5cc247dfadc3 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Fri, 20 Jan 2012 02:37:53 +1100 Subject: prohibit using same anti-bot hashes across different boards/threads --- inc/functions.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index 7412f49f..c968ff69 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1048,9 +1048,16 @@ } } - function createHiddenInputs() { + function createHiddenInputs($extra_salt = Array()) { global $config; + if(!empty($extra_salt)) { + // create a salted hash of the "extra salt" + $extra_salt = implode(':', $extra_salt); + } else { + $extra_salt = ''; + } + $inputs = Array(); shuffle($config['spam']['hidden_input_names']); @@ -1139,7 +1146,7 @@ $hash .= $config['cookies']['salt']; // Use SHA1 for the hash - $hash = sha1($hash); + $hash = sha1($hash . $extra_salt); // Append it to the HTML $content .= ''; @@ -1147,7 +1154,7 @@ return $content; } - function checkSpam() { + function checkSpam($extra_salt = Array()) { global $config; if(!isset($_POST['hash'])) @@ -1155,6 +1162,13 @@ $hash = $_POST['hash']; + if(!empty($extra_salt)) { + // create a salted hash of the "extra salt" + $extra_salt = implode(':', $extra_salt); + } else { + $extra_salt = ''; + } + // Reconsturct the $inputs array $inputs = Array(); @@ -1179,7 +1193,7 @@ $_hash .= $config['cookies']['salt']; // Use SHA1 for the hash - $_hash = sha1($_hash); + $_hash = sha1($_hash . $extra_salt); return $hash != $_hash; } @@ -1197,7 +1211,6 @@ $content['pages'] = $pages; $content['pages'][$page-1]['selected'] = true; $content['btn'] = getPageButtons($content['pages']); - $content['hidden_inputs'] = createHiddenInputs(); file_write($filename, Element('index.html', $content)); if(isset($md5) && $md5 == md5_file($filename)) { @@ -1460,7 +1473,6 @@ 'id' => $id, 'mod' => $mod, 'boardlist' => createBoardlist($mod), - 'hidden_inputs' => $content['hidden_inputs'] = createHiddenInputs(), 'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['uri'] . '/' . $config['file_index']) )); -- cgit v1.3