Guest User

Untitled

a guest
Nov 9th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import paramiko
  3. import base64
  4.  
  5. # Run in /mnt/c/Users/<username>/AppData/Local/Xamarin/MonoTouch
  6. # Unfortunately this does NOT work yet, as I do not understand the passphrase.key
  7. # file contents entirely (it appears to be bytes inside the base64 encoded string)
  8. # and how to use it as the SSH key.
  9.  
  10. with open("passphrase.key", 'r') as file:
  11. passphrase = base64.b64decode(file.read())
  12.  
  13. k = paramiko.RSAKey.from_private_key_file("id_rsa", password=passphrase)
  14. c = paramiko.SSHClient()
  15. c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  16.  
  17. print "connecting"
  18.  
  19. c.connect( hostname = "<target>", username = "<username>", pkey = k )
  20. print "connected"
  21.  
  22. commands = [ "uname -a", "whoami" ]
  23. for command in commands:
  24. print "Executing {}".format( command )
  25. stdin , stdout, stderr = c.exec_command(command)
  26. print stdout.read()
  27. print( "Errors")
  28. print stderr.read()
  29. c.close()
Add Comment
Please, Sign In to add comment