简体   繁体   中英

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

I have a script

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

Script is executed
Input argument for this script is hello

As I have the password in the script, I decided to encode it with base64

base64 test.sh > o

To execute the script, I am using (decoding the obfuscated output to input and executing)

base64 -do | 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"

if I try this, I am getting

$ base64 -do | sh hello
sh: hello: No such file or directory

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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