Loading... # 1、ssh 连接 pwn.college ```bash ssh -i C:\Users\abao\key hacker@dojo.pwn.college ``` # 2、Linux 知识总结 ## 2.1、环境变量相关 参考 Linux env 命令: ```bash hacker@embryoio_level25:~$ env --help Usage: env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...] Set each NAME to VALUE in the environment and run COMMAND. Mandatory arguments to long options are mandatory for short options too. -i, --ignore-environment start with an empty environment -0, --null end each output line with NUL, not newline -u, --unset=NAME remove variable from the environment -C, --chdir=DIR change working directory to DIR -S, --split-string=S process and split S into separate arguments; used to pass multiple arguments on shebang lines -v, --debug print verbose information for each processing step --help display this help and exit --version output version information and exit A mere - implies -i. If no COMMAND, print the resulting environment. ``` 执行一个命令并清空其环境变量: ```bash env -i /challenge/embryoio_level15 ``` 执行一个命令并设置指定环境变量: ```bash env name=value python my_script.py ``` # 3、python 知识总结 ## 3.1、subprocess 相关 参考:[subprocess](https://docs.python.org/3/library/subprocess.html) 如下示例,创建一个子进程 /challenge/embryoio_level25,携带一个命令行参数为 yiehttesuv,并设置子进程环境变量 "puyxbm" = "bqhghvxvwm",同时将输入重定向到 /tmp/bbb.txt 文件: ```python import subprocess with open("/tmp/bbb.txt", 'r') as fd: subprocess.run(["/challenge/embryoio_level25", "yiehttesuv"], env={"puyxbm":"bqhghvxvwm"}, stdin=fd) ``` # 3、shell 编程 demo ```bash #!/bin/bash stdin_file="/tmp/trdcda" password="xqwyyasy" tmp_py="./19.py" if [ -f $stdin_file ] then rm $stdin_file fi if [ -f $tmp_py ] then rm $tmp_py fi touch $stdin_file echo $password > $stdin_file touch $tmp_py echo "import subprocess" > $tmp_py echo "with open('$stdin_file') as fd:" >> $tmp_py echo " subprocess.run([\"/challenge/embryoio_level19\"], stdin=fd)" >> $tmp_py echo "" >> $tmp_py ipython $tmp_py ``` 最后修改:2022 年 09 月 14 日 11 : 06 PM © 允许规范转载