Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. import os
  2. import sys
  3. import time
  4. import paramiko
  5. import subprocess
  6. message="Use 1 to copy script from server and start an atom instance on it or 2 to upload it on the server.\n"
  7. print message
  8. ssh = paramiko.SSHClient()
  9. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  10. user="target"
  11. password="qwertyuiop12345689010"
  12. host="45.79.206.221"
  13. port=22
  14. if len(sys.argv) < 2:
  15. print "You need to give me a file first! Run python "+sys.argv[0]+" <filename>"
  16. sys.exit()
  17. else:
  18. thefile=sys.argv[1]
  19. c=raw_input("Choose 1 or 2: ")
  20. if int(c) == 1:
  21. ssh.connect(host, port=port, username=user, password=password, timeout=3)
  22. stdin, stdout, stderr = ssh.exec_command("curl --upload-file ./"+thefile+" https://transfer.sh/"+thefile)
  23. link = stdout.read()
  24. print "We git link! - %r \n" % link
  25. print "Downloading..."
  26. time.sleep(0.5)
  27. os.system("wget %r"%link)
  28. time.sleep(0.2)
  29. os.system("atom "+thefile)
  30. sys.exit(0)
  31. elif int(c) == 2:
  32. proc = subprocess.Popen(["curl --upload-file ./"+thefile+" https://transfer.sh/"+thefile], stdout=subprocess.PIPE, shell=True)
  33. (out, err) = proc.communicate()
  34. print out
  35. ssh.connect(host, port=port, username=user, password=password, timeout=3)
  36. time.sleep(2)
  37. ssh.exec_command("rm "+thefile)
  38. ssh.exec_command("cd art/")
  39. ssh.exec_command("wget %r" % out)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement