Last active
June 23, 2018 21:25
-
-
Save obfusk/7f081ca7a0eae946fc7fc6821b4680b4 to your computer and use it in GitHub Desktop.
m-over-reverse-ssh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cleanup() { | |
trap - EXIT INT TERM HUP | |
rm -f ~/._m_fifo_{i,o} | |
} | |
echo CLIENT SSH >&2 | |
mkfifo ~/._m_fifo_{i,o} | |
trap cleanup EXIT; trap exit INT TERM HUP | |
{ while cat ~/._m_fifo_o; do :; done; } & cat > ~/._m_fifo_i; wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cleanup() { | |
trap - EXIT INT TERM HUP | |
kill 0 | |
} | |
echo CLIENT >&2 | |
trap cleanup EXIT; trap exit INT TERM HUP | |
{ while cat ~/._m_fifo_i; do :; done; } & | |
while read -r -p ">>> "; do | |
echo "$REPLY" > ~/._m_fifo_o; sleep 0.1 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cleanup() { | |
trap - EXIT INT TERM HUP | |
rm -f ~/._m_fifo | |
} | |
echo SERVER SSH >&2 | |
mkfifo ~/._m_fifo | |
trap cleanup EXIT; trap exit INT TERM HUP | |
run() { "$@"; } # ssh THE_CLIENT "$@" | |
run ./client-ssh.sh < ~/._m_fifo | ./server.sh > ~/._m_fifo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo SERVER >&2 | |
while read -r; do | |
echo "[$REPLY]" >&2 | |
case "$REPLY" in | |
pwd) echo pwd ;; | |
"cd "*) echo cd "${REPLY:3}" ;; | |
ls) echo m ls -n ;; | |
next) echo m next ;; | |
"play "*) echo m play -- "${REPLY:5}" ;; | |
p) echo xdotool key space ;; | |
quit) echo xdotool key alt+f4 ;; | |
*) echo unknown command ;; | |
esac | |
echo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment