• About
  • Policy
  • Contact

Phan Anh Buổi Sáng

  • Home
  • Kiến thức IT
    • PSD
    • Blogger
  • Translate
Google
Custom Search
Trang chủ » Security » TUTORIALS » Sử dụng Iptables chống Syn Flood attacks và cấm IP

Sử dụng Iptables chống Syn Flood attacks và cấm IP

Unknown Labels: Security, TUTORIALS Leave A Comment 20:19
Syn flood là 1 dạng tấn công từ chối dịch vụ, kẻ tấn công gửi các gói tin kết nối SYN đến hệ thống. Đây là 1 loại tấn công rất phổ biến. Loại tấn công này sẽ nguy hiểm nếu hệ thống cấp phát tài nguyên ngay sau khi nhận gói tin SYN từ kẻ tấn công và trước khi nhận gói ACK.
Nếu việc thiết lập kết nối chưa hòan tất 3 bước đây đủ (gọi là half-open connection) mà buộc hệ thống server phải cấp tài nguyên để quản lý thì kẻ tấn công có thể lấy hết tài nguyên của hệ thống server bằng các “flooding” vào server với các gói tin SYN. Syn flood là 1 dạng tấn công phổ biến và nó có thể được ngăn chặn bằng đoạn lệnh iptables sau:
Mã:
iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 3 -j RETURN
Tất cả các kết nối đến hệ thống chỉ được phép theo các thông số giới hạn sau:
–limit 1/s: Tốc độ truyền gói tin trung bình tối đa 1/s (giây)
–limit-burst 3: Số lượng gói tin khởi tạo tối đa được phép là 3

