如何在动态解码 base64 编码的 shell 脚本和执行时传递参数



>我有一个脚本

test.sh:

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

如果我执行脚本,我会得到

./test.sh 你好

脚本

已执行
此脚本的输入参数是 hello

由于我在脚本中有密码,因此我决定使用 base64 对其进行编码

底座64 test.sh> O

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

base64 -d o | sh

输出为

脚本已执行
此脚本的输入参数为

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

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

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

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

试试这个:

base64 -d o | sh -s hello

你可以使用这个:

base64 -d o | sh -s hello

最新更新