【问题标题】:how to pass the argument, when dynamically decoding a base64 encoded shell script, and executing如何在动态解码 base64 编码的 shell 脚本并执行时传递参数
【发布时间】:2017-11-08 05:48:16
【问题描述】:

我有一个脚本

test.sh:

#!/bin/bash
echo "Script is executed"
echo "Input argument for this script is $1"
password="xyz"

如果我执行脚本,我会得到 ​​p>

./test.sh 你好

脚本被执行
这个脚本的输入参数是hello

因为我在脚本中有密码,所以我决定用 base64 对其进行编码

base64 test.sh > o

为了执行脚本,我正在使用(将混淆后的输出解码为输入并执行)

base64 -d o |嘘

输出是

脚本被执行
这个脚本的输入参数是

我的问题是,如何将“hello”参数传递给这个执行方法“base64 -d o | sh”

如果我尝试这个,我会得到

$ base64 -d o | sh hello
sh: hello: 没有这样的文件或目录

注意:我无法从文件中传递参数,因为它是由用户动态键入的。

【问题讨论】:

  • 可以使用临时文件吗? base64 -d o > tmp.file && sh tmp.file 你好 && rm tmp.file

标签: linux shell unix base64 pipe


【解决方案1】:

试试这个:

base64 -d o | sh -s hello

【讨论】:

    【解决方案2】:

    你可以用这个:

    base64 -d o | sh -s hello

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      • 2022-10-24
      • 2018-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多