Linux系统cc放大攻击脚本,linux – iptables:构建针对DNS放大攻击滥用的规则集

我一直致力于构建一个规则集来检测和阻止DNS放大攻击.

我卡住了,希望能在这里找到帮助.

我将在这里发布我的内容(bash脚本,与DNS有关的部分):

IPTABLES='/sbin/iptables -v'

SERVERIP=a.b.c.d

echo '################ PrevIoUsly initiated and accepted exchanges bypass rule checking #'

$IPTABLES --append INPUT -m state --state ESTABLISHED,RELATED --jump ACCEPT

echo '################################################ Allow unlimited outbound traffic #'

$IPTABLES --append OUTPUT -m state --state NEW,ESTABLISHED,RELATED --jump ACCEPT

echo '################################################################## Rules for DNS #'

# DIG ANY ISC.ORG attack preventer.

# QUESTION1: this one does not work,why!?!?

$IPTABLES --append INPUT --proto udp --dport 53 -m string --string "isc.org" --algo bm --to 65535 --jump LOG --log-prefix "iptables: UDP ISC0 "

$IPTABLES --append INPUT --proto udp --dport 53 -m string --hex-string "|03697363036f726700|" --algo bm --to 65535 --jump LOG --log-prefix "iptables: UDP ISC "

$IPTABLES --append INPUT --proto udp --dport 53 -m string --hex-string "|03697363036f726700|" --algo bm --to 65535 --jump DROP

# DNS DNSIPSOK list

$IPTABLES --new DNSFLOODRULES

$IPTABLES --append DNSFLOODRULES --source 127.0.0.1 --jump RETURN

$IPTABLES --append DNSFLOODRULES --source $SERVERIP --jump RETURN

$IPTABLES --append DNSFLOODRULES --jump LOG --log-prefix "iptables: UDP BLOCK "

$IPTABLES --append DNSFLOODRULES --jump ACCEPT

#$IPTABLES --append DNSFLOODRULES --jump DROP

# I have it turned off right now,because

echo '# S & D port rules'

# DNS limit rule for standard acceptance

# QUESTION2: can't get the connbytes to work properly :(

$IPTABLES --append INPUT --proto udp --source 0/0 --dport 53 \

-m state --state NEW \

-m connbytes --connbytes 75 --connbytes-dir reply --connbytes-mode bytes

-m limit --limit 1/s --limit-burst 10 --jump ACCEPT

# DNS log / drop the abusers EXEPT the whitelisted IP numbers

$IPTABLES --append INPUT --proto udp --source 0/0 --dport 53 -m state --state NEW --jump DNSFLOODRULES

$IPTABLES --append INPUT --proto udp --source 0/0 --sport 53 -m state --state NEW --jump DNSFLOODRULES

# DNS allow the whitelisted IP numbers

$IPTABLES --append INPUT --proto udp --source 0/0 --dport 53 -m state --state NEW --jump ACCEPT

$IPTABLES --append INPUT --proto udp --source 0/0 --sport 53 -m state --state NEW --jump ACCEPT

问题1:

为什么它需要是十六进制字符串,普通的字符串会更容易维护,但是那个字节不会字节,你能告诉我为什么吗?

问题2:

通过TCPdump我可以看到大多数答案都很小,因此需要列入白名单.还有本地主机(以及我自己的一些服务器,我广泛地查询名称服务器(DNSFLOODRULES).DNS放大攻击是一个持续激增的“大”答案,我想限制.

问题是我不能让’connbytes’部分工作.我一直在摸索它,也认为它应该是OUTPUT的艺术,因为它大约是答案的大小,而不是问题.我还尝试了“允许无限制的出站流量”部分,但这种情况非常糟糕.

非常感谢您的想法和帮助.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值