2022 twenty-four merry days of Perl Feed

TWVycnkgQ2hyaXN0bWFzIDop

MIME::Base64 - 2022-12-18

Perl Birthday Party

On the 18th of December, to celebrate Perl's birthday, the elves organized a big party with cakes, waffles, pancakes and maple syrup.

They partied like crazy but only until exactly midnight when everyone went to bed.

The day after, the elves walked to North Pole warehouse. To open the door and disable the alarm, as every day, they called the dedicated elf "Spof" to enter the code. He typed the code and the security LCD printed "ERROR".

- Type it again, said another elf

He proceeded and, once again, got "ERROR".

- We are bad!

Then they looked at Spof, his face was all red and his eyes were all dizzy... They remembered that Spof drank a lot of maple syrup during the past day party, something like 5 glasses. And if you are not aware, elves should drink maple syrup with parsimony because else it drives them mad!

- What is the code? they asked

- TWVycnkgQ2hyaXN0bWFzIDop

- Are you sure?

- WWVz

Deciphering the code

One of the elves has a little experience with IT and he immediately thought he would test MIME::Base64 to translate this gibberish:

use MIME::Base64 qw( decode_base64 );

print decode_base64('TWVycnkgQ2hyaXN0bWFzIDop');

Bingo! He got the code Merry Christmas :) and elves were able to open the warehouse!

Secret is compromised!

But wait, now everyone is aware of the secret code, including you! This is not acceptable!

So some senior elves decided to change the code:

use Env;
use MIME::Base64 qw( encode_base64 );

print encode_base64($ENV{SECRET});

The above script is using an environment variable to pass the secret.

Make perl speak Spof's dialect

Aside from maple syrup, Spof enjoys doing some Perl scripting for himself the evening, so after this event he did (or at least he tried).

Being still confused he tried to write cHJpbnQgIk1lcnJ5IENocmlzdG1hcyA6KSIK but it was not working.

Confused but lazy, he searched the MetaCPAN for a solution and went with Acme::Base64:

use Acme::Base64;

cHJpbnQgIk1lcnJ5IENocmlzdG1hcyA6KSIK

This way, the perl interpreter could understand the base64 dialect spoken by Spof! Magic!

Conclusion

You should never feed Gremlin after midnight but you also need to monitor closely the maple syrup consumption of elves!

Gravatar Image This article contributed by: Thibault DUPONCHELLE <thibault.duponchelle@gmail.com>