# Code Pyn

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

{% file src="/files/2wMaeDpDtKA3HwNc9Y7c" %}

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

**Category:** Reverse - **Points:** 34 - **Solves:** 20\
**Description:** I lost my pin code. Can you help me find it?

**Infos:**

> A .pyc file is provided (pyn.pyc)

**Solution:**\
To solve this challenge you need to find a solution to decrypt the .pyc file or to recover the program code.\
To do this I chose to develop a little python script (*bruteforcePYC.py*).\
The script recove the program structure and we can see what he is doing.\
For example the python script return this :

```
  8          24 LOAD_NAME                4 (len)
             26 LOAD_NAME                3 (pin)
             28 CALL_FUNCTION            1
             30 LOAD_CONST               5 (4)
```

This block indicate that the PIN is composed by 4 digits (*LOAD\_CONST (4)*)\
After theses lines indicate that we need to do a [XOR](https://xor.pw/#) between 5 and 3 :

```
60 LOAD_CONST               6 (5)
62 BINARY_XOR
64 LOAD_CONST               7 (3)
```

And it's the same for the 2 following PIN

```
86 LOAD_CONST               7 (3)
88 BINARY_XOR
90 LOAD_CONST               6 (5)
```

```
112 LOAD_CONST              10 (8)
114 BINARY_XOR
116 LOAD_CONST               8 (1)
```

So we have the 3 first digits (669) and the fourth need to be find manually.\
When we test the last digit, we found speedly that is 1.\
So we know the PIN code : 6691 and the FLAG is the PIN so...

<details>

<summary>🚩 FLAG</summary>

```
DVC{6691}
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://writeups.ayweth20.com/2021/dvctf-to-join-davincicode/reverse/code-pyn.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
