TL;DR No, you are not 100% safe. Or with other words, think twice. ;)
Don't execute code snippets without understanding the basics. Use man
to learn more about a command or a program. Use Google or an other search portal if you don't understand. And if you still doubt, simply do not execute the code.
Do you trust me? Then run:
man man
Ok, not dangerous, you see the man-page of man
But what about the code below, do you trust me?
$(perl -MMIME::Base64 -0777ne 'print decode_base64($_)' <<< "ZWNobyAnQk9PSCEnCg==")
Not? Good idea. Let's breakdown the code:
perl
The Perl language interpreter
-MMIME::Base64
Encoding and decoding of base64 strings
-0777ne
-0777
- Changes the line separator to undef, letting us to slurp the file, feeding all the lines to Perl in one go.
-e
- (execute) flag is what allows us to specify the Perl code we want to run right on the command line.
-n
- Feed the input to Perl line by line.
'print decode_base64($_)'
- Decodes a string, the string is saved in $_
.
"ZWNobyAnQk9PSCEnCg=="
- And this? What is this?
Let's start a test.
We know, it's something like base64 and it looks encoded. Therefore decode the string with:
base64 --decode <<< "ZWNobyAnQk9PSCEnCg=="
And the output is … ok, not really dangerous:
echo 'BOOH!'
Now, we can do the same with perl
perl -MMIME::Base64 -0777ne 'print decode_base64($_)' <<< "ZWNobyAnQk9PSCEnCg=="
And the output is, what a surprise:
echo 'BOOH!'
But was it dangerous? This is dangerous:
$(…)
This construct executes the output of the commands in the round brackets.
Let's try it, do you trust me?
$(perl -MMIME::Base64 -0777ne 'print decode_base64($_)' <<< "ZWNobyAnQk9PSCEnCg==")
'BOOH!'
And what's about
c3VkbyBraWxsYWxsIG5hdXRpbHVzCg==
Try it out … Do you trust me?
sudo
. – Simon Richter Jul 17 '15 at 06:42