ApoorvCTF 2025 – [AI] Pokédex Neural Network Write Up

20250304 1638 32

20250304 1735 51

Professor Oak, the renowned Pokémon researcher, has developed an advanced Pokédex upgrade that utilizes neural networks to classify Pokémon types. However, a mishap caused by an overexcited Pikachu has disrupted crucial data files, leaving the system in chaos. Now, trainers must step up to the challenge—training a CNN model to restore order and complete the classifier, ensuring the Pokédex can once again identify Pokémon with precision.

For further details, access the PDF. Heads up!! It’s password protected. The password is the name of the pokemon Ash first captured. Good Luck Trainer !!!

20250304 1736 18

Dataset.z01
19.53MB

Dataset.zip
3.82MB

HiTrainer_protected.pdf
0.13MB

core_dump.txt
0.00MB

Google Search

PDF password Check

20250304 1740 35

core_dump.txt 

base64 decoding

PokemonCNN
├── Initial Input: (256, 256, 4)

├── Feature Extraction Layers
│   ├── Conv2D (4->32)
│   ├── BatchNorm2D 
│   ├── ReLU Activation
│   ├── MaxPool2D(K Size = 3)
│   ├── Dropout (p=0.25)

├── Deeper Processing
│   ├── Conv2D(32->64)
│   ├── BatchNorm2D (64)
│   ├── ReLU Activation
│   ├── MaxPool2D(K Size = 3)
│   ├── Dropout (p=0.25)

├── More Feature Extraction
│   ├── Conv2D(64->128)
│   ├── BatchNorm2D
│   ├── ReLU Activation
│   ├── MaxPool2D(K Size = 3)
│   ├── Dropout (p=0.25)

├── Fully Connected Layers
│   ├── Flatten
│   ├── Linear (512 Neurons)
│   ├── BatchNorm1D
│   ├── Dropout (p=0.5)
│   ├── Linear
│   ├── Softmax Activation

└── Output: 18 classes

PDF Contents

Welcome, Pokémon Trainer!   Hello there! Welcome to the world of Pokémon! ⚡ I’m Professor Oak, the leading Pokémon researcher, and I’ve been working on an advanced Pokédex upgrade that can automatically classify Pokémon types using cutting-edge neural networks. This breakthrough could revolutionize how trainers understand their Pokémon! BUT… there’s been a slight hiccup in the lab.  My Pikachu got a little too excited and—well, let’s just say a few crucial data files were shocked into oblivion. ⚡? Now, the entire system is scrambled, and I need your help to restore order and complete the classifier! Your mission: Train a CNN model to classify Pokémon by type and help me get the Pokédex back on track. Are you up for the challenge, Trainer? Let’s GO!  ? Notebook link: https://www.kaggle.com/code/gl3mon/apoorvquestion Dataset link: https://www.kaggle.com/datasets/gl3mon/apoorvctf

kaggle sign up

Greetings, Trainer!

I am Professor Oak, and I’m working on an exciting new upgrade for the Pokédex!

For years, the Pokédex has relied on manual data entry and preprogrammed knowledge to classify Pokémon types. But I believe it’s time for an upgrade—a smarter, more advanced system that can instantly recognize a Pokémon’s type just by looking at it!

To make this happen, I’m developing a powerful new Pokédex feature using Convolutional Neural Networks (CNNs). With this, the Pokédex will be able to analyze Pokémon images and determine their type with incredible accuracy. But I need the help of skilled trainers like you to fine-tune this cutting-edge technology!

Your mission:

Make sure you have imported the dataset required for training the model.

Train and refine the CNN model for Pokémon type classification.

Make sure you use the GPU T4x2 Accelerator to train the model.

Optimize its performance to make the Pokédex faster and smarter.

Help revolutionize Pokémon research with this groundbreaking upgrade!

Are you ready to be part of Pokédex history? Let’s get started! ??

20250304 1638 32

Personal mobile phone verification 

20250304 1828 10

Next -> Gemma Download Use Agree

20250304 1747 11

Accelerator GPU T4 x2  Active

20250304 1829 30

Accelerator GPU T4 x2  Use Check

20250304 1748 44

seed hint

20250304 1750 11

20250304 1750 31

seed setting

20250304 1751 07

Question 1:  6

Next ->  Data Set

