diff --git a/simpleDDoS/__init__.py b/simpleDDoS/__init__.py index 4795a4e..a786be0 100644 --- a/simpleDDoS/__init__.py +++ b/simpleDDoS/__init__.py @@ -3,3 +3,16 @@ __app_name__ = 'simple_ddos' __version__ = "0.1.0" + +# import socket +# +# ( socket.gaierror, +# KeyboardInterrupt, +# NameError +# ) = range(3) +# +# ERRORS = { +# KeyboardInterrupt: 'Keyboard Interrupt. Terminating session...', +# socket.gaierror: 'Unknown address.' + '\n' + 'Please input the correct ip address.', +# NameError: 'Unknown address.' + '\n' + 'Please input the correct ip address.' +# } \ No newline at end of file diff --git a/simpleDDoS/__main__.py b/simpleDDoS/__main__.py index e69de29..280504a 100644 --- a/simpleDDoS/__main__.py +++ b/simpleDDoS/__main__.py @@ -0,0 +1,10 @@ +"""Top-level package for Simple DDoS.""" +# simpleDDoS/__main__.py + +from simpleDDoS import cli, __app_name__ + +def main(): + cli.app(prog_name=__app_name__) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/simpleDDoS/ddos.py b/simpleDDoS/ddos.py index 1ebea0c..e464a18 100644 --- a/simpleDDoS/ddos.py +++ b/simpleDDoS/ddos.py @@ -11,12 +11,6 @@ import socket # 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 # Instead of using SOCK_STREAM for TCP connections @@ -48,21 +42,12 @@ def check_os(): 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 init_app(target, port, ipaddress): sent = 0 try: while True: @@ -78,15 +63,15 @@ def ddos(target, port, ipaddress): # Break out of infinite loop except KeyboardInterrupt: - print('\n' + R + '[!]' + C + 'Keyboard Interrupt. Terminating session...' + W) + print('\n' + 'Keyboard Interrupt. Terminating session...') except socket.gaierror: - print(R + '[-] ' + C + 'Unknown address.') - print(R + '[-] ' + C + 'Please input the correct ip address.') + print('Unknown address.') + print('Please input the correct ip address.') except NameError: - print(R + '[-] ' + C + 'Unknown address.') - print(R + '[-] ' + C + 'Please input the correct ip address.') + print('Unknown address.') + print('Please input the correct ip address.') # For introducing to the script later diff --git a/simpleDDoS/tests/__init__.py b/simpleDDoS/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/simpleDDoS/tests/test_running_ddos.py b/simpleDDoS/tests/test_running_ddos.py new file mode 100644 index 0000000..493b0f1 --- /dev/null +++ b/simpleDDoS/tests/test_running_ddos.py @@ -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() diff --git a/simpleDDoS/tests/test_simpleDDoS_cli.py b/simpleDDoS/tests/test_simpleDDoS_cli.py new file mode 100644 index 0000000..3322704 --- /dev/null +++ b/simpleDDoS/tests/test_simpleDDoS_cli.py @@ -0,0 +1,12 @@ +# tests/test_rptodo.py + +from typer.testing import CliRunner + +from .. 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 \ No newline at end of file