المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : حصرياً الطريقة الأحترافية لصد هجمات الدوس DDOS Attacks



walid
11-02-2013, بتوقيت غرينيتش 01:58 AM
حصرياً الطريقة الأحترافية لصد هجمات الدوس DDOS Attacks


: : : هذا الشرح طريقة مقدم من شركة هوست تونيد لخدمات الأستضافة والتصميم style : : :



شرح طريقةي راح يكون عن الطريقة الأحترافية في صد هجمات الدوس الطريقة مجربة 100% وتم حظر الكثير من هجمات الدوس على السيرفر SERVERات بواسطة الطريقة سهلة وبسيطة والتي تعبت جدا في البحث عنها وتمت تجربتها والحمد لله كل شيء صار تمام http://www.dzbatna.com/images/smilies/shiny01.gif


تـــابــع الشرح طريقة

قبل كل شيء أنبه ان هنالك ثغرة خطيرة في برنامج bind9 وننصح بتركيب install النسخة 9.3.4 لخلوها من الثغرة

1 • الحماية ضد Dos , DDos :

? تقوية sysctl.conf و host.conf

ندخل على الشيل
رمز PHP:

<code style="white-space:nowrap"> <code> cd /etc/
mv sysctl.conf sysctl.conf.css
</code> </code>

رمز PHP:

<code style="white-space:nowrap"> <code> pico sysctl.conf
</code> </code>

ضع فيه التالي :

رمز PHP:

<code style="white-space:nowrap"> <code> # Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.

# Controls IP packet forwarding
net.ipv4.ip_forward = 0

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.lo.rp_filter = 1
net.ipv4.conf.eth0.rp_filter = 1

# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.lo.accept_source_route = 0
net.ipv4.conf.eth0.accept_source_route = 0

# Disable ICMP Redirect Acceptance
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.lo.accept_redirects = 0
net.ipv4.conf.eth0.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0

# Enable Log Spoofed Packets, Source Routed Packets, Redirect Packets
net.ipv4.conf.all.log_martians = 0
net.ipv4.conf.lo.log_martians = 0
net.ipv4.conf.eth0.log_martians = 0

# Lower retry rates
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 3

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Max File Handlers
fs.file-max = 8192
# Disable CTR+ALT+DEL Restart Keys
kernel.ctrl-alt-del = 1

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 15

# Decrease the time default value for tcp_keepalive_time connection
net.ipv4.tcp_keepalive_time = 1800

# Turn off the tcp_window_scaling
net.ipv4.tcp_window_scaling = 0

# Turn off the tcp_sack
net.ipv4.tcp_sack = 0

# Turn off the tcp_timestamps
net.ipv4.tcp_timestamps = 0

# Enable TCP SYN Cookie Protection
net.ipv4.tcp_syncookies = 1

# Enable ignoring broadcasts request
net.ipv4.icmp_echo_ignore_broadcasts = 1

# Enable bad error message Protection
net.ipv4.icmp_ignore_bogus_error_responses = 1

# Log Spoofed Packets, Source Routed Packets, Redirect Packets
net.ipv4.conf.all.log_martians = 1

# Increases the size of the socket queue (effectively, q0).
net.ipv4.tcp_max_syn_backlog = 1024

# Increase the tcp-time-wait buckets pool size
net.ipv4.tcp_max_tw_buckets = 1440000

# Allowed local port range
net.ipv4.ip_local_port_range = 16384 65536
</code> </code>

ثم نحفظ العمل

رمز PHP:

<code style="white-space:nowrap"> <code> /sbin/sysctl -p
</code> </code>

رمز PHP:

<code style="white-space:nowrap"> <code> sysctl -w net.ipv4.route.flush=1



</code> </code>


ثم

رمز PHP:

<code style="white-space:nowrap"> <code> cd /etc
mv host.conf host.conf.css
</code> </code>

رمز PHP:

<code style="white-space:nowrap"> <code> pico host.conf
</code> </code>


نضع فيه التالي :


رمز PHP:

