Piping(√)

标准输入,标注输出,标注错误输出 【stdin,stdout,stderr】

level 1 重定向 标准输出 写入文件

echo PWN > COLLEGE

level 2 重定向 程序输出 写入文件

/challenge/run > myflag

level 3 重定向追加写入

/challenge/run >> the-flag

level 4 重定向错误输出

等价于 1> ,fd为1【标准输出】。
0>标准输入, 2>标准错误输出

 /challenge/run > myflag   2> instructions    # 程序两个输出分别重定向

level 5 重定向输入文件内容给程序

echo COLLEGE > PWN
/challenge/run < PWN

level 6 grep筛选指定数据行【将输出数据存储后筛选】

grep "pwn.college" data.txt
pwn.college{w8bTSXyLhnyY7JYcKUjjRANXKKk.dhTM4QDLwYTM2QzW}

level 7 grep 与 | 筛选指定数据行【不存储直接筛选】

./run | grep pwn.college
pwn.college{Uo2csJwSWCIW7jC3hmF2VnSw1rM.dlTM4QDLwYTM2QzW}

level 8 标准错误输出重定向到标准输出并使用grep筛选

“|”运算符仅将标准输出重定向到另一个程序,并且不存在运算符的“2|”形式!
它可以重定向标准输出(文件描述符1)。

hacker@piping~grepping-errors:/challenge$ ./run 2>&1| grep pwn.college
[INFO] WELCOME! This challenge makes the following asks of you:
[INFO] - the challenge checks for a specific process at the other end of stderr : grep
[INFO] - the challenge will output a reward file if all the tests pass : /challenge/.data.txt

[HYPE] ONWARDS TO GREATNESS!

[INFO] This challenge will perform a bunch of checks.
[INFO] If you pass these checks, you will receive the /challenge/.data.txt file.

[TEST] You should have redirected my stderr to another process. Checking...
[TEST] Performing checks on that process!

[INFO] The process' executable is /usr/bin/grep.'
[INFO] This might be different than expected because of symbolic links (for example, from /usr/bin/python to /usr/bin/python3 to /usr/bin/python3.8).
[INFO] To pass the checks, the executable must be grep.

[PASS] You have passed the checks on the process on the other end of my stderr!
[PASS] Success! You have satisfied all execution requirements.
pwn.college{Ad3t-Y49HHZS2fcpBJXEfTtDtRw.dVDM5QDLwYTM2QzW}

level 9 【⭐⭐⭐】

   将一个bash文件运行【添加特定参数】的输出数据**通过管道符**传递给另一个bash文件【不能改变第二个bash文件内容】通过第二个bash获得flag。
hacker@piping~duplicating-piped-data-with-tee:/challenge$ /challenge/pwn --secret 8hKE-9lb  | /challenge/college
Processing...
Correct! Passing secret value to /challenge/college...
Great job! Here is your flag:
pwn.college{8hKE-9lbCSPdTOscjCaM6nWkxCO.dFjM5QDLwYTM2QzW}

tee命令

When you pipe data from one command to another, you of course no longer see it on your 
screen.
This is not always desired: for example, you might want to see the data as it flows 
through between your commands to debug unintended outcomes 
(e.g., "why did that second command not work???").

Luckily, there is a solution!
The `tee` command, named after a "T-splitter" from _plumbing_ pipes, duplicates data 
flowing through your pipes to any number of files provided on the command line.
For example:

```console
hacker@dojo:~$ echo hi | tee pwn college
hi
hacker@dojo:~$ cat pwn
hi
hacker@dojo:~$ cat college
hi
hacker@dojo:~$

As you can see, by providing two files to tee, we ended up with three copies of the
piped-in data: one to stdout, one to the pwn file, and one to the college file.
You can imagine how you might use this to debug things going haywire:

hacker@dojo:~$ command_1 | command_2
Command 2 failed!
hacker@dojo:~$ command_1 | tee cmd1_output | command_2
Command 2 failed!
hacker@dojo:~$ cat cmd1_output
Command 1 failed: must pass --succeed!
hacker@dojo:~$ command_1 --succeed | command_2
Commands succeeded!

Now, you try it!
This process’ /challenge/pwn must be piped into /challenge/college,
but you’ll need to intercept the data to see what pwn needs from you!

```shell
当您将数据从一个命令管道传输到另一个命令时,您当然不会再在屏幕上看到它。
这并不总是可取的:例如,您可能希望看到数据在命令之间流动,以调试意外结果
(例如,“为什么第二个命令不起作用??”)。
幸运的是,有一个解决方案!
“tee”命令以_pluming_pipes中的“T形拆分器”命名,
它将流经管道的数据复制到命令行上提供的任意数量的文件中。
例如:
```console
hacker@dojo:~$ echo hi | tee pwn college
hi
hacker@dojo:~$ cat pwn
hi
hacker@dojo:~$ cat college
hi
hacker@dojo:~$

正如您所看到的,通过向“tee”提供两个文件,我们最终得到了管道输入数据的三个副本:一个到stdout,一个到“pwn”文件,一个给“college”文件。
您可以想象如何使用它来调试失控的事情:

hacker@dojo:~$ command_1 | command_2
Command 2 failed!
hacker@dojo:~$ command_1 | tee cmd1_output | command_2
Command 2 failed!
hacker@dojo:~$ cat cmd1_output
Command 1 failed: must pass --succeed!
hacker@dojo:~$ command_1 --succeed | command_2
Commands succeeded!

现在,你试试看!
这个过程“/chamlley/pwn”必须通过管道传输到“/chamble/college”,但您需要截取数据,看看“pwn”需要从您那里得到什么!

相关推荐

  1. Piping(√)

    2024-07-21 01:16:03       15 阅读
  2. pip使用

    2024-07-21 01:16:03       46 阅读
  3. The Water Pipe with a Building

    2024-07-21 01:16:03       50 阅读
  4. ERROR Broken pipie

    2024-07-21 01:16:03       42 阅读
  5. pipx和conda

    2024-07-21 01:16:03       31 阅读
  6. pip安装加速】pip 更换清华源

    2024-07-21 01:16:03       45 阅读
  7. Linux系统如何安装pip pip3

    2024-07-21 01:16:03       20 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-21 01:16:03       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-21 01:16:03       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-21 01:16:03       45 阅读
  4. Python语言-面向对象

    2024-07-21 01:16:03       55 阅读

热门阅读

  1. KTV点歌系统有什么作用?

    2024-07-21 01:16:03       16 阅读
  2. Flutter 状态管理调研总结

    2024-07-21 01:16:03       18 阅读
  3. Elasticsearch 使用terms对long类型日期统计按月销售

    2024-07-21 01:16:03       18 阅读
  4. 轮播图变成响应式数据

    2024-07-21 01:16:03       19 阅读
  5. 基于python实现医院信息管理系统的设计与实现

    2024-07-21 01:16:03       18 阅读