From 5f7e62142cffa795a7c2213f04f672a7dbfb7507 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 21 Sep 2014 00:56:00 +0200 Subject: [PATCH] SECURITY: prevent a DoS attack by disabling HTTP access to tools/ scripts. --- tools/inc/cli.php | 57 +---------------------------------------- tools/rebuild.php | 4 --- tools/recount-bumps.php | 4 --- tools/stats.php | 4 --- 4 files changed, 1 insertion(+), 68 deletions(-) diff --git a/tools/inc/cli.php b/tools/inc/cli.php index cff17e34..f3e8824f 100644 --- a/tools/inc/cli.php +++ b/tools/inc/cli.php @@ -13,7 +13,7 @@ error_reporting(E_ALL); set_time_limit(0); $shell_path = getcwd(); -if (isset ($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] != '127.0.0.1' && $_SERVER['REMOTE_ADDR'] != '::1') { +if (php_sapi_name() != 'cli') { die("This script is executable only from Command Line Interface."); } @@ -48,59 +48,4 @@ $mod = Array( 'boards' => Array('*') ); -function get_httpd_privileges() { - global $config, $shell_path, $argv; - - if(php_sapi_name() != 'cli') - die("get_httpd_privileges(): invoked from HTTP client.\n"); - - echo "Dropping priviledges...\n"; - - if(!is_writable('.')) - die("get_httpd_privileges(): web directory is not writable\n"); - - $filename = '.' . md5(rand()) . '.php'; - $inc_filename = '.' . md5(rand()) . '.php'; - - echo "Copying rebuilder to web directory...\n"; - - // replace "/inc/cli.php" with its new filename - passthru("cat " . escapeshellarg($shell_path . '/' . $_SERVER['PHP_SELF']) . " | sed \"s/'\/inc\/cli\.php'/'\/{$inc_filename}'/\" > {$filename}"); - - $inc_header = "