سنبدا باعاده بناء الاباتشي عبر سكربت بالطريقة الصحيحة.
كود:
wget http://dolphin4h.com/ssh/DL-apache.sh
sh DL-apache.sh
زي مانشوف الصوره y انتر وننتظر لين مايخلص اعاده بناء الاباتشي ..
=============================================
نركب جدار ناري الـ CSF
لمعرفة عمل هاذا الجدار من هنآ
كود:
http://configserver.com/الان نركب الجدار بهاذي الخطوات ..
كود:
wget http://www.dolphin4h.com/ssh/csf.sh
chmod +x csf.sh
sh csf.sh
جيد جدا بعد تركيب جدار الـ CSF نركب LES لحماية ملفات النظام
اتبع التالي
كود:
cd /usr/src
wget http://www.r-fx.ca/downloads/les-current.tar.gz
tar -zxvf les-current.tar.gz
cd les*
sh install.sh
/usr/local/sbin/les -ea 1
تم تركيب LES جيد جدا نركب الان ELS للحماية من الروت كيت واشياء اخرى ..
يمكنكم القراء عنة هنآ
كود:
http://servermonkeys.comتمام نركبة..
كود:
wget --output-document=installer.sh http://servermonkeys.com/projects/els/installer.sh; chmod +x installer.sh; sh installer.shتمام الان نمنع الروت كيت .. ننفذ
كود:
els --chkrootkitونفحص السيرفر من الروت كيتس
كود:
els --chkrootkitcronالان ننفذ
كود PHP:
els --rkhuntercron و
كود:
els --chmodfilesو
كود:
els --disabletelnetو
كود:
els --securepartitions=============================================
حمايه الـ PHP وهي آهم شيء في آلسيرفر
نحرر الملف ..
كود:
pico /usr/local/lib/php.iniفي بدايه الملف نضع ..
كود:
reveal_php 0نبحث عن السيف مود ونحوله من Off الى On
كود:
safe_modeزي ماهو موضح في الصوره
زي ماهو موضح نسوي حسب الاعدادات لكل قيمة
كود:
allow_url_fopen = off&
كود:
expose_php = off&
كود:
enable_dl = off&
كود:
register_globals = off&
كود:
display_errors = Off&
كود:
max_execution_time = 3600تمام الان نضع دوال ممنوعة نبحث عن disable_functions
ونضع هاذي الدوال جنب =
كود:
dl,escapeshellarg,escapeshellcmd,exec,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,system,pcntl_exec,getrusage,chown,chgrp,closelog,openlog,syslog,define_syslog_variables,php_ini_scanned_files,php_ini_loaded_file,ini_get_all,get_cfg_var,getservbyname,getservbyportكما هو موضح في الصوره
=============================================
بحمد الله تم الانتهاء من حمايه الـ PHP الان نضبط الصلاحيات نفذ :
كود:
chmod 700 /usr/bin/perl
chown root:root /usr/bin/perl
chmod 700 /bin/dmesg
chmod 700 /bin/rpm
c
chmod 700 /bin/mount
te
chmod 700 /usr/bin/t
hmod 700 /usr/bin/wr
ialk
chmod 700 /usr/bin/ipcrm
700 /usr/bin/free
chmod
chmod 700 /usr/bin/ipcs
chmod
700 /usr/bin/locate
chmod 700 /usr/bin/wall
chmod 700 /sbin/ifconfig
chmod 700 /usr/bin/finger
chmod 700 /sbin/arp
in/tcpdump
chmod 700 /usr/bi
chmod 700 /usr/sbin/repquota
chmod 700 /usr/s
bn/wget
chmod 700 /usr/bin/lynx
chmod 700 /usr/lib/bcc/bcc-cc1
/bin/cc
chmod 700 /usr/bi
chmod 700 /usr/bin/perlcc
chmod 700 /usr/bin/bcc
chmod 700 /us
rn/gcc
chmod 700 /usr/bin/who
chmod 700 /usr/bin/w
chmod 711 /
chmod 711 /home
ar/log
chmod 7
chmod 711 /etc
chmod 711 /var
chmod 711 /usr/etc
chmod 711 /usr/local/etc
chmod 711 /
v11 /sbin
chmod 711 /usr/sbin
chmod 711 /usr/local/sbin
chattr +i /usr/bin/cmp
r +i /usr/bin/find
chat
chattr +i /usr/bin/diff
chattr +i /usr/bin/diff3
chattr +i /usr/bin/sdiff
chat
ttr +i /usr/bin/xargs
chattr +i /usr/bin/eu-addr2line
chattr +i /usr/bin/eu-ar
u-findtextrel
chattr +i /usr
chattr +i /usr/bin/eu-elfcmp
chattr +i /usr/bin/eu-elflint
chattr +i /usr/bin/
e/bin/eu-make-debug-archive
chattr +i /usr/bin/eu-nm
chattr +i /usr/bin/eu-objdump
ze
chattr +i /usr/bin/eu-str
chattr +i /usr/bin/eu-ranlib
chattr +i /usr/bin/eu-readelf
chattr +i /usr/bin/eu-s
iings
chattr +i /usr/bin/eu-strip
chattr +i /usr/bin/eu-unstrip
chattr +i /usr/bin/eu-ranlib
+i /usr/bin/eu-elflint
chattr +
chattr +i /usr/bin/eu-addr2line
chattr +i /usr/bin/eu-ar
chattr +i /usr/bin/eu-elfcmp
chattr
i /usr/bin/eu-findtextrel
chattr +i /usr/bin/eu-make-debug-archive
chattr +i /usr/bin/eu-nm
chattr +i /usr/bin/eu-objdump
+i /usr/bin/eu-strip
chattr
chattr +i /usr/bin/eu-ranlib
chattr +i /usr/bin/eu-readelf
chattr +i /usr/bin/eu-size
chattr +i /usr/bin/eu-strings
chattr
+i /usr/bin/eu-unstrip
chattr +i /usr/bin/eu-ranlib
chattr +i /usr/bin/dig
chattr +i /usr/bin/host
chattr +i /usr/bin/nslookup
i /sbin/arping
chattr +i /s
chattr +i /usr/bin/nsupdate
chattr +i /bin/ping
chattr +i /bin/ping6
chattr +i /bin/tracepath
chattr +i /bin/tracepath6
chattr
+bin/ifenslave
chattr +i /sbin/rdisc
chattr +i /usr/sbin/arping
chattr +i /usr/sbin/clockdiff
chattr +i /usr/sbin/ping6
chattr +i /usr/sbin/tracepath
chattr +i /usr/bin/shar
chattr
chattr +i /usr/sbin/tracepath6
chattr +i /usr/bin/compress-dummy
chattr +i /usr/bin/mail-files
chattr +i /usr/bin/mailshar
chattr +i /usr/bin/remsync
+i /usr/bin/unshar
i /usr/bin/newgrp
chattr +i
chattr +i /usr/bin/uudecode
chattr +i /usr/bin/uuencode
chattr +i /usr/bin/chage
chattr +i /usr/bin/faillog
chattr +i /usr/bin/gpasswd
chattr +i /usr/bin/lastlog
chattr
+ /usr/bin/sg
chattr +i /usr/sbin/adduser
chattr +i /usr/sbin/chpasswd
chattr +i /usr/sbin/groupadd
chattr +i /usr/sbin/groupdel
chattr +i /usr/sbin/groupmod
chattr +i /usr/sbin/grpck
bin/useradd
chattr +i /usr/
chattr +i /usr/sbin/grpconv
chattr +i /usr/sbin/grpunconv
chattr +i /usr/sbin/newusers
chattr +i /usr/sbin/pwck
chattr +i /usr/sbin/pwconv
chattr +i /usr/sbin/pwunconv
chattr +i /usr/
ssbin/userdel
chattr +i /usr/sbin/usermod
chattr +i /usr/bin/addr2line
chattr +i /usr/bin/ar
chattr +i /usr/bin/as
chattr +i /usr/bin/c++filt
chattr +i /usr/bin/gprof
chattr +i /usr/bin/ld
chattr +i /usr/bin/nm
17.50.0.6-14.el5.so
chattr
chattr +i /usr/bin/objcopy
chattr +i /usr/bin/objdump
chattr +i /usr/bin/ranlib
chattr +i /usr/bin/readelf
chattr +i /usr/bin/size
chattr +i /usr/bin/strings
chattr +i /usr/bin/strip
chattr +i /usr/lib/libbfd-2
. +i /usr/lib/libopcodes-2.17.50.0.6-14.el5.so
chattr +i /usr/bin/ranlib
chattr +i /usr/lib/libbfd-2.17.50.0.6-14.el5.so
chattr +i /usr/lib/libopcodes-2.17.50.0.6-14.el5.so
chattr +i /bin/doexec
chattr +i /bin/ipcalc
port
chattr +i /sbin/
chattr +i /bin/usleep
chattr +i /sbin/consoletype
chattr +i /sbin/fstab-decode
chattr +i /sbin/genhostid
chattr +i /sbin/getkey
chattr +i /sbin/ifdown
chattr +i /sbin/ifup
chattr +i /sbin/initlog
chattr +i /sbin/netr
eppp-watch
chattr +i /sbin/service
chattr +i /sbin/setsysfont
chattr +i /usr/sbin/sys-unconfig
chattr +i /usr/sbin/usernetctl
chattr +i /lib/udev/rename_device
chattr +i /sbin/grubby
chattr +i /sbin/installkernel
chattr +i /sbin/mkinitrd
/etc/bashrc
chmod 644 /etc/cs
chattr +i /sbin/new-kernel-pkg
chattr +i /lib/bdevid/ata.so
chattr +i /lib/bdevid/scsi.so
chattr +i /lib/bdevid/usb.so
chattr +i /usr/lib/libbdevid.so.5.1.19.6
chmod 644 /etc/profile
chattr +i /etc/profile
chmod 644 /etc/bashrc
chattr +
ih
=============================================
بعد ضبط التصاريح ننتقل الى المرحلة التاليه وهي منع تشغيل البيرل في السيرفر + والحماية من السيملنك طريقة ( انس عاطف ) الله يعطية العافية..
ننفذ
كود:
cd /usr/local/apache/confننشىء
كود:
nano 0x0.confضع بلملف هاذا المحتوى
كود:
<Directory "/">
Options -Indexes -ExecCGI -FollowSymLinks -Includes IncludesNOEXEC Indexes -MultiViews SymLinksIfOwnerMatch
AllowOverride AuthConfig Indexes Limit FileInfo Option,Indexes,Includes,MultiViews,SymLinksIfOwnerMatch
</Directory>
ومن ثم ctrl x واحفظ الملف..
نفتح كونفق الاباتشي
كود:
nano /usr/local/apache/conf/httpd.confونبحث عن
كود:
<Directory "/">
Options
rride All
</Direc
AllowOv
etory>
ونحذفها كاملة الحين نحط هاذا الانكلود بلملف
كود:
Include "/usr/local/apache/conf/0x0.conf"زي ماتشوفون في الصوره
نبحث عن
كود:
<Directory "/usr/local/apache/htdocs">نحذف الكلام كامل ونستبدلة بـ
كود:
<Directory "/usr/local/apache/htdocs">
Options Includes Indexes SymLinksIfOwnerMatch
AllowOverride None
Order Deny,Allow
Deny from all
كود:
</Directory>نبحث عن
كود:
<Directory "/usr/local/apache/cgi-bin">نبدلة بـ
كود:
<Directory "/usr/local/apache/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Deny from all
كود:
</Directory>احفظ الملف وسوي رستارت للباتشي
كود:
service httpd restartلو حد حاول يسحب الكونفق ( اختصار )
بالامر هاذا
كود:
ln -s /home/user/public_html/config.php config.txtالنتيجة Forbidden واذا رفع htaccess يجية خطاء Internal Server Error حتة البيرل نفس الحاجة.
=============================================
الان نركب PHPSuHosin
كود:
/scripts/phpextensionmgr install PHPSuHosinونحرر ملف الـ PHP
كود:
pico /usr/local/lib/php.iniونحط هذا في بداية الملف
كود:
suhosin.executor.func.blacklist =dl,system,passthru,exec,popen,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,****l_exec,escape,****lcmd,pclose,pfsockopen,chgrp,debugger_off,debugger_on,leak,listen,define_syslog_variables,ftp_exec,posix_uname,posix_getpwuid,get_current_user,getmyuid,getmygid,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,pfsockopen,chgrp,debugger_off,debugger_on,leak,listen,define_syslog_variables,ftp_exec,posix_uname,posix_getpwuid,get_current_user,getmyuid,getmygid,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,escape****larg,getservbyport,getservbyname,my****lexec,escape****larg,symlink,****l_exec,exec,proc_close,proc_open,popen,system,dl,passthru,escape****larg,escape****lcmd,posix_getgid,posix_getgrgid,dl,exec,pclose,proc_nice,proc_terminate,proc_get_status,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,hypot,pg_host,pos,posix_access,posix_getcwd,posix_getservbyname,my****lexec,getpid,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mknod,posix_setgid,posix_setsid,posix_setuid,posix_times,posix_uname,ps_fill,posix_getpwuid,global,ini_restore,bzopen,bzread,bzwrite,apache_get_modules,apache_get_version,phpversionphpinfo,php_ini_scanned_files,get_current_user,error_log,disk_total_space,diskfreespace,leak,imap_list,hypo,filedump,gethostbyname,safe_mode,getmygid,php_uname,apache_getenv,apache_setenv,bzread,bzwrite,posix_access,bzopen,phpini,dos_conv,get_current_user,get_cwd,error_log,cmd,e_name,vdir,get_dir,only_readتحميك من الشلات المشفرة والغير المشفرة بعض الشلات ..
وبنفس الوقت نرقع ثغره SUPHP
كود:
pico /home/cpeasyapache/src/suphp.confونبحث عن
application/x-httpd-php5=/usr/local/lib;
ونعدلها لتصبح كتالي
application/x-httpd-php5=/usr/local/lib
ونعدل القيم التاليه :
كود:
; Security options
allow_file_group_writeable=true
allow_file_others_writeable=false
allow_directory_group_writeable=true
allow_directory_others_writeable=false
check_vhost_docroot=true
up=false
full_php_process_display
userdir_overrides_usergr
o=true
والان نحرر ملف
كود:
pico /etc/httpd/conf/php.confنبحث عن
كود:
suPHP_Engine onنضع تحتة
كود:
SuPHP_ConfigPath /usr/local/lib/php.ini=============================================
حمايه معلومات الاباتشي ..
نحرر
كود:
pico /etc/httpd/conf/httpd.confنبحث عن
كود:
ServerSignature onنحولها الى ..
كود:
ServerSignature offوتحتة نضع هاذا السطر ..
كود:
ServerTokens ProductOnlyنحفظ الملف ونعمل رستارت
كود:
/etc/rc.d/init.d/httpd restart=============================================
حمايه الـ Kernel وتزيف معلوماتها ..
ننفذ
كود:
mv /bin/uname /bin/uname2من ثم
كود:
nano /bin/unameنضع المحتوى
كود:
#!/bin/bash
echo "Linux server.h4x0rz.net SECURED-KERNEL BY 0x0 Team"
وننفذ في الشل الان uname -a
نشوف في الصوره
=============================================
تركيب DoS Deflate للحمايه من الدوس اتاك ..
نفذ التالي لتركيب البرنامج ..
كود:
wget http://www.inetbase.com/scripts/ddos/install.sh
chmod 0700 install.sh
./install.sh
=============================================
تركيب Apache Booster لتسريع الاباتشي ومفيد جدا خاصة في هجمات الدوس اتاك ..
كود PHP:
wget http://prajith.in/downloads/apachebooster.tar.gz
tar -zxf apachebooster-v1.3.tar.gz cd apachebooster sh install.sh صوره من خاصية السكربت ..
=============================================
والى هنا تم الانتهاء من الشرح .. نشكر جميع الاعضاء ..
0 التعليقات:
إرسال تعليق