-
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge50.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.owasp.wrongsecrets.challenges.docker; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.owasp.wrongsecrets.challenges.Challenge; | ||
import org.owasp.wrongsecrets.challenges.Spoiler; | ||
import org.owasp.wrongsecrets.challenges.docker.binaryexecution.BinaryExecutionHelper; | ||
import org.owasp.wrongsecrets.challenges.docker.binaryexecution.MuslDetectorImpl; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** This challenge is about finding a secret hardcoded in a dotnet binary. */ | ||
@Slf4j | ||
@Component | ||
public class Challenge50 implements Challenge { | ||
|
||
private final BinaryExecutionHelper binaryExecutionHelper; | ||
|
||
public Challenge50() { | ||
this.binaryExecutionHelper = new BinaryExecutionHelper(50, new MuslDetectorImpl()); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public Spoiler spoiler() { | ||
return new Spoiler(binaryExecutionHelper.executeCommand("", "wrongsecrets-dotnet")); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public boolean answerCorrect(String answer) { | ||
return binaryExecutionHelper | ||
.executeCommand(answer, "wrongsecrets-dotnet") | ||
.equals("This is correct! Congrats!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
=== Hiding in binaries revisited: .NET self contained runtime | ||
|
||
It is super easy to find a secret in a DLL, but when you are on MacOS or Linux it is much harder. So I am sure we can keep one there right? | ||
|
||
Show us that we should not do that! Can you find the secret in https://github.com/OWASP/wrongsecrets/tree/master/src/main/resources/executables/wrongsecrets-dotnet[wrongsecrets-dotnet] (or https://github.com/OWASP/wrongsecrets/tree/master/src/main/resources/executables/wrongsecrets-dotnet-arm[wrongsecrets-dotnet-arm], https://github.com/OWASP/wrongsecrets/tree/master/src/main/resources/executables/wrongsecrets-dotnet-linux[wrongsecrets-dotnet-linux])? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
This challenge is specifically looking at a secret in a .NET8 binary | ||
|
||
You can solve this challenge using the following alternative solutions: | ||
|
||
1. Find the secrets with Ilsply. | ||
- Install .NET8 and .NET8 SDK | ||
- Install https://github.com/icsharpcode/ILSpy/tree/master/ICSharpCode.ILSpyCmd[ilspycmd] | ||
- Install `sfextract`: `dotnet tool install -g sfextract` | ||
- Unpack the self-contained binary: `sfextract wrongsecrets-dotnet -o \./tmp`. | ||
- Go to the tmp folder and do `ilspycmd dotnetproject.dll` to decompile the dll and find the secret. | ||
Don't want to install the tools? check the https://github.com/OWASP/wrongsecrets/tree/master?tab=readme-ov-file#want-to-play-but-are-not-allowed-to-install-the-tools[WrongSecrets Desktop container]! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
*Why Using binaries to hide a secret will only delay an attacker.* | ||
|
||
With beautiful free Reverse engineering applications as ILSoy, not a lot of things remain safe. Anyone who can load the executable in ILspy or Ghidra 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/test/java/org/owasp/wrongsecrets/challenges/docker/Challenge50Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.owasp.wrongsecrets.challenges.docker; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.owasp.wrongsecrets.challenges.docker.binaryexecution.BinaryExecutionHelper.ERROR_EXECUTION; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.owasp.wrongsecrets.challenges.Spoiler; | ||
|
||
class Challenge50Test { | ||
|
||
@Test | ||
void spoilerShouldNotCrash() { | ||
var challenge = new Challenge50(); | ||
|
||
assertThat(challenge.spoiler()).isNotEqualTo(new Spoiler(ERROR_EXECUTION)); | ||
assertThat(challenge.answerCorrect(challenge.spoiler().solution())).isTrue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters