Piping(√)

简介: 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”需要从您那里得到什么!

相关文章
|
域名解析 网络协议
kali2023.1 网络配置
kali2023.1 网络配置
573 0
|
数据采集 存储 监控
如何使用 Python 爬取京东商品数据
如何使用 Python 爬取京东商品数据
2519 0
|
安全 网络协议 前端开发
Windows下nmap命令及Zenmap工具的使用方法
【7月更文挑战第28天】zenmap是一个开放源代码的网络探测和安全审核的工具,它是nmap安全扫描工具的图形界面前端,它可以支持跨平台。使用zenmap工具可以快速地扫描大型网络或单个主机的信息。如扫描主机提供了哪些服务,使用的操作系统等。
2764 8
|
JavaScript 前端开发
15 Uncaught TypeError: Cannot set properties of null (setting ‘onclick‘)
这篇文章解释了在HTML文档中因JavaScript代码在页面元素加载之前执行导致的"Cannot set properties of null (setting ‘onclick’)"错误,并提供了将JavaScript代码置于`<body>`标签内或使用`window.onload`事件确保DOM完全加载后再绑定事件处理器的解决办法。
15 Uncaught TypeError: Cannot set properties of null (setting ‘onclick‘)
|
JSON API 数据格式
从基础到高级,带你深入了解和使用curl命令(四)
本文介绍了如何使用curl命令发送GET和POST请求。发送GET请求的基本语法是`curl [URL]`,加参数时使用`&`连接。添加`-v`参数可显示详细输出。发送POST请求,使用`-X POST -d`传表单数据,或`-d -H &quot;Content-Type: application/json&quot;`发送JSON数据,用`-F &quot;file=@path&quot;`上传文件,`--data-binary`用于上传二进制数据。curl是一个功能强大的HTTP请求工具,适用于各种网络通信需求。
|
机器学习/深度学习 自然语言处理
一文搞懂Transformer的位置编码
一文搞懂Transformer的位置编码
6494 2
|
机器学习/深度学习 人工智能 PyTorch
深度学习四大框架之争(Tensorflow、Pytorch、Keras和Paddle)
深度学习四大框架之争(Tensorflow、Pytorch、Keras和Paddle)
深度学习四大框架之争(Tensorflow、Pytorch、Keras和Paddle)
|
网络安全 数据安全/隐私保护
SNMP客户端MIB Browser的使用
SNMP客户端MIB Browser的使用
6260 0
|
Java Python Windows
Python pip 源设置成国内源,阿里云源,清华大学源,最方便的方式,都在这里了
Python pip 源设置成国内源,阿里云源,清华大学源,最方便的方式,都在这里了
96954 1