Linux+DDoS deflate 预防DDoS攻击
使用DDoS脚本防止DDoS攻击
使用DDoS脚本防止DDoS攻击:
DDoS概述:
分布式拒绝服务(DDoS:Distributed Denial of Service)攻击,指借助于客户/服务器技术,将多个计算机联合起来作为攻击平台,对一个或多个目标发动DDoS攻击,从而成倍地提高拒绝服务攻击的威力。
如何查看是否受到DDoS攻击?
通过netstat 查看网络连接数。如果一个IP地址对服务器建立很多连接数(比如一分钟产生了100个连接),就认为发生了DDoS
[root@web ~]# vim ddos_test.sh #写入以下内容
#!/bin/bash
netstat -ntu | awk '{print $5}' | cut -d: -f1 | uniq -c | sort -n
查看tcp和udp连接情况|截取外网IP和端口|截取外网IP|去重|排序并统计
模拟DDOS攻击
[root@web ~]# systemctl start httpd
# 使用ab命令模拟DDoS攻击 访问一个页面 , 页面越大 ,消耗服务器带宽就越大
[root@DDoS ~]# ab -n -c http://192.168.94.11/index.html # -n 要产生的链接数总和 -c 同时打开的客户端数量
# 回到web服务器查看
[root@web ~]# netstat -ntu | awk '{print $5}' | cut -d: -f1 | uniq -c | sort -n
192.168.94.254
Address
servers)
192.168.94.111
# 如果发现某个IP连接数据有上百的链接,说明就有DDOS攻击
解决办法
使用DDoS deflate 解决服务器被DDOS攻击的问题
DDoS deflate是用来防御和减轻DDoS攻击的脚本 它通过netstat监测跟踪创建大量网络连接的IP地址,在检测到某个结点超过预设的限制时,该程序会通过APF或IPTABLES禁止或阻挡这些IP
下面开始安装DDos deflate
[root@web ~]# wget http://www.inetbase.com/scripts/ddos/install.sh
[root@web ~]# chmod +x install.sh
[root@web ~]# ./install.sh #需要机器能上网
Installing DOS-Deflate 0.6 Downloading source files.........done Creating cron to run script every minute.....(Default setting).....done Installation has completed.
Config file is at /usr/local/ddos/ddos.conf
Please send in your comments and/or suggestions to zaf@vsnl.com #下面内容省略 输入q退出
[root@web ~]# cd /usr/local/ddos/
[root@web ddos]# ls
ddos.conf ddos.sh ignore.ip.list LICENSE # 安装目录下面有配置文件、脚本和IP白名单
配置DDoS deflate配置文件
##### Paths of the script and other files
PROGDIR="/usr/local/ddos"
PROG="/usr/local/ddos/ddos.sh" #要执行的DDoS脚本
IGNORE_IP_LIST="/usr/local/ddos/ignore.ip.list" # IP白名单 , 名单中的IP不受限制
CRON="/etc/cron.d/ddos.cron" # 周期任务
APF="/etc/apf/apf"
IPT="/sbin/iptables" ##### frequency in minutes for running the script
##### Caution: Every time this setting is changed, run the script with --cron
##### option so that the new frequency takes effect
FREQ= # 检查DDoS攻击间隔 , 默认一分钟 ##### How many connections define a bad IP? Indicate that below.
NO_OF_CONNECTIONS= # 最大连接数,超过这个数IP就会被屏蔽,一般默认即可 ##### APF_BAN= (Make sure your APF version is atleast 0.96)
##### APF_BAN= (Uses iptables for banning ips instead of APF)
APF_BAN= # 使用APF还是iptables。推荐使用iptables,将APF_BAN的值改为0即可 ##### KILL= (Bad IPs are'nt banned, good for interactive execution of script)
##### KILL= (Recommended setting)
KILL= # 是否屏蔽IP,默认即可 ##### An email is sent to the following address when an IP is banned.
##### Blank would suppress sending of mails
EMAIL_TO="root" # 当IP被屏蔽时给指定邮箱发送邮件报警,换成自己的邮箱即可 ##### Number of seconds the banned ip should remain in blacklist.
BAN_PERIOD= # 禁用IP时间,默认600秒,可根据情况调整
查看周期任务
[root@web ddos]# cat /etc/cron.d/ddos.cron # 系统级别的计划任务
SHELL=/bin/sh
-/ * * * * root /usr/local/ddos/ddos.sh >/dev/null >&
# 每分钟查看一下,是不是有ddos攻击,如果发现就开始拒绝
测试
# 查看web服务器iptables策略
[root@web ddos]# iptables -nL
Chain INPUT (policy ACCEPT)
target prot opt source destination Chain FORWARD (policy ACCEPT)
target prot opt source destination Chain OUTPUT (policy ACCEPT)
target prot opt source destination #使用ab命令模拟DDoS攻击
[root@DDoS ~]# ab -n -c http://192.168.94.11/index.html # 等一分钟查看web服务器查看iptables策略
[root@web ddos]# iptables -nL
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- 192.168.94.111 0.0.0.0/ Chain FORWARD (policy ACCEPT)
target prot opt source destination Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@web ddos]#
若果不想使用DDoS deflate怎么办呢?
很简单
一键卸载 :
[root@web ddos]# wget http://www.inetbase.com/scripts/ddos/uninstall.ddos
[root@web ddos]# chmod +x uninstall.ddos
[root@web ddos]# ./uninstall.ddos Uninstalling DOS-Deflate Deleting script files.........done Deleting cron job.......done Uninstall Complete
虽然说DDoS deflate的计划任务是系统级别的
黑客一样有办法去篡改一个系统级别的计划任务
可能我们也看不出动了什么手脚 , 定期检查的时候看着还是跟往常一样
忽然某一天被DDoS攻击了还不知道怎么回事
所以 , 我们还是先下手为强
[root@web ~]# find /etc/cron* -type f -exec md5sum {} \; > /usr/share/cronfile_md5
# 可以使用md5加密 , 因为md5加密算法是不可逆的 , 文件只要被改动过就能看得出来
[root@web share]# cat cronfile_md5
1638f7fe39f7f52c412e1705a0bc52d1 /etc/cron.d/0hourly
367636170f3ac44df6a117e3cbf7e4ba /etc/cron.d/raid-check
a51a35325c37a1cc0ed00f8638a06b96 /etc/cron.d/ddos.cron
6e10e35911b4ba4e2dff44613b56676f /etc/cron.daily/logrotate
16e73be8fe46a83f7525b59f921e9bab /etc/cron.daily/man-db.cron
d41d8cd98f00b204e9800998ecf8427e /etc/cron.deny
8675eb4a3dba8e20bd6b82c626304556 /etc/cron.hourly/0anacron
c39252b11aad842fcb75e05c6a27eef8 /etc/crontab
[root@web share]# md5sum -c cronfile_md5 # 校验文件信息
/etc/cron.d/0hourly: 确定
/etc/cron.d/raid-check: 确定
/etc/cron.d/ddos.cron: 确定
/etc/cron.daily/logrotate: 确定
/etc/cron.daily/man-db.cron: 确定
/etc/cron.deny: 确定
/etc/cron.hourly/0anacron: 确定
/etc/crontab: 确定
[root@web share]# echo " " >> /etc/cron.d/ddos.cron # 加一个空格进去
[root@web share]# md5sum -c cronfile_md5
/etc/cron.d/0hourly: 确定
/etc/cron.d/raid-check: 确定
/etc/cron.d/ddos.cron: 失败 # 验证失败
/etc/cron.daily/logrotate: 确定
/etc/cron.daily/man-db.cron: 确定
/etc/cron.deny: 确定
/etc/cron.hourly/0anacron: 确定
/etc/crontab: 确定
md5sum: 警告: 个校验和不匹配
这样定期检查的时候就可以发现系统级别的计划任务是否被篡改
Linux+DDoS deflate 预防DDoS攻击的更多相关文章
- DDoS deflate - Linux下防御/减轻DDOS攻击
2010年04月19日 上午 | 作者:VPS侦探 前言 互联网如同现实社会一样充满钩心斗角,网站被DDOS也成为站长最头疼的事.在没有硬防的情况下,寻找软件代替是最直接的方法,比如用iptables ...
- linux笔记_防止ddos攻击
一.什么是DoS攻击 DoS是Denial of Service的简称,即拒绝服务,造成DoS的攻击行为被称为DoS攻击,其目的是使计算机或网络无法提供正常的服务.最常见的DoS攻击有计算机网络带宽攻 ...
- 修改Linux SSH连接端口和禁用IP,安装DDoS deflate
测试系统:centos7 修改连接端口 修改配置文件 vi /etc/ssh/sshd_config 去掉port 22的注释,添加新的端口配置 port your_port_num 自定义端口选择建 ...
- 怎样预防Ddos攻击
一.为何要DDOS? 随着Internet互联网络带宽的增加和多种DDOS黑客工具的不断发布,DDOS拒绝服务攻击的实施越来越容易,DDOS攻击事件正在成上升趋势.出于商业竞争.打击报复和网络敲诈等多 ...
- 使用DDOS deflate抵御少量DDOS攻击
DDoS-Deflate是一款非常小巧的防御和减轻DDoS攻击的工具,它可以通过监测netstat来跟踪来创建大量互联网连接的IP地址信息,通过APF或IPTABLES禁止或阻档这些非常IP地址. 工 ...
- DDoS deflate+iptables防御轻量级ddos攻击
一.查看攻击者ip #netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n 二.安装ddos deflate ...
- DDos游戏行业受攻击最多
游戏行业遭遇DDOS攻击现状. 游戏一直是最易遭受黑客攻击的行业,高居全年DDOS攻击的48%.大规模攻击居多,平均值均超过100Gbps,攻击峰值急速上升,同比2015年增加了137.1%,其中攻击 ...
- DoS(拒绝服务攻击)与DDoS(分布式拒绝服务攻击)
SYN Flood是当前最流行的DoS(拒绝服务攻击)与DDoS(分布式拒绝服务攻击)的方式之一,这是一种利用TCP协议缺陷,发送大量伪造的TCP连接请求,从而使得被攻击方资源耗尽(CPU满负荷或内存 ...
- 29.极具破坏力的DDoS:浅析其攻击及防御
一.DDoS的概念 1.什么是“DDoS”? DDoS:Distributed Denial of Service(分布式拒绝服务)攻击指借助于客户/服务器技术,将多个计算机联合起来作为攻击平台,对一 ...
随机推荐
- GeForce GTX 1080 ti安装记录
安装GeForce GTX 1080ti 安装GeForce GTX 1080ti,8+8pin需要全接,接4pin就开机显示器上会提示电源线没接完,将显示器线接在显卡上. 设置Win 10 pro ...
- 蜕变成蝶~Linux设备驱动之按键设备驱动
在上述的驱动系列博客中,我们已经了解了关于阻塞和非阻塞.异步通知.轮询.内存和I/O口访问.并发控制等知识,按键设备驱动相对来说是比较简单的,本章内容可以加深我们对字符设备驱动架构.阻塞与非阻塞.中断 ...
- IP地址在mysql的存储(IP地址和int的转换)
PHP echo ip2long('192.168.1.38'); 输出:3232235814 MYSQL SELECT INET_ATON('192.168.1.38'); 输出:323223581 ...
- [Benchmark] Codeflaws: A Programming Competition Benchmark for Evaluating Automated Program Repair Tools
Basic Information Publication: ICSE'17 Authors: Shin Hwei Tan, Jooyong Yi, Yulis, Sergey Mechtaev, A ...
- 安装redis时Newer version of jemalloc required错误解决
问题: [root@localhost redis-4.0.0]# make cd src && make allmake[1]: Entering directory `/root/ ...
- PHP实现URL长连接转短连接方法总结
短链接,通俗来说,就是将长的URL 网址,通过程序计算等方式,转换为简短的网址字符串. 这样的话其好处为:1.内容需要:2.用户友好:3.便于管理. 实现短网址(short URL)系统比较流行的算法 ...
- JAVA课程课后作业之使用递归完成回文
一.思路 1.我的想法是利用数组的做法来进行,先是用scanner录入一个String类 2.然后就是将String转化成char数组 3.递归的就是第一个和最后一个对比,然后第一个加一,最后一个减一 ...
- 怎么在Centos7 下让我的mariadb开机启动?(已解决)
以前我经常使用syscemctl工具在开机后执行 systemctl start mariadb (哈哈,打得可6,只是有点儿麻烦), 如果能开机自启动mariadb就好了. 所以,我想百度下看什么命 ...
- css学习_css浮动
1.文档流介绍 网页布局的核心就是利用css来摆放盒子, 把盒子摆放在合适的位置. css的定位机制有以下3种(网页布局一般需要3种搭配使用): a.普通流(标准流) b.浮动 1.浮动只有左右. 2 ...
- vim创建程序文件自动添加头部注释/自动文件头注释与模板定义
Vim 自动文件头注释与模板定义 在vim的配置文件.vimrc添加一些配置可以实现创建新文件时自动添加文件头注释,输入特定命令可以生成模板. 使用方法 插入模式输入模式输入seqlogic[Ente ...