Skip to content

Commit 9bdb940

Browse files
authored
refactor: use class attribute for SSH and Telnet client instantiation (#1068)
1 parent d77becc commit 9bdb940

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

nettacker/core/lib/ssh.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99

1010

1111
class SshLibrary(BaseLibrary):
12+
client = SSHClient
13+
1214
def brute_force(self, *args, **kwargs):
1315
host = kwargs["host"]
1416
port = kwargs["port"]
1517
username = kwargs["username"]
1618
password = kwargs["password"]
1719

18-
connection = SSHClient()
20+
connection = self.client()
1921
connection.set_missing_host_key_policy(AutoAddPolicy())
2022
connection.connect(
2123
**{

nettacker/core/lib/telnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class TelnetLibrary(BaseLibrary):
77
client = telnetlib.Telnet
88

99
def brute_force(self, host, port, username, password, timeout):
10-
connection = telnetlib.Telnet(host, port, timeout)
10+
connection = self.client(host, port, timeout)
1111
connection.read_until(b"login: ")
1212
connection.write(username.encode("utf-8") + b"\n")
1313
connection.read_until(b"Password: ")

0 commit comments

Comments
 (0)