ariary / console.sh

Share terminal in your browser console
The Unlicense
4 stars 0 forks source link
browser-extension console golang hack reverse-shell shell websocket

console.sh

Execute shell command from browser console (developer tools)

Usage

Launch websocket server:

console.sh

Open browser console (certainly with Shift + CTRL + K or Shift + ⌘ + K). Copy/paste within:

s=new WebSocket("wss://localhost:8080/sh"),s.onmessage=function(ev){console.log(ev.data)};function sh(cmd){s.send(cmd)};function promptsh(){cmd=prompt();s.send(cmd)};Object.defineProperty(window, 'psh', { get: promptsh });

Now you are able to execute shell command from browser console with:

> sh("[command]")
//OR (alternative)
> sh`[command]`
//OR (prompted version)
> psh

N.B:

Why?

Why not! The need does not inspire the feature, it's the other way around (s/o Apple philosophy)

Otherwise, see remote use

Set-up

Install console.sh:

curl -lO -L https://github.com/ariary/console.sh/releases/latest/download/console.sh
chmod +x console.sh
# or with go
go install github.com/ariary/console.sh@latest

Then as you have to launch the websocket server with certificates (otherwise browsers won't accept connection). Create cert and key in the same directory:

mkcert -install
mkcert -key-file key.pem -cert-file cert.pem localhost 127.0.0.1 ::1 # Many way to do it, openssl etc => key: key.pem and cert: cert.pem

Remote Code execution

console.sh can also be launched on a remote device. The main advantage of this is to browse internet while having a quick access to a kind of remote shell.

To make it works, Install mkcert CA in your local trust store and build console.sh like this before transfer it on remote:

mkcert -install
./build-embed.sh [REMOTE_URL] #directly embed cert,key in binary

Browser extension (WIP)

Using the extension you can quickly run command on a remote host while browsing the web:

Some challenges still need to be overcome (see)

Notes