class CTFDataset(Dataset):
    def __init__(self, annotation_file, img_dir, transform = None, target_transform = None):
        self.img_labels = pd.read_csv(annotation_file, index_col=0)
        self.label_mapping = {
            'Bug': 0, 'Dark': 1, 'Dragon': 2, 'Electric': 3, 'Fairy': 4,
            'Fighting': 5, 'Fire': 6, 'Flying': 7, 'Ghost': 8, 'Grass': 9,
            'Ground': 10, 'Ice': 11, 'Normal': 12, 'Poison': 13, 'Psychic': 14,
            'Rock': 15, 'Steel': 16, 'Water': 17
        }
        self.img_labels['class'] = self.img_labels['type'].map(self.label_mapping)
        self.img_dir = img_dir
        self.transform = transform
        self.target_transform = target_transform

    def __len__(self):
        return len(self.img_labels)

    def __getitem__(self, idx):
        img_path = os.path.join(self.img_dir, self.img_labels.iloc[idx]['type'], f'{self.img_labels.iloc[idx]["pkn"]}'+'.png')
        image = None
        try:
            image = read_image(img_path).to(pt.float32)
        except:
            image = pt.zeros(4, 256, 256)
        label = self.img_labels.iloc[idx]['class']
        if self.transform:
            image = self.transform(image)
        if self.target_transform:
                label = self.target_transform(label)
        return image, label
ds = CTFDataset(
    annotation_file = '/kaggle/input/d/redchupa/apoorvctf/label.csv',
    img_dir = '/kaggle/input/d/redchupa/apoorvctf/images',
)

File Upload

20250304 1753 39

hint: kernel_size=2

img format 

20250304 1756 09

Initial Input: (256, 256, 4)

class PokemonCNN(nn.Module):
    def __init__(self):
        super().__init__()
        # 256 256 4
        self.conv1 = nn.Conv2d(4, 32, kernel_size=2) # 255 255 32
        self.bn1 = nn.BatchNorm2d(32)
        self.relu = nn.ReLU()
        self.pool = nn.MaxPool2d(kernel_size=3) # 85 85 32
        self.drop1 = nn.Dropout(0.25)

        self.conv2 = nn.Conv2d(32, 64, kernel_size=2) # 84 84 64
        self.bn2 = nn.BatchNorm2d(64)
        self.relu2 = nn.ReLU()
        self.pool2 = nn.MaxPool2d(kernel_size=3) # 28 28 64
        self.drop2 = nn.Dropout(0.25)

        self.conv3 = nn.Conv2d(64, 128, kernel_size=2) # 27 27 128
        self.bn3 = nn.BatchNorm2d(128)
        self.relu3 = nn.ReLU()
        self.pool3 = nn.MaxPool2d(kernel_size=3) # 9 9 128
        self.drop3 = nn.Dropout(0.25)

        self.flatten = nn.Flatten()
        self.fc1 = nn.Linear(10368, 512)
        self.bn4 = nn.BatchNorm1d(512)
        self.drop4 = nn.Dropout(0.5)
        self.fc2 = nn.Linear(512, 18)
        self.softmax = nn.Softmax()

    def forward(self, x):
        x = self.pool(F.relu(self.bn1(self.conv1(x))))
        x = self.drop1(x)

        x = self.pool(F.relu(self.bn2(self.conv2(x))))
        x = self.drop2(x)

        x = self.pool(F.relu(self.bn3(self.conv3(x))))
        x = self.drop3(x)

        x = self.flatten(x)
        x = self.fc1(x)
        x = self.bn4(x)
        x = self.drop4(x)
        x = self.fc2(x)
        x = self.softmax(x)
        return x

Conv2d Analyze

edited 20250304 1757 54

MaxPool2d Analyze

20250304 1758 14

Question 2:  9 * 9 * 128 = 10368

Training Start

20250305 1559 39

20250305 1559 11

Question 3,4

20250304 1800 22

netcat use

2

Reference

ApoorvCTF 2025

CSYClubIIITK/CTF-Writeups · GitHub

CTF-Writeups/ApoorvCTF-25-Writeups at main · CSYClubIIITK/CTF-Writeups

If there is a copyright issue with my writing, please request it in the comments and I will edit or delete it.

댓글 달기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

위로 스크롤