简体   繁体   English

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

[英]how to pass the argument, when dynamically decoding a base64 encoded shell script, and executing

I have a script 我有一个剧本

test.sh: test.sh:

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

If I execute the script, I am getting 如果执行脚本,我将得到

./test.sh hello ./test.sh你好

Script is executed 脚本执行
Input argument for this script is hello 该脚本的输入参数是hello

As I have the password in the script, I decided to encode it with base64 由于脚本中包含密码,因此我决定使用base64对其进行编码

base64 test.sh > o base64 test.sh> o

To execute the script, I am using (decoding the obfuscated output to input and executing) 为了执行脚本,我正在使用(将混淆后的输出解码为输入并执行)

base64 -do | base64 -do | sh SH

output is 输出是

Script is executed 脚本执行
Input argument for this script is 该脚本的输入参数是

My question is, how can I pass the "hello" argument to this execution method "base64 -do | sh" 我的问题是,如何将“ hello”参数传递给此执行方法“ base64 -do | sh”

if I try this, I am getting 如果我尝试这个,我会

$ base64 -do | $ base64 -do | sh hello 你好
sh: hello: No such file or directory sh:你好:没有这样的文件或目录

Note: I cannot pass the argument from a file, as it is keyyed-in by the user dynamically. 注意:我无法从文件传递参数,因为它是用户动态键入的。

尝试这个:

base64 -d o | sh -s hello

您可以使用此:

base64 -do | sh -s hello

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM