How to encode shell commands into base64 (that they auto decode when excuted.)

Encoding a shell command might seem hard at first, but as you’ll find out, it actually isn’t.

The idea began when I was trying to run some evil commands on my terminal, and an idea came to mind, what if these commands were unreadable, that when someone sees any of them, he/she has to decode it first to be able to read it.

And what’s the first thing that goes to mind when talking about encoding? BASE64

Table of contents:

– Encoding the “ls” command.
– Putting the command together.
– Automating this process.
– And take a quote.

Encoding the “ls” command.

Let’s assume that we want to run the ls command… that it’s encoded and auto decodes when run, how can this goal be reached?!

We’ll take it in a step by step process, at first we encode the command with:

echo "ls" | base64

we’ve got bHMK.

Putting the command together.

Now, let’s put the command together.

We want to decode it, then execute it, all in the one command. the command would be:

echo 'bHMK' | base64 -d | bash

When you run this, it gives the same output as running ls.

Automating this process.

I’d created a python script in order to automate this process, which you can find here in my Github repo.

And take a quote:


-I said it, as always



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s