Decrypting a file with XOR on the shell

I suspected some firmware file to be encrypted/obfuscated with a simple XOR bit operation, and needed a command line tool for it.

In the end I found xortool-xor that is part of the pip-installable xortool. It can be used as follows:

$ echo "foo bar baz" | xortool-xor -r secretkey --no-cycle -f - > test.enc
$ xortool-xor --no-cycle -r secretkey -f test.enc
foo bar baz


$

I used the --no-cycle parameter because the length of the encrypted data need to be a multiple of the key length. This is not the case in my example, and I wanted no strange data appended at the end.

Written by Christian Weiske.

Comments? Please send an e-mail.