|
1 | 1 | package org.owasp.wrongsecrets.challenges.docker; |
2 | 2 |
|
| 3 | +import java.nio.charset.StandardCharsets; |
| 4 | +import java.security.InvalidAlgorithmParameterException; |
| 5 | +import java.security.InvalidKeyException; |
| 6 | +import java.security.NoSuchAlgorithmException; |
3 | 7 | import java.util.List; |
| 8 | +import javax.crypto.BadPaddingException; |
| 9 | +import javax.crypto.Cipher; |
| 10 | +import javax.crypto.IllegalBlockSizeException; |
| 11 | +import javax.crypto.NoSuchPaddingException; |
| 12 | +import javax.crypto.spec.IvParameterSpec; |
| 13 | +import javax.crypto.spec.SecretKeySpec; |
4 | 14 | import lombok.extern.slf4j.Slf4j; |
| 15 | +import org.apache.commons.codec.binary.Base64; |
5 | 16 | import org.owasp.wrongsecrets.RuntimeEnvironment; |
6 | 17 | import org.owasp.wrongsecrets.ScoreCard; |
7 | 18 | import org.owasp.wrongsecrets.challenges.Challenge; |
@@ -59,7 +70,29 @@ public List<RuntimeEnvironment.Environment> supportedRuntimeEnvironments() { |
59 | 70 | } |
60 | 71 |
|
61 | 72 | private String getKey() { |
62 | | - // google api key |
63 | | - return "AIzaSyBSpHvt8l1f9qlppJqQW280vGacXgwNnrk"; |
| 73 | + String ciphertext = "zRR77ETjg5GsXv3az1TZU73xiFWYHbVceJBvBbjChxLyMjHkF6kFdwIXIduVBHAT"; |
| 74 | + try { |
| 75 | + return decrypt(ciphertext); |
| 76 | + } catch (Exception e) { |
| 77 | + log.warn("there was an exception with decrypting content in challenge35", e); |
| 78 | + return "error_decryption"; |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + private String decrypt(String ciphertext) |
| 83 | + throws InvalidAlgorithmParameterException, |
| 84 | + InvalidKeyException, |
| 85 | + NoSuchPaddingException, |
| 86 | + NoSuchAlgorithmException, |
| 87 | + IllegalBlockSizeException, |
| 88 | + BadPaddingException { |
| 89 | + IvParameterSpec iv = new IvParameterSpec("1234567890123456".getBytes(StandardCharsets.UTF_8)); |
| 90 | + SecretKeySpec skeySpec = |
| 91 | + new SecretKeySpec( |
| 92 | + "12345678901234561234567890123456".getBytes(StandardCharsets.UTF_8), "AES"); |
| 93 | + |
| 94 | + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); |
| 95 | + cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv); |
| 96 | + return new String(cipher.doFinal(Base64.decodeBase64(ciphertext))); |
64 | 97 | } |
65 | 98 | } |
0 commit comments