Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenSSL: Bad magic number using command line tool

For background, I am working through the Matasano Crypto Challenges. One of the problems (Set1, Challenge 7) is to decrypt an AES-128 ECB mode file with a given key, YELLOW SUBMARINE.

The file is base64 encoded and I can decrypt the file in Python but I cannot using the Windows 10 openssl command line tool.

The command I am running is:

openssl aes-128-ecb -d -a -in 7.txt -pass pass:"YELLOW SUBMARINE"

When I run this I am told that I have a bad magic number.

Does anyone have an idea of why I am getting this error?

like image 597
user668074 Avatar asked Sep 13 '25 09:09

user668074


1 Answers

Looks like the -pass option doesn't like the space in the passphrase.

You can use the option -K with the hexadecimal key like this:

openssl aes-128-ecb -d -a -K 59454c4c4f57205355424d4152494e45 -in 7.txt

Or use the passphrase directly with this command:

openssl aes-128-ecb -d -a -in 7.txt -K  $(echo -n "YELLOW SUBMARINE" | hexdump -v -e '/1 "%02X"')
like image 65
oliv Avatar answered Sep 16 '25 05:09

oliv