Challenge 21 ☆☆☆☆☆

Welcome to challenge Challenge 21. You need to guess the secret that is hidden in Java, Docker, Kubernetes, Vault, AWS or GCP.

Hiding in binaries part 3: the Go binary

Our third language of choice for a compiled application is Go. With the rise of its popularity, we see an increase of secrets hidden inside the binaries. Can you find the secret in our binary?

Let’s debunk the "secrets are hard to find in native compiled applications" myth for Go: can you find the secret in wrongsecrets-golang (or wrongsecrets-golang-arm, wrongsecrets-golang-linux)?

Answer to solution :

This challenge is specifically looking at a secret in a Go binary

This one is a little harder, as we used Cobra to create the CLI, introducing some more overhead. You can solve this challenge using the following steps:

  1. Find the secrets with Ghidra.

    • Install Ghidra.

    • Start it with ghidraRun.

    • Load the application wrongsecrets-golang into ghidra by choosing a new project, then import the file and then doubleclick on it.

    • Allow the Ghidra to analyze the application. Note that this takes much longer as our binary is a lot larger.

    • Go to the data type manager in the bottom left, now filter for string, now right-click at string as a member of wrongsecrets-golang and select find uses of.

    • Now filter for known keywords: you should easily be able to find the secret now!

  2. Find the secrets with radare2.

    • Install radare2 with either brew install radare2 on Mac or follow these steps: git clone https://github.com/radareorg/radare2; cd radare2 ; sys/install.sh

    • Launch r2 analysis with $ r2 -A wrongsecrets-golang

    • Start a search for the string with /w secret

    • Now take the results and look for possible answers, how about /w his is the secret in Golang ? You should be able to find the secret now.

Why Using binaries to hide a secret will only delay an attacker.

With beautiful free Reverse engineering applications as Ghidra, not a lot of things remain safe. Anyone who can load the executable in Ghidra or Radare2 can easily start doing a reconnaissance and find secrets within your binary.

Encrypting the secret with a key embedded in the binary, and other funny puzzles do delay an attacker and just make it fun finding the secret. Be aware that, if the secret needs to be used by the executable, it eventually needs to be in memory ready to be executed.

Still need to have a secret in the binary? Make sure it can only be retrieved remotely after authenticating against a server.