diff options
| author | jerome <jerome@xlinfo.fr> | 2025-10-12 17:41:43 +0200 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2025-10-12 17:41:43 +0200 |
| commit | ec8893a097a6c0fffebd7db9e4a5568a3bf4df47 (patch) | |
| tree | ffebe60c3aa98df05d14aec8cea937430272c1ec /bruteforce/sshClient.py | |
| parent | ba41fa46e69dbb264dfbed1b9fca5daab44a07c7 (diff) | |
| download | python-ec8893a097a6c0fffebd7db9e4a5568a3bf4df47.tar.gz python-ec8893a097a6c0fffebd7db9e4a5568a3bf4df47.zip | |
organisation
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") |