<code style="white-space:nowrap"> <code> # Lookup names via DNS first then fall back to /etc/hosts
order hosts,bind
# Check for IP address spoofing.
nospoof on
# multiple IP addresses
multi on
</code> </code>

ثم
رمز PHP:

<code style="white-space:nowrap"> <code> httpd restart
</code> </code>


الساين كوكيز يمكن تفعيلها عن طريق الأمر :

رمز PHP:

<code style="white-space:nowrap"> <code> echo 1 > /proc/sys/net/ipv4/tcp_syncookies
</code> </code>

بعد ذلك نقوم بتركيب install برنامج Easy Linux Security

لتركيب install البرنامج اكتب الأمر التالي :
رمز PHP:

<code style="white-space:nowrap"> <code> wget --output-document=installer.sh http://servermonkeys.com/projects/els/installer.sh; chmod +x installer.sh; sh installer.sh
</code> </code>


الي مركب البرنامج احنا راح ننزل برنامج APF + BFD مع افضل الأعدادات :


نـبداء الشرح طريقة :
نقوم بتحديث update سكربت ELS عن طريق الأمر التالي :
رمز PHP:

<code style="white-space:nowrap"> <code> els --update
</code> </code>

اذا هناك تحديث update سوف يقوم به تلقائيا اذا كانت لديك أخر نسخه من الاسكربت سوف تظهر هذه الرساله :
رمز PHP:

<code style="white-space:nowrap"> <code> &#91;color="DarkGreen"&#93;ELS 3.0.0.3 is the latest release, there is no need to update.&#91;/color&#93;
</code> </code>


اولا : تركيب install برنامج الجدار الناري APF مع افضل اعدادات
نكتب الأمر التالي لتركيب install البرنامج :
رمز PHP:

<code style="white-space:nowrap"> <code> els --apf
</code> </code>

بعد تنزيل البرنامج نكتب الأمر التالي لضبط الأعدادات :
رمز PHP:

<code style="white-space:nowrap"> <code> pico /etc/apf/conf.apf
</code> </code>

ونتإكد من القيم التالية بإنها :

رمز PHP:

<code style="white-space:nowrap"> <code> EGF="1"
USE_DS="1"
USE_AD= 1
</code> </code>

بعد ذلك نسوي حفظ للعمل


بعد ذلك نذهب الى الملف التالي :
رمز PHP:

<code style="white-space:nowrap"> <code> pico /etc/apf/ad/conf.antidos
</code> </code>

ونتأكد من القيم التالية :

رمز PHP:

<code style="white-space:nowrap"> <code> LP_KLOG="1"
CONAME="Your Company"
USR_ALERT="1"
USR="[email protected] (http://www.cloudflare.com/email-protection)"
</code> </code>

بعد ذلك نسوي خفظ للملف

هذه اوامر مهمة للفايرول :
تشغيل الفايرول :

رمز PHP:

<code style="white-space:nowrap"> <code> /usr/local/sbin/apf -s
</code> </code>

اعادة تشغيل الفايرول :

رمز PHP:

<code style="white-space:nowrap"> <code> /usr/local/sbin/apf -r
</code> </code>

ايقاف الفايرول :

رمز PHP:

<code style="white-space:nowrap"> <code> /usr/local/sbin/apf -f
</code> </code>

مشاهدة حالة الفايرول :

رمز PHP:

<code style="white-space:nowrap"> <code> /usr/local/sbin/apf -st
</code> </code>

للسماح للأي بي

رمز PHP:

<code style="white-space:nowrap"> <code> /usr/local/sbin/apf -a 124.11.11.11
</code> </code>

لحظر أي بي شخص بالفيرول

رمز PHP:

<code style="white-space:nowrap"> <code> /usr/local/sbin/apf -d 124.11.11.11
</code> </code>

بعد الانتهاء نقوم بتشغيل الفايرول اكتب الأمرين التالين :
رمز PHP:

<code style="white-space:nowrap"> <code> /etc/apf/ad/antidos -a
/usr/local/sbin/apf -r
</code> </code>


