# PW Crack 1

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FhVRySL2XL8qdMANleLbN%2Fimage.png?alt=media&#x26;token=30666840-4d15-4691-91eb-d2d0a3804c95" alt=""><figcaption></figcaption></figure>

Download the challenge files in the same directory:

```bash
curl https://artifacts.picoctf.net/c/10/level1.py -o level1.py
```

{% code overflow="wrap" %}
```bash
curl https://artifacts.picoctf.net/c/10/level1.flag.txt.enc -o level1.flag.txt.enc
```
{% endcode %}

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FZ8S6Ja79SryeL3livaA0%2Fimage.png?alt=media&#x26;token=bf25af1b-a5a9-4b2a-b748-7e297ae77382" alt=""><figcaption></figcaption></figure>

Read the encrypted flag:

```bash
cat level1.flag.txt.enc
```

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FbAt1gGvqmEg7gCQBbPfR%2Fimage.png?alt=media&#x26;token=ab24803e-1ac5-4880-aa04-ceab01e91689" alt=""><figcaption></figcaption></figure>

And read the script:

```bash
cat level1.py
```

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FSX688FIU6yX1xbiNAqW9%2Fimage.png?alt=media&#x26;token=50eb5699-5019-4e82-abb1-b3df34613558" alt=""><figcaption></figcaption></figure>

The first function str\_xor as stated will not help us, so we will not focus on it.

flag\_enc will open the encrypted flag file, and read it and saves it in it.

Then the level\_1\_pw\_check called, and asks for input, and then compare that input to "691d", if True, it will continue the process and decrypt the flag, and print it, else it will print That password is incorrect and exit.

So all we have to do, is to run that script, and pass this password to it to decrypt the flag:

```bash
python3 level1.py
	691d
```

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FegvhbXjyWONDT0sfhGf1%2Fimage.png?alt=media&#x26;token=ff976ff3-747f-41d8-83e9-4fcd1237e387" alt=""><figcaption></figcaption></figure>

Here is the flag.

Since the process is just xoring, we can recover the flag with cyberchef:

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FLAYbXrCdNIV37pGNjwXM%2Fimage.png?alt=media&#x26;token=19cce68a-cf1d-4a06-866e-b69ab2ab800e" alt=""><figcaption></figcaption></figure>

I uploaded the encrypted flag, and used xor operation, and set the type of the key to UTF8, and the key is picoCTF{, as shown in the output 691d is repeated twice, so maybe if we take it and place in the key place:

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FbIgpYQ5h57ZBx8BHgWrK%2Fimage.png?alt=media&#x26;token=1306b1ed-ea8b-44ee-ad78-e8d6e3673e96" alt=""><figcaption></figcaption></figure>
