📖 File Reader
<?php
$logfile = '/tmp/ld_preload_diagnose.log';
file_put_contents($logfile, "=== DIAGNOSTIC START ===\n", FILE_APPEND);
// 1. Check sendmail_path
$sendmail_path = ini_get('sendmail_path');
file_put_contents($logfile, "sendmail_path: " . ($sendmail_path ?: 'not set (default)') . "\n", FILE_APPEND);
// 2. Check if /tmp/evil_marker.so exists and permissions
$libpath = '/tmp/evil_marker.so';
if (file_exists($libpath)) {
$perms = fileperms($libpath);
$perms_str = substr(sprintf('%o', $perms), -4);
file_put_contents($logfile, "Library exists: YES, permissions: $perms_str\n", FILE_APPEND);
if (is_readable($libpath)) {
file_put_contents($logfile, "Library is readable by PHP\n", FILE_APPEND);
} else {
file_put_contents($logfile, "Library is NOT readable\n", FILE_APPEND);
}
} else {
file_put_contents($logfile, "Library does NOT exist\n", FILE_APPEND);
}
// 3. Try to call mail() and capture any output/error
$mail_result = @mail('root@localhost', 'Test', 'Body');
if ($mail_result) {
file_put_contents($logfile, "mail() returned TRUE\n", FILE_APPEND);
} else {
file_put_contents($logfile, "mail() returned FALSE\n", FILE_APPEND);
$error = error_get_last();
if ($error) {
file_put_contents($logfile, "mail() error: " . $error['message'] . "\n", FILE_APPEND);
}
}
// 4. Try alternative: error_log with mail destination
$error_log_result = @error_log('test message', 1, 'root@localhost');
if ($error_log_result) {
file_put_contents($logfile, "error_log(mail) returned TRUE\n", FILE_APPEND);
} else {
file_put_contents($logfile, "error_log(mail) returned FALSE\n", FILE_APPEND);
$error = error_get_last();
if ($error) {
file_put_contents($logfile, "error_log error: " . $error['message'] . "\n", FILE_APPEND);
}
}
// 5. Check for common mailer binaries (exists and executable)
$common_mailers = ['/usr/sbin/sendmail', '/usr/lib/sendmail', '/usr/bin/sendmail', '/bin/mail', '/usr/bin/mail'];
foreach ($common_mailers as $mailer) {
if (file_exists($mailer)) {
file_put_contents($logfile, "Mailer found: $mailer\n", FILE_APPEND);
if (is_executable($mailer)) {
file_put_contents($logfile, " - is executable\n", FILE_APPEND);
} else {
file_put_contents($logfile, " - is NOT executable\n", FILE_APPEND);
}
}
}
file_put_contents($logfile, "=== DIAGNOSTIC END ===\n\n", FILE_APPEND);
echo "Diagnostic completed. Check $logfile for details.";
?>