/ some_dir /.
/some_dir/php-5.1.6
/some_dir/php-5.2.17
/some_dir/php-5.3.1
/ some_dir / ...
<?php # , . # test.php. define('TEST_DONE_STR', 'TEST DONE'); define('TEST_PATH', dirname(__FILE__)); define('CLI_PATH', 'sapi/cli/php'); # PHP $dirs = array(); foreach(scandir('./') as $item) { if(preg_match("#^php-#", $item) AND is_dir($item)) { if(file_exists($item . "/sapi/cli/php")) $dirs[] = $item; else print "$item - php-cli not found\n"; } } # test.php foreach($dirs as $dir) { $output = array(); exec(TEST_PATH . "/$dir/" . CLI_PATH . " " . TEST_PATH . "/test.php", $output); print "$dir - " . (implode("", $output) == TEST_DONE_STR ? "OK" : "FAILED") . "\n"; }
<?php # , . # run.php. define('TEST_DONE_STR', 'TEST DONE'); # ob_start(); include("/etc/passwd/../passwd"); $result = ob_get_contents(); ob_end_clean(); # if(substr_count($result, 'root:')) print TEST_DONE_STR;
user @ comp: ~ / php $ php run.php
php-4.3.1 - php-cli not found
php-5.2.16 - php-cli not found
php-5.2.17-suhosin - php-cli not found
php-4.3.10 - OK
php-4.4.9 - OK
php-5.0.5 - OK
php-5.1.6 - OK
php-5.1.6-suhosin - FAILED
php-5.2.0 - OK
php-5.2.17 - OK
php-5.2.2 - OK
php-5.2.3 - OK
php-5.2.4 - OK
php-5.2.9 - OK
php-5.3.0 - FAILED
php-5.3.1 - FAILED
php-5.3.10 - FAILED
php-5.3.20 - FAILED
php-5.3.5 - FAILED
Source: https://habr.com/ru/post/169311/
All Articles