Allora in phpnuke non ho fatto nulla. Questo lo uso per phpBB..
a.php
Codice PHP:
<?php
if (file_exists('secureconfig.php'))
{
echo 'YOU HAVE TO DELETE secureconfig.php';
exit;
}
$sdr = $_SERVER['DOCUMENT_ROOT'];
$sdr = strtoupper(str_replace('\\','/',$sdr));
$dbuser = ECH0('{DBUSER}',$sdr);
$dbpasswd = ECH0('{DBPASSWD}',$sdr);
$table_prefix = ECH0('{TABLE_PREFIX}',$sdr);
function ECH0($str,$key)
{
$letter = -1;
$lenpath = strlen($key);
$str = base64_decode($str);
for ($i = 0; $i < strlen($str); $i++)
{
$letter++;
if ($letter >= $lenpath)
{
$letter = 0;
}
$neword = ord($str{$i})-ord($key{$letter});
if ($neword <= 0)
{
$neword += 256;
}
$newpass .= chr($neword);
}
// echo $newpass;
return $newpass;
}
?>
secureconfig.php
Codice PHP:
<?php
// ENCRYPT YOUR CONFIG.PHP
// http://www.in-my-opinion.org/in-my-opinion-3734.html
echo "<html><body style='font-family:courier new'>";
if (!$aphp = @file_get_contents('a.php'))
{
echo '<br /><br />Sorry, could not read "a.php". Please, correct the problem and try again.';
exit;
}
if (!$handle = @fopen('a.php','w'))
{
echo '<br /><br />Sorry, could not open "a.php" for writing. Please, correct the problem and try again.';
exit;
}
$sdr = $_SERVER['DOCUMENT_ROOT'];
include('config.php');
$sdr = strtoupper(str_replace('\\','/',$sdr));
if (!$sdr)
{
echo "<br />Sorry, you cannot secure your Database Password";
exit;
}
echo '<br />Your Server Document Root is: '.$sdr;
echo '<br />Important: Whenever (in the future) you change this path (for example if you move with your forum to another server) you need to rerun this program';
echo '<br /><br />';
//$sdr = chr(199);
function encode($str,$key)
{
$letter = -1;
$lenpath = strlen($key);
for ($i = 0; $i < strlen($str); $i++)
{
$letter++;
if ($letter >= $lenpath)
{
$letter = 0;
}
$neword = ord($str{$i})+ord($key{$letter});
if ($neword >= 256)
{
$neword -= 256;
}
$newpass .= chr($neword);
}
return base64_encode($newpass);
}
echo "<br />A file called 'a.php' has been created. Now do the following:";
echo "<br />1) Open 'config.php'\n";
echo "<br />2) Replace the 3 lines: ";
echo "<div style='border: 2px solid red'>";
echo ' $dbuser = \''.$dbuser.'\';';
echo '<br /> $dbpasswd = \''.$dbpasswd.'\';';
echo '<br /> $table_prefix = \''.$table_prefix.'\';';
echo "</div>";
echo "<br /> by the following 4 lines:";
$dbpasswd = encode($dbpasswd,$sdr);
$dbuser = encode($dbuser,$sdr);
$table_prefix = encode($table_prefix,$sdr);
echo "<div style='border: 2px solid green'>";
echo ' $dbuser = \''.randPass(strlen($dbuser)).'\';';
echo '<br /> $dbpasswd = \''.randPass(strlen($dbpasswd)).'\';';
echo '<br /> $table_prefix = \''.randPass(strlen($table_prefix)).'_\';';
echo "<br /> include('a.php');";
echo "</div>";
echo "(or any other random sequence of characters)";
echo "<br />";
echo "<br />Now delete the file 'secureconfig.php'!";
$fin[] = '{DBUSER}';
$fin[] = '{DBPASSWD}';
$fin[] = '{TABLE_PREFIX}';
$rep[] = $dbuser;
$rep[] = $dbpasswd;
$rep[] = $table_prefix;
if (@fwrite($handle,str_replace($fin,$rep,$aphp)) === FALSE)
{
echo '<br /><br />Sorry, could not write to "a.php". Please, correct the problem and try again.';
}
fclose($handle);
function randPass($len)
{
for ($i=0; $i < $len; $i++)
{
$r = rand(1,3);
if (($i == 0) && ($r == 1))
{
$r = 3; // No digit as first character
}
switch($r)
{
case 1: $pw .= chr(rand(48,57)); break; //0-9
case 2: $pw .= chr(rand(65,90)); break; //A-Z
case 3: $pw .= chr(rand(97,122)); break; //a-z
}
}
return $pw;
}
echo '</body></html>';
?>