diff options
Diffstat (limited to 'bruteforce/sshClient.py')
| -rw-r--r-- | bruteforce/sshClient.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/bruteforce/sshClient.py b/bruteforce/sshClient.py new file mode 100644 index 0000000..41dabb4 --- /dev/null +++ b/bruteforce/sshClient.py @@ -0,0 +1,24 @@ +import sys, paramiko, getpass + +def sshClient(hostname,port,cmd,username,password): + client = paramiko.SSHClient() + client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + try: + client.connect(hostname,port=port,username=username, password=password) + _stdin, _stdout,_stderr = client.exec_command(cmd) + print(_stdout.read().decode()) + except paramiko.ssh_exception.AuthenticationException: + print("Erreur d'authenfication !") + finally: + client.close() + +if __name__ == "__main__": + try: + hostname = sys.argv[1] + port = sys.argv[2] + cmd = sys.argv[3] + username = input("Nom d'utilisateur : ") + password = getpass.getpass() + sshClient(hostname,port,cmd,username,password) + except IndexError: + print(f"{sys.argv[0]} demande des arguments") |
