طريقة تركيب الmod_security
mod_security هو اضافة مفتوحة المصدر تضاف للApache Deomon في ال*nix و تستغل في اكتشاف محاولات الأختراقات (intrusion detection) و تسجيل مصادرها
+هذا المود يعمل مع السيرفرات التي تتعامل مع لوحات تحكم Cpanel
+هذا المود يساهم في تعطيل اي خدمة في السيرفرات و سهل التحكم به و هو ضروري و انصح به لجميع السيرفرات Apache WebServer
+يركب على النسخ : apache 2,x و apache 1.3x
طريقة التركيب
بعد الدخول (Root) على السيرفر عن طريق ال SSH بإستعمال putty مثلا
اكتب الأمر التالي لتحميل ال mod على السيرفر
كود:
wget http://www.modsecurity.org/download/...y-1.7.4.tar.gz
ثم فك ضغط الملف و ركبه
و اكتب الكود التالي :
كود:
tar zxvf mod_security-1.7.4.tar.gz
cd mod_security-1.7.4/
ثم حسب نسخة الApache الي على سيرفرك (your Server)
تجد المجلدين
كود:
APACHE 1.3.x
cd apache1/
APACHE 2.x
cd apache2/
ثم يجب عمل compile لل Mod الجديد الذي تم تركيبه
اكتب الأمر التالي
كود:
/usr/local/apache/bin/apxs -cia mod_security.c
ثم الأن عليك تحرير الhttpd.conf لتغير بعض الderective
اولا و نصيحة لكم مني هو عمل نسخة احتياطية من الملف الذي سنحرره (httpd.conf)
اكتب الكود التالي
كود:
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.backup
ثم بندأ تحرير الملف
كود:
pico /usr/local/apache/conf/httpd.conf
ابحث الأن على
كود:
<IfModule mod_dir.c>
الأن اضف تحت السطر ذلك
الكود هذا
كود:
<IfModule mod_security.c>
# Turn the filtering engine On or Off
SecFilterEngine On
# Change Server: string
SecServerSignature " "
# Make sure that URL encoding is valid
SecFilterCheckURLEncoding On
# This setting should be set to On only if the Web site is
# using the Unicode encoding. Otherwise it may interfere with
# the normal Web site operation.
SecFilterCheckUnicodeEncoding Off
# Only allow bytes from this range
SecFilterForceByteRange 1 255
# The audit engine works independently and
# can be turned On of Off on the per-server or
# on the per-directory basis. "On" will log everything,
# "DynamicOrRelevant" will log dynamic requests or violations,
# and "RelevantOnly" will only log policy violations
SecAuditEngine RelevantOnly
# The name of the audit log file
SecAuditLog /var/log/httpd/audit_log
# Should mod_security inspect POST payloads
SecFilterScanPOST On
# Action to take by default
SecFilterDefaultAction "deny,log,status:500"
# Require HTTP_USER_AGENT and HTTP_HOST in all requests
SecFilterSelective "HTTP_USER_AGENT|HTTP_HOST" "^$"
# Prevent path traversal (..) attacks
SecFilter "../"
# Weaker XSS protection but allows common HTML tags
SecFilter "<[[:space:]]*script"
# Prevent XSS atacks (HTML/Javascript injection)
SecFilter "<(.|n)+>"
# Very crude filters to prevent SQL injection attacks
SecFilter "delete[[:space:]]+from"
SecFilter "insert[[:space:]]+into"
SecFilter "select.+from"
# Protecting from XSS attacks through the PHP session cookie
SecFilterSelective ARG_PHPSESSID "!^[0-9a-z]*$"
SecFilterSelective COOKIE_PHPSESSID "!^[0-9a-z]*$"
</IfModule>
الأن سجل ما قمت به من تعديلا
بعمل crtl-X
ثم
Y
ثم اعد تشغيل الApache
كود:
/etc/rc.d/init.d/httpd stop
/etc/rc.d/init.d/httpd start
____________________________________
منقول ووضعته للفائدة
ابو طلال