-
Notifications
You must be signed in to change notification settings - Fork 141
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
14 changed files
with
199 additions
and
28 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
118 changes: 118 additions & 0 deletions
118
trainingportal/static/lessons/cryptoBreaker/crypto_analysis.sol.md
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,118 @@ | ||
### Solution for "Cryptanalysis" challenge | ||
|
||
This challenge puts together all types of text transformation techniques encountered so far. | ||
|
||
You will leverage the fact that you are able to guess the starting line in the message. | ||
|
||
The HTTP protocol defines messages that follow the format below: | ||
|
||
{HTTP METHOD} {PATH} {PROTOCOL}\r\n | ||
{HEADER 1}:{VALUE 1}\r\n | ||
... | ||
{HEADER N}:{VALUE N}\r\n | ||
\r\n | ||
{OPTIONAL BODY} | ||
\r\n | ||
|
||
|
||
{HTTP METHOD} can be any of the following: GET, POST, HEAD, OPTIONS, PUT, DELETE, but most commonly GET and POST are used. | ||
|
||
POST in particular is used to transmit data in the request body. | ||
|
||
A typical request will look like this: | ||
|
||
POST /{path} HTTP/{version} | ||
|
||
|
||
Path can be anything | ||
Version can be 1.0, 1.1, 2 or more. However versions 2 and above are binary protocols so they are a bit more complicated for cryptanalysis. | ||
|
||
HTTP/1.1 was the protocol of choice for a very long time so it's a good guess. | ||
|
||
You could start with POST / and build up from it, but for the purpose of this challenge let's assume we can guess the entire request line from the start: | ||
|
||
POST / HTTP/1.1 | ||
|
||
Now you can remember the XOR challenge and the property of XOR below: | ||
|
||
A ^ B = C | ||
B ^ C = A | ||
A ^ C = B | ||
|
||
|
||
##### Step 1 - Recover the key | ||
|
||
Use a online tool to get the ASCII code for `POST / HTTP/1.1` **in hexadecimal**. | ||
|
||
|
||
You will get something like this: | ||
|
||
50 4F 53 54 20 2F 20 48 54 54 50 2F 31 2E 31 | ||
|
||
This is only 15 bytes. Add `0D` (CR) to make it 16 bytes, which is a multiple of 2 and likely the length of the key. | ||
|
||
50 4F 53 54 20 2F 20 48 54 54 50 2F 31 2E 31 0D | ||
|
||
Now **XOR** the assumed plain text with the cipher **as a hexadecimal key** and copy down the resulting first 16 bytes. | ||
|
||
41 35 BA 75 45 C3 A0 80 53 0E 5F 54 0A 05 13 CD | ||
|
||
|
||
##### Step 2 - Recover the HTTP message | ||
|
||
|
||
Now **XOR** the recovered key bytes with the cipher. Display the result as printable characters: | ||
|
||
You will get something like the below. | ||
|
||
POST / HTTP/1.1 | ||
Host: finance.biznis | ||
Content-length: 326 | ||
kmb64=eyJrZXlNYXRlcmlhbFNoaWZ0ZWQiOiJHV01FWUZHIENTRFBBIFVNT0VJRCBFR1JJViBHR0NHTFcgUUNDSiBRQUNQWiBYQUNIRlYgWFRQVlZBIFdXU0lEWiIsImdvbGRlbktleVNoaWZ0SGFzaCI6ImE1MTZmZjc0ZTIyMmMzYmJkM2FiOTI0ZTk2ZmVmZTBjIiwiZ29sZGVuS2V5U2FsdEhhc2giOiJhOGQzMTM5ZTAwNzUyZjg4NzZlNDdiMmZiZGNlMDc0ZCIsImhhc2hpbmdGdW5jdGlvbiI6IlNIQTI1NiIsIml0ZXIiOjEwMDB9 | ||
|
||
|
||
##### Step 3 - Decode the kmb64 parameter | ||
|
||
Decode the kmb64 parameter using an online base64 decoder. | ||
|
||
Now we can see a JSON message similar to the example below: | ||
|
||
{ | ||
"keyMaterialShifted":"GWMEYFG CSDPA UMOEID EGRIV GGCGLW QCCJ QACPZ XACHFV XTPVVA WWSIDZ", | ||
"goldenKeyShiftHash":"a516ff74e222c3bbd3ab924e96fefe0c", | ||
"goldenKeySaltHash":"a8d3139e00752f8876e47b2fbdce074d", | ||
"hashingFunction":"SHA256", | ||
"iter":1000 | ||
} | ||
|
||
##### Step 4 - Look-up the hashes | ||
|
||
Using your online rainbow table of choice identify the Shift and the Salt hashes. | ||
|
||
For the given example: | ||
|
||
a516ff74e222c3bbd3ab924e96fefe0c - LOREM | ||
a8d3139e00752f8876e47b2fbdce074d - VIVAMUS | ||
|
||
##### Step 5 - Unscramble the key material using Vigenère | ||
|
||
Using an online tool unscramble the text using the value associated with `goldenKeyShiftHash` as a key: | ||
|
||
GWMEYFG CSDPA UMOEID EGRIV GGCGLW QCCJ QACPZ XACHFV XTPVVA WWSIDZ | ||
VIVAMUS LOREM DICTUM AUGUE CURSUS EROS MORBI TORTOR LIBERO LIBERO | ||
|
||
|
||
##### Step 6 - Generate the PBKDF2 | ||
|
||
Using an online tool generate a PBKDF2 key using the parameters associated with the JSON. | ||
|
||
For our example: | ||
|
||
Password: VIVAMUS LOREM DICTUM AUGUE CURSUS EROS MORBI TORTOR LIBERO LIBERO | ||
Algortithm: SHA256 | ||
Salt: VIVAMUS | ||
Iterations: 1000 | ||
|
||
The solution is the resulting hex value. | ||
|
3 changes: 3 additions & 0 deletions
3
trainingportal/static/lessons/cryptoBreaker/crypto_ascii.sol.md
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,3 @@ | ||
### Solution for "ASCII" challenge | ||
|
||
Use an online ASCII decoder tool to convert the ASCII codes into characters. |
3 changes: 3 additions & 0 deletions
3
trainingportal/static/lessons/cryptoBreaker/crypto_base64.sol.md
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,3 @@ | ||
### Solution for "Base64" challenge | ||
|
||
Use an online Base64 decoder tool to convert the base64 encoding into 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
9 changes: 9 additions & 0 deletions
9
trainingportal/static/lessons/cryptoBreaker/crypto_caesar.sol.md
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,9 @@ | ||
### Solution for "Caesar" challenge | ||
|
||
Use an online tool to unscramble the text. | ||
|
||
If you need a challenge you could also try shifting the letters like in the example below, until they make sense. The words are from the well known Lorem Ipsum text used in printing and typsetting. | ||
|
||
NQTGO | ||
<- MPSFN | ||
<- LOREM |
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
8 changes: 8 additions & 0 deletions
8
trainingportal/static/lessons/cryptoBreaker/crypto_hash.sol.md
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,8 @@ | ||
### Solution for "One Way Hash" challenge | ||
|
||
Use an online rainbow table tool to identify the words corresponding to each hash. | ||
|
||
It's a good idea to write down the hashes and then reconstruct the text in order as some of the tools remove hashes or change the order when using bulk look-ups. | ||
|
||
a516ff74e222c3bbd3ab924e96fefe0c -> LOREM | ||
e17acb30902a2d91764780ec14400766 -> IPSUM |
5 changes: 5 additions & 0 deletions
5
trainingportal/static/lessons/cryptoBreaker/crypto_pbk.sol.md
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 @@ | ||
### Solution for "Password Based Key" challenge | ||
|
||
Use an online tool to generate a PBKDF key with the provided parameters. | ||
|
||
Once you have the key, copy the hexadecimal value and use an online tool to decrypt the XOR cipher. |
File renamed without changes.
24 changes: 24 additions & 0 deletions
24
trainingportal/static/lessons/cryptoBreaker/crypto_vigenere.sol.md
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,24 @@ | ||
### Solution for "Vigenère" challenge | ||
|
||
Use an online tool to unscramble the text. | ||
|
||
Some online tools perform frequency analysis on the cipher. Given the correct language they will find the key automatically. | ||
|
||
However to assist with this challenge, the given plain text always begins with `LOREM`. | ||
|
||
This should help you figure out the key pretty easily even without using an online tool and also recognize the correct solution if given several options. | ||
|
||
For example, in the previous challenge we arrived at LOREM with two shifts to the left in the Latin alphabet: | ||
|
||
NQTGO | ||
<- MPSFN | ||
<- LOREM | ||
|
||
Given a Vigenère cipher that begins with **LPTEN**, we can infer the key is `ABC`. | ||
|
||
`Cipher`: L P T E N | ||
`A`: >L< O R >E< M | ||
`B`: M >P< F S >N< | ||
`C`: N Q >T< G O | ||
|
||
9 changes: 9 additions & 0 deletions
9
trainingportal/static/lessons/cryptoBreaker/crypto_xor.sol.md
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,9 @@ | ||
### Solution for "XOR" challenge | ||
|
||
Remember that in XOR the key, plain text and the cipher are interchangeable (if they have the same length). | ||
|
||
To obtain the characters of the key, all you have to do is to XOR the given hex values of the cipher with the known plain text: `LOREM IPSUM DOLOR SIT AMET` | ||
|
||
- Go to your online XOR decoder of choice | ||
- Provide the hex values of the cipher | ||
- Provide `LOREM IPSUM DOLOR SIT AMET` **as an ASCII KEY** |
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