> For the complete documentation index, see [llms.txt](https://arne-ctf.gitbook.io/ctf/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://arne-ctf.gitbook.io/ctf/2023/bucketctf/rev-schematic.md).

# Rev - Schematic

## Description

<div align="left"><figure><img src="/files/qphAaLgTUUmIQaqbhAXT" alt=""><figcaption></figcaption></figure></div>

## Downloads

{% file src="/files/lY8l10QtEJrPhdzzrEqo" %}

## Solution

A quick google search revealed that `.schematic` files are in the `NBT` file format.&#x20;

<figure><img src="/files/AayBIRtD0irCoW2bdhsa" alt=""><figcaption><p>From Minecraft Wiki</p></figcaption></figure>

Open the file using `NBTExplorer`.

<figure><img src="/files/lMgptfqYP8q2Whgs39YK" alt=""><figcaption><p><code>NBTExplorer</code> GUI</p></figcaption></figure>

At the start I thought the `dispenser` will be one of the `TileEntities` so I tried to find it using the following python code:

```python
from nbt import nbt

nbtfile = nbt.NBTFile("Ricardo3s_60AP_100C_200SB.schematic",'rb')

for tileentities in nbtfile['TileEntities']:
	try:
		for item in tileentities['Items']:
			print(item)
	except:
		print(tileentities)
```

As it turns out, `TileEntities` only contain either `minecraft:tnt` item or a Minecraft `Comparator`.

<figure><img src="/files/oRaACThvLb8QCbvUU2pd" alt=""><figcaption><p>Python output</p></figcaption></figure>

I then proceeded to search up on Minecraft dispenser to find out what exactly it is since it is not in `TileEntities`.

<figure><img src="/files/b3rLlovJtQn0VK31FjSz" alt=""><figcaption><p>From Minecraft Wiki once again</p></figcaption></figure>

It seems like a `Dispenser` is a **block**. I then edited the python script to print out all the blocks.

```python
from nbt import nbt
nbtfile = nbt.NBTFile("Ricardo3s_60AP_100C_200SB.schematic",'rb')
print(nbtfile['Blocks'])
```

&#x20;The output is as follows:

<figure><img src="/files/2K4wa4LrAgWP0cFw2wiJ" alt=""><figcaption><p>Python output</p></figcaption></figure>

The output is an array of numbers which suggests that every block is stored as a unique number that determines which block type it is. Previously from the Minecraft wiki page, we can also see the number 23 under the dispenser's **Numeric ID**. Now we just need to count the number of dispensers with the following code:

```python
from nbt import nbt
nbtfile = nbt.NBTFile("Ricardo3s_60AP_100C_200SB.schematic",'rb')

# Count number of blocks with 23 as Numeric ID
print(len([i for i in nbtfile['Blocks'] if i == 23]))
```

Flag: `bucket{2238}`