ثانيا : بعد الانتهاء من تركيب install الفايرول نقوم بتركيب install برنامج الحماية BFD (Brute Force Detection)


لتركيب install البرنامج اكتب الأمر التالي :
رمز PHP:

<code style="white-space:nowrap"> <code> els --bfd
</code> </code>


ولضبط اعدادات البرنامج نكتب الأمر التالي :
رمز PHP:

<code style="white-space:nowrap"> <code> pico -w /usr/local/bfd/conf.bfd
</code> </code>

يجب انت تكون القيم كتالي :
رمز PHP:

<code style="white-space:nowrap"> <code> ALERT_USR="1"
EMAIL_USR=you@yoursite.com
</code> </code>

مع استبدال البريد الإلكتروني

نسوي حفظ للملف

لتشغيل البرنامج نكتب الأمر التالي :
رمز PHP:

<code style="white-space:nowrap"> <code> /usr/local/sbin/bfd -s
</code> </code>

معلومة هامة حول البرنامج :
للسماح بالأي بي
رمز PHP:

<code style="white-space:nowrap"> <code> pico -w /etc/apf/allow_hosts.rules
</code> </code>

ونضع الأي بي داخل الملف ونسوي له حفظ

ولحظر اي بي نروح الى
رمز PHP:

<code style="white-space:nowrap"> <code> pico -w /usr/local/bfd/ignore.hosts
</code> </code>

ونضع الأي بي داخل الملف ونسوي له حفظ


ثالثا : تركيب install برنامج الحماية من هجمات DOS-Deflate


تنصيب setup البرنامج :

رمز PHP:

<code style="white-space:nowrap"> <code> wget http://www.inetbase.com/scripts/ddos/install.sh
chmod 0700 install.sh
./install.sh
</code> </code>

بعد ذلك نقوم بضبط الأعدادات :
رمز PHP:

<code style="white-space:nowrap"> <code> pico /usr/local/ddos/ddos.conf
</code> </code>

ونغير التالي :
رمز PHP:

<code style="white-space:nowrap"> <code> Set NO_OF_CONNECTIONS=150
</code> </code>

نغيرها الى اي رقم تريده
هذا الخيار للوضع حدد لعدد الأتصالات بالسيرفر SERVER للأي بي الواحد
يفضل وضعها 300 او 250

وتإكد من القيم التالية :

رمز PHP:

<code style="white-space:nowrap"> <code> APF_BAN=1
EMAIL_TO=xxx@xxx.com
هذا عدد الوقت بالثانية للحظر 600 ثانية
BAN_PERIOD=600
</code> </code>


لمعرفة المتصلين بالسيرفر SERVER نكتب الامر هذا

رمز PHP:

<code style="white-space:nowrap"> <code> cd /usr/local/ddos/;./ddos.sh
sh /usr/local/ddos/ddos.sh
</code> </code>

لحظر اي شخص ندخل هنا

رمز PHP:

<code style="white-space:nowrap"> <code> pico /usr/local/ddos/ignore.ip.list
</code> </code>

ونضع الأي بي داخل الملف ونسوي له حفظ


تشغيل البرنامج :

رمز PHP:

<code style="white-space:nowrap"> <code> /usr/local/ddos/ddos.sh -c
iptables -F
</code> </code>

ولجعل البرنامج يعمل بعد الريستارت نروح للملف :
رمز PHP:

<code style="white-space:nowrap"> <code> pico /etc/rc.d/rc.local
</code> </code>

ونضع في نهاية الملف التالي :

رمز PHP:

<code style="white-space:nowrap"> <code> ## Add the following lines at the bottom of the file
/usr/local/ddos/ddos.sh -c
</code> </code>

لو رغبت بحذف البرنامج اكتب الأمر التالي :

رمز PHP:

<code style="white-space:nowrap"> <code> wget http://www.inetbase.com/scripts/ddos/uninstall.ddos
chmod 0700 uninstall.ddos
./uninstall.ddos
</code> </code>

بعد الانتهاء من اعداد برامج الحماية السيرفر SERVER والفايرول افضل اعدادات اقدم لكم معلومات لكيفة صد اي هجوم DOS يتعرض له السيرفر SERVER وشرح كيفية معرفة ذلك

