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

目录
相关文章
|
3月前
|
机器学习/深度学习 分布式计算 数据处理
分布式计算框架:并行力量的交响乐章
分布式计算框架如Apache Spark解决单机计算挑战,通过拆分任务到多机并行处理提升效率。Spark以其内存计算加速处理,支持批处理、查询、流处理和机器学习。以下是一个PySpark统计日志中每日UV的示例,展示如何利用SparkContext、map和reduceByKey进行数据聚合分析。这些框架的运用,正改变大数据处理领域,推动数据分析和机器学习的边界。【6月更文挑战第18天】
129 2
BUUCTF--misc--大白1
BUUCTF--misc--大白1
|
1月前
|
弹性计算 Kubernetes 安全
Kubernetes 的架构问题之在Serverless Container中保障应用的安全防护如何解决
Kubernetes 的架构问题之在Serverless Container中保障应用的安全防护如何解决
144 8
|
1月前
|
人工智能
多模态AI单词助记模型体验
一文带你了解多模态AI单词助记模型的优与劣
177 1
|
1月前
|
Java UED
基于SpringBoot自定义线程池实现多线程执行方法,以及多线程之间的协调和同步
这篇文章介绍了在SpringBoot项目中如何自定义线程池来实现多线程执行方法,并探讨了多线程之间的协调和同步问题,提供了相关的示例代码。
177 0
|
2月前
|
人工智能 编解码 API
通义万相AIGC技术测评报告
**摘要:** 通义万相是阿里云的AI绘画模型,提供清晰的部署指南和易用的API,适合新手。资源部署耗时约10分钟,API响应快,支持多种风格图片生成,适用于广告、媒体等领域。产品性价比高,功能包括文本到图像转换等,但仍有改进空间,如增加服装纹理选项、互动功能和更多API接口。建议完善功能、加强推广和降低成本以吸引更多用户。[链接](https://developer.aliyun.com/topic/tongyi-wanxiang?spm=a2c6h.27063436.J_6978680750.5.3a774f461hv8qD)
155 6
|
3月前
|
机器学习/深度学习 Python Windows
Python---Anaconda安装
Python---Anaconda安装
131 2
|
3月前
|
JSON 缓存 移动开发
原创自研uniapp+vue3手机桌面os管理系统
vue3-uniapp-os一款基于uniapp+vue3跨端手机版后台os系统新解决方案。
214 3
|
4月前
|
自然语言处理 安全 机器人
使用RAG-GPT和Ollama搭建智能客服
使用RAG-GPT和Ollama搭建智能客服
223 0
|
SQL 安全 网络安全
Sqlmap学习 -- Tamper绕过脚本
Sqlmap学习 -- Tamper绕过脚本
880 0