scripts to decode base64 and hex

About a month ago, I added a couple shell scripts to my DFIR Github repository. Three of the four scripts are used at work daily in either a Linux terminal, or a Cygwin terminal. The fourth script is something I use to help with quarantined mail, and not really DFIR based.

b64Decode.sh and hexConvert.bash take command line arguments and reports back the result. For example:

It works well enough. Mainly I use it for base64 encoded subject lines or links in emails. The hex version does something similar, and used for the same reason. However since the beginning of 2018, I’ve been using it to deobfuscate shell code passed via SOAP API calls.

Last week I noticed that a coworker was using a website to do the deobfuscation. Which led three of us to talk about how we see the code. I was doing it via my shell scripts (really just echo $1 | decoder of choice). Another team member was doing the same thing in Python. The guy using the website said that he wanted to be able to paste the code to a file, click a button, and have another file with the output.

Which lead me to writing Python to do just that.

b64Decoder.py

It requires the base64.txt file in the same directory as the script, and outputs b64_plain.txt to the same directory.

The Github has a compile version for people that don’t have Python on their computers. Same requirement on the text file.

hexDecoder.py

Yes they’re fairly simple, and not very pythonic, but the output is better than the shell scripts. Here is the same base64 sample above, the one with the question mark.

Note that it’s not a question mark, but the radiation symbol emoji.

Leave a Reply

Your email address will not be published. Required fields are marked *