اكتب الأمر التالي لمعرفة عدد المتصلين بالسيرفر SERVER :

رمز PHP:

<code style="white-space:nowrap"> <code> netstat -plan|grep :80|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -nk 1
or
netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
</code> </code>

راح يظهر لك النتيجة كتالي :

رمز PHP:

<code style="white-space:nowrap"> <code> 1 195.229.235.36
1 195.229.235.39
1 195.229.236.214
1 195.229.237.39
1 195.229.242.53
1 195.229.242.55
1 195.229.242.56
1 196.12.217.252
1 196.20.126.97
1 41.200.213.119
1 86.60.97.145
1 89.108.0.85
2 195.229.235.41
2 41.201.175.161
2 41.248.162.42
2 77.30.118.133
2 94.97.78.197
3 84.11.138.148
400 41.235.239.187
</code> </code>

هذا يعني ان الأي بي
41.235.239.187
مسوي فلود على السيرفر SERVER طيب الحين عرفنا مسبب الفلود الحين نجي نسوي له حظر

اكتب الأمر التالي :

رمز PHP:

<code style="white-space:nowrap"> <code> pico /usr/local/ddos/ignore.ip.list
</code> </code>

وضع الأي بي الشخص المسبب للحظر

ولحظر الأي بي بواسطة برنامج BFD
ولحظر اي بي نروح الى

رمز PHP:

<code style="white-space:nowrap"> <code> pico -w /usr/local/bfd/ignore.hosts
</code> </code>

ونضع الأي بي داخل الملف ونسوي له حفظ

وايضا نروح للبرنامج APF ونحط الأي بي

رمز PHP:

<code style="white-space:nowrap"> <code> /usr/local/sbin/apf -d 41.235.239.187
</code> </code>

وهذه طريقة اخرى لخظر الشخص

رمز PHP:

<code style="white-space:nowrap"> <code> iptables -I INPUT -s 41.235.239.187 -j DROP
</code> </code>

بعد كذا نكتب الامر
رمز PHP:

<code style="white-space:nowrap"> <code> service iptables save
service iptables restart
</code> </code>


بالنسبة للي مركب برنامج الحماية CSF انصح الأشخاص الذين يمتلكون سيرفر SERVERات سيرفر VPS بعدم تركيب installه لأن ما ينفع مع سيرفر SERVERات سيرفر VPS ويسبب مشاكل ولكن يعمل بشكل جيد مع السيرفر SERVERات الكاملة


انتهى الشرح طريقة وهذا افضل طريقة للحظر هجمات الدوس وهي طريقة مجربة http://www.dzbatna.com/images/smilies/shiny01.gif

عند عمل فلود راح توصلك رسالة كتالي على بريدك http://www.dzbatna.com/images/smilies/bleh.gif
IP addresses banned on Wed Aug 13 17:10:07 AST 2014

رمز PHP:

<code style="white-space:nowrap"> <code> Banned the following ip addresses on Wed Aug 13 17:10:01 AST 2014

41.249.56.19 with 205 connections
</code> </code>


انا جالس اجهز شرح طريقة مفصل للسيرفر SERVERات وان شاءلله ربنا يوفقنا في الأنتهاء من كتابة الشرح طريقة http://www.dzbatna.com/images/smilies/bigsmile.gif


نشوف الردود والتقييمات http://www.dzbatna.com/images/smilies/icon30.gif


حسن محمد القوزعي http://www.dzbatna.com/images/smilies/shiny01.gif
ادارة شركة هوست تونيد




https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-ash4/482113_236967293114455_1193518507_n.png (http://www.dzbatna.com)
©المشاركات المنشورة تعبر عن وجهة نظر صاحبها فقط، ولا تُعبّر بأي شكل من الأشكال عن وجهة نظر إدارة المنتدى (http://www.dzbatna.com)©

استعمل مربع البحث في الاسفل لمزيد من المواضيع


سريع للبحث عن مواضيع في المنتدى