harakit/docs/peek.1

111 lines
2.9 KiB
Groff
Raw Normal View History

2024-04-17 16:37:54 -06:00
.\" Copyright (c) 2023-2024 DTB <trinity@trinity.moe>
.\" Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
2024-04-17 16:37:54 -06:00
.\"
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
2024-06-28 08:37:49 -06:00
.TH PEEK 1 2024-06-28 "Harakit X.X.X"
2024-04-17 16:37:54 -06:00
.SH NAME
2024-04-18 10:04:26 -06:00
peek \(en read from the standard input, furtively
.\"
2024-04-17 16:37:54 -06:00
.SH SYNOPSIS
peek
.RB ( -i )
.\"
2024-04-17 16:37:54 -06:00
.SH DESCRIPTION
Read input from the standard input with terminal echo disabled.
.\"
2024-04-17 16:37:54 -06:00
.SH OPTIONS
.IP \fB-i\fP
2024-06-26 09:55:32 -06:00
Allows input to come from sources other than terminals (pipes).
.\"
2024-04-17 16:37:54 -06:00
.SH DIAGNOSTICS
In the event of an error, a debug message will be printed and the program will
exit with the appropriate
.BR sysexits.h (3)
error code.
2024-04-17 16:37:54 -06:00
In order to ensure the user\(cqs terminal is still usable after premature
termination, the program attempts to handle the SIGINT signal; if it cannot,
an error message is printed and execution continues. If the program is
interrupted, it exits unsuccessfully without an error message.
.\"
.SH RATIONALE
This tool was originally written to accept passwords in shell scripts as an
extremely simple alternative to the GNU Privacy Guard project\(cqs
.BR pinentry (1)
utility.
2024-04-17 16:37:54 -06:00
Accepting input without showing what is being typed is useful when keying in
secrets in public settings or in places where surveillance cameras are
installed.
.\"
.SH CAVEATS
2024-04-17 16:37:54 -06:00
This program does nothing to prevent others from seeing the key presses input to
a keyboard. It also does not protect against the sound of typing being analyzed
2024-06-28 08:37:49 -06:00
to determine what was input without needing to see screen or keyboard.
2024-04-17 16:37:54 -06:00
Accepting secrets in shell scripts is probably not advisable.
2024-04-17 16:37:54 -06:00
On systems that support it, the
.BR ioctl (2)
command TIOCSTI can be used to insert characters into the standard input. This
doesn't allow snooping but can be used for general mischief.
.\"
2024-04-17 16:37:54 -06:00
.SH EXAMPLES
This is an
.BR sh (1p)
command line that hashes a given password. It uses
.BR head (1p)
to only accept one line of input,
.BR xargs (1p)
and
.BR printf (1p)
to strip the trailing newline,
.BR htpasswd (1)
from Apache\(cqs utilities to hash the input with the bcrypt algorithm, and
.BR cut (1p)
to print only the resulting hash:
2024-04-17 16:37:54 -06:00
.RS
$ peek | head -n 1 | xargs printf '%s' | htpasswd -nBi _ | cut -d : -f 2
2024-04-17 16:37:54 -06:00
.RE
This is an
.BR sh (1p)
command line that allows a user to write blindly into a text file but displaying
only written lines. Some writers have the habit of prematurely revising their
work and use tools with functionality similar to this to prevent it.
It uses
.BR mm (1)
to pipe the output of the program to both the standard error and the regular
file writing.txt:
2024-04-17 16:37:54 -06:00
.RS
$ echo Input ^D to quit. && peek | mm -eo - >writing.txt
2024-04-17 16:37:54 -06:00
.RE
.\"
2024-04-17 16:37:54 -06:00
.SH AUTHOR
Written by DTB
.MT trinity@trinity.moe
.ME .
.\"
2024-04-17 16:37:54 -06:00
.SH COPYRIGHT
Copyright \(co 2023-2024 DTB. License AGPLv3+: GNU AGPL version 3 or later
2024-04-17 16:37:54 -06:00
<https://gnu.org/licenses/gpl.html>.
.\"
2024-04-17 16:37:54 -06:00
.SH SEE ALSO
.BR ioctl (2),
.BR ioctl_tty (2),
.BR read (1),
.BR sh (1)