forked from OWASP/Nettacker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssh.py
More file actions
41 lines (31 loc) · 1.05 KB
/
Copy pathssh.py
File metadata and controls
41 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import logging
from paramiko import AutoAddPolicy, SSHClient
from paramiko.auth_strategy import NoneAuth, Password
from nettacker.core.lib.base import BaseEngine, BaseLibrary
logging.getLogger("paramiko.transport").disabled = True
class SshLibrary(BaseLibrary):
client = SSHClient
def brute_force(self, *args, **kwargs):
host = kwargs["host"]
port = kwargs["port"]
username = kwargs["username"]
password = kwargs["password"]
connection = self.client()
connection.set_missing_host_key_policy(AutoAddPolicy())
connection.connect(
**{
"hostname": host,
"port": port,
"auth_strategy": Password(username=username, password_getter=lambda: password)
if password
else NoneAuth(username=username),
}
)
return {
"host": host,
"port": port,
"username": username,
"password": password,
}
class SshEngine(BaseEngine):
library = SshLibrary