> 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

Easy | 284 points

## Description

<div align="left"><figure><img src="https://4077916634-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9J6tnLQGbY0Or10P4xUT%2Fuploads%2Frl6feYiPzZTxzFP5hq9f%2Fimage.png?alt=media&amp;token=77581c21-b41a-447a-b7b1-ac2d5914e8c4" 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="https://4077916634-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9J6tnLQGbY0Or10P4xUT%2Fuploads%2FRrhgKclkvxqLVx8bdUpZ%2Fimage.png?alt=media&amp;token=c4dbc664-83fe-49b9-8b11-404fa94c5a68" alt=""><figcaption><p>From Minecraft Wiki</p></figcaption></figure>

Open the file using `NBTExplorer`.

<figure><img src="https://4077916634-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9J6tnLQGbY0Or10P4xUT%2Fuploads%2FoUySee32j3QmDl25Ftrh%2Fimage.png?alt=media&amp;token=0774597a-5c46-46a6-be00-8684019bc7b1" 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="https://4077916634-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9J6tnLQGbY0Or10P4xUT%2Fuploads%2Fjhg5zw0gN0Nl4UMV9fWm%2Fimage.png?alt=media&amp;token=99064978-a148-4012-82bf-fa8c00bb30f3" 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="https://4077916634-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9J6tnLQGbY0Or10P4xUT%2Fuploads%2F7fA26aFON6Fq5VtljLRZ%2Fimage.png?alt=media&amp;token=4c405237-cc01-4558-b9e1-836317b5d0ce" 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="https://4077916634-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9J6tnLQGbY0Or10P4xUT%2Fuploads%2F8445YjcNLHUfKN66eMaZ%2Fimage.png?alt=media&amp;token=0546f029-9e69-42d9-9c01-47c36b1da56d" 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}`