Dùng iptables, thêm rule sau vào:
Trích:
# Limit the number of incoming tcp connections
# Interface 0 incoming syn-flood protection
iptables -N syn_flood
iptables -A INPUT -p tcp –syn -j syn_flood
iptables -A syn_flood -m limit –limit 1/s –limit-burst 3 -j RETURN
iptables -A syn_flood -j DROP
iptables -I INPUT -p tcp -s 0/0 -d $SERVER_IP –sport 513:65535 –dport 22 -m state –state NEW,ESTABLISHED -m recent –set -j ACCEPT iptables -I INPUT -p tcp –dport 22 -m state –state NEW -m recent –update –seconds 600 –hitcount 11 -j DROP
iptables -A OUTPUT -p tcp -s $SERVER_IP -d 0/0 –sport 22 –dport 513:65
#!/bin/bash
IPT=/sbin/iptables
SPAMLIST=”spamlist”
SPAMDROPMSG=”SPAM LIST DROP”
BADIPS=$(egrep -v -E “^#|^$” /root/iptables/blocked.ips)
# create a new iptables list
$IPT -N $SPAMLIST
for ipblock in $BADIPS
do
$IPT -A $SPAMLIST -s $ipblock -j LOG –log-prefix “$SPAMDROPMSG”
$IPT -A $SPAMLIST -s $ipblock -j DROP
done
$IPT -I INPUT -j $SPAMLIST
$IPT -I OUTPUT -j $SPAMLIST
$IPT -I FORWARD -j $SPAMLIST
#!/bin/bash
# Ban quyen thuoc ve Hanh_bk
/etc/init.d/iptables start
cd /root/iptables
netstat -atun | grep SYN_RECV | awk ‘{print $5}’ | cut -d: -f1 |sort | uniq -d | sort -n > blocked.ips
sh ./iptables.sh

Bài viết liên quan

← Bài đăng mới hơn Bài đăng cũ hơn → Trang chủ
Powered by Blogger.

Các Bình Luận Gần Đây

Bài đăng phổ biến

  • [PHP] Get list username - vBulletin
    <?php // GET user function duyk_get_all_usr($link, $total_usr) { $max_page = $total_usr/100; $ma...
  • 10 tên tội phạm máy tính từng "làm khổ" cả thế giới (phần 1)
    Ngay từ những ngày đầu tiên khi những chiếc máy tính ra đời từ cách đây hơn 50 năm, một loại tội phạm mới cũng theo đó mà xuất hiện: tội p...
  • Ảnh bìa chế Phía sau một cô gái - Soobin Hoàng Sơn - Zoy Thủ Thuật #Zoy
    Đôi lúc em tránh ánh mắt của anh. vì dường như lúc nào em cũng hiểu thấu lòng anh Demo Cover Download PSD loading...
  • 403 Forbidden and cant read /etc/named.conf Error Bypass
    This Tut has been submitted by Sen Haxor Now days most of the 2012 Linux Kernel server show this error when you try to symlink the serve...
  • Chuyển domain blog Storm Tuấn
                                     BLog Stormtuanit .tk đã chuyển lại thành  http://truongtuan-it.blogspot.com/                               ...
  • vBulletin 5 Multiple Full Path Disclosure vulnerabilities
    /core/vb5/route/channel.php /core/vb5/route/conversation.php /core/vb5/route/*.php /includes/api/ interface /noncollapsed.php /includes/api/...
  • Symlink IncludesNOEXEC
    <Directory "/"> Options -ExecCGI -FollowSymLinks -Includes IncludesNOEXEC Indexes -MultiViews SymLinksIfOwnerMatch AllowOver...
  • 3D Oranges
  • [Tut] Unlock Tên Giả Không Cần CMND
                                                              Nguồn:  TruongTuan-IT.Cf
  • Perl, Python, Ruby bypass Open_BaseDir
        [+] Đầu tiên ta hãy tìm hiểu xem cái open_basedir là cái wtf gì      http://id.php.net/manual/en/ini.core...i.open-basedir     Tạm dịch ...

Pageviews from the past week

Chuyên mục

Bài đăng phổ biến

  • [PHP] Get list username - vBulletin
    <?php // GET user function duyk_get_all_usr($link, $total_usr) { $max_page = $total_usr/100; $ma...
  • 10 tên tội phạm máy tính từng "làm khổ" cả thế giới (phần 1)
    Ngay từ những ngày đầu tiên khi những chiếc máy tính ra đời từ cách đây hơn 50 năm, một loại tội phạm mới cũng theo đó mà xuất hiện: tội p...
  • Ảnh bìa chế Phía sau một cô gái - Soobin Hoàng Sơn - Zoy Thủ Thuật #Zoy
    Ảnh bìa chế Phía sau một cô gái - Soobin Hoàng Sơn - Zoy Thủ Thuật #Zoy
    Đôi lúc em tránh ánh mắt của anh. vì dường như lúc nào em cũng hiểu thấu lòng anh Demo Cover Download PSD loading...
  • 403 Forbidden and cant read /etc/named.conf Error Bypass
    This Tut has been submitted by Sen Haxor Now days most of the 2012 Linux Kernel server show this error when you try to symlink the serve...
  • Chuyển domain blog Storm Tuấn
    Chuyển domain blog Storm Tuấn
                                     BLog Stormtuanit .tk đã chuyển lại thành  http://truongtuan-it.blogspot.com/                               ...
  • vBulletin 5 Multiple Full Path Disclosure vulnerabilities
    /core/vb5/route/channel.php /core/vb5/route/conversation.php /core/vb5/route/*.php /includes/api/ interface /noncollapsed.php /includes/api/...
  • Symlink IncludesNOEXEC
    <Directory "/"> Options -ExecCGI -FollowSymLinks -Includes IncludesNOEXEC Indexes -MultiViews SymLinksIfOwnerMatch AllowOver...
  • 3D Oranges
    3D Oranges
  • [Tut] Unlock Tên Giả Không Cần CMND
    [Tut] Unlock Tên Giả Không Cần CMND
                                                              Nguồn:  TruongTuan-IT.Cf
  • Perl, Python, Ruby bypass Open_BaseDir
        [+] Đầu tiên ta hãy tìm hiểu xem cái open_basedir là cái wtf gì      http://id.php.net/manual/en/ini.core...i.open-basedir     Tạm dịch ...
Google
Custom Search
Support: Facebook | Twitter | Google+ | Giới thiệu
Copyright © 2015 • Phan Anh Buổi Sáng • All Right Reserved. Template by Template Việt