Skip to content

Instantly share code, notes, and snippets.

@KINGSABRI
Last active June 7, 2016 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KINGSABRI/baae12a5b4e4786c8cdd830dc9d35228 to your computer and use it in GitHub Desktop.
Save KINGSABRI/baae12a5b4e4786c8cdd830dc9d35228 to your computer and use it in GitHub Desktop.
# Reproduce
## Terminal 1
ncat -lvp 5555 -e /bin/sh
## Terminal 2
ncat -v localhost 5555
# Python pty spawn
python -c 'import pty; pty.spawn("/bin/bash")'
# test interactive mode with interactive linux command
passwd
# Ruby tries - didn't work
ruby -r 'pty' -e 'PTY.getpty("/bin/bash")'
ruby -r 'pty' -e 'PTY.spawn("/bin/bash")'
ruby -e 'puts exec("/bin/bash")'
ruby -e 'puts system("/bin/bash")'
ruby -e 'IO.popen("/bin/bash") { |f| puts f.gets }'
ruby -e '%x"/bin/bash"'
ruby -r 'pty' -r 'expect' -e 'PTY.getpty("/bin/bash"){|i, o| o.sync = true; i.expect(/.*/) {|l| puts l,o}}'
ruby -r 'pty' -r 'expect' -e 'PTY.getpty("/bin/bash"){|i, o| o.sync = true; i.expect(/.*/) {|l| puts l,o; o.flush} }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment