简体   繁体   English

从base64解码并执行命令

[英]Decode from base64 and execute command

I want to execute command on Linux box, but I should send commands on base64 format.我想在 Linux 机器上执行命令,但我应该以 base64 格式发送命令。

How can I decode base64 string on Linux command and then execute the decoded string?如何在 Linux 命令上解码 base64 字符串,然后执行解码后的字符串?

Use base64 -d :使用base64 -d

# 'string' variable contains a base64 encoded command
command=$(base64 -d <<< "$string"); decode_status=$?
# run the command only if decode was successful
# we shouldn't enclose $command in double quotes in this case
[[ $decode_status == 0 ]] && $command

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

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