1

I was solving a problem on a popular hacking for fun website, when I got following idea:

Is it possible to represent - for example a '/' (just the slash) in the terminal (linux) in another way - for example hexadecimal:

example:

cd /etc/

as

cd %2F etc %2F

is this somehow possible? Even though in this example I am using a special character (%) again.

OcK
  • 13
  • 3

1 Answers1

2

Yes, this is possible. In most shells, there are plenty of ways to do this. Any way you can encode and decode something in a subshell into ASCII will work. A few examples for bash:

cd $(printf '\x2fetc')
cd $(base64 -d <<< 'L2V0Ywo=')
cd $(awk 'BEGIN{printf("%cetc",47);}')
cd $(cut -b1 <<< $HOME)etc
eval $(base64 -d <<< 'Y2QgL2V0Ywo=')

Everything in the subshell is evaluated first, so these all become:

cd /etc

There are countless other ways to do this, many far more obfuscated than anything I've put here. But if all you want to do is change directories without using a /, any of these should suffice perfectly. Note that some of these use bash-isms and are not perfectly POSIX-compliant.

forest
  • 64,616
  • 20
  • 206
  • 257