Language: php (GeSHi-highlighted)
<?php
/*
* Copyright (C) 2007 CrYpTiC MauleR <http://www.expertsrt.net/images/cm_email.gif>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/*
Download UPX : http://upx.sourceforge.net/
Copy upx.exe to the Windows system32 folder
NOTE : ONLY run on local/dedicated server and not on critical or shared server.
The recursion and compressing may cause server to respond slowly. Also prior to
running make the following PHP directives higher so script has adequate time and
memory to perform operations without prematurely ending. Values depend on amount
of files to be processed. Following are values I used on my system.
max_execution_time = 3600 ; Maximum execution time of each script, in seconds
memory_limit = 50M ; Maximum amount of memory a script may consume (8MB)
*/
define('COMMANDS', ' --brute '); /* Try It All */
define('DIRECTORY', 'C:/MY_APPLICATIONS');
function recurse($path)
{
$handle = @ dir($path);
if ($handle)
{
while (false !== ($item = $handle->read()))
{
if ('.' !== $item[0])
{
$full = $path . '/' . $item;
if ((is_file($full)) && (preg_match('/\.(dll|exe)$/i', $item)))
{
exec('upx' . COMMANDS . $full);
echo $full . "\n";
ob_flush();
flush();
}
else if (is_dir($full))
{
recurse($full);
}
}
}
$handle->close();
}
}
header('Content-Type: text/plain');
echo "Packing...\n";
recurse(DIRECTORY);
echo 'complete!';
?>