Standard Input 标准输入
程序接收输入的默认通道,简称 stdin。 Linux/Unix 文件描述符是 0。
三种来源
# 1. 键盘(默认)
$ cat
hello ← 你输入
hello ← 程序回显
# 2. 重定向自文件
$ cat < input.txt
# 3. 管道
$ ls | grep ".md" # ls 的 stdout 变成 grep 的 stdin跟 stdout、stderr 一组
安全场景
- 永远不信任 stdin —— 是用户输入,可能是恶意 payload
- 用户输入直接传给 shell command → command injection
- 用户输入直接拼进 SQL → SQL injection