From ec8893a097a6c0fffebd7db9e4a5568a3bf4df47 Mon Sep 17 00:00:00 2001 From: jerome Date: Sun, 12 Oct 2025 17:41:43 +0200 Subject: organisation --- bruteforce/sshClient.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 bruteforce/sshClient.py (limited to 'bruteforce/sshClient.py') 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") -- cgit v1.2.3