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

# crackme1

Déjà vu, I've just been in this place before. Higher on the street and I know it's my time to go!  Files available here  Author: @scuffed

Firstly, I decided to decompile the given binary and saw 2 main things of interest.

```c
void *_dso_handle = &_dso_handle; // idb
char dejavu[52] = "This challenge feels pretty familiar... doesn't it?"; // idb
int spinit[13] = { 5, 41, 21, 26, 41, 15, 24, 1, 10, 21, 7, 3, 24 }; // idb
char _bss_start; // weak
_UNKNOWN end; // weak
```

and

```c
v6 = __readfsqword(0x28u);
  printf("%s\n\nGive me your input: ", dejavu);
  __isoc99_scanf("%s", input);
  for ( i = 0; i <= 12; ++i )
  {
    if ( input[i] != dejavu[spinit[i]] )
    {
      puts("Nice try!!");
      return -1;
    }
  }
  printf("\nYou got it! Your flag is blahaj{%s}\n", input);
  return 0;
}
```

Thus, I created a python script to reverse the given function and obtain the flag

```python
dejavu = "This challenge feels pretty familiar... doesn't it?"
spinit = [5, 41, 21, 26, 41, 15, 24, 1, 10, 21, 7, 3, 24]

# Use spinit to pick characters from dejavu
flag = ''.join(dejavu[i] for i in spinit)

print(f"The flag is: {flag}")
```

We obtain `The flag is: copyofthepast`

Thus, by running the binary and putting in the text we obtained, "`copyofthepast"`

<figure><img src="https://175444261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyxEI13wXOyST4LLTOUiS%2Fuploads%2FDwle6YNxecYzoQlbBPju%2Fimage.png?alt=media&amp;token=3ff55d45-d465-442b-9fcf-e6b4b290c6bc" alt=""><figcaption></figcaption></figure>

Thus the flag is `blahaj{copyofthepast}`
