> For the complete documentation index, see [llms.txt](https://sayonara.gitbook.io/writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sayonara.gitbook.io/writeups/ctf/downunderctf-2023/web/grades_grades_grades.md).

# &#x20;grades\_grades\_grades

### <mark style="color:blue;">Challenge Description</mark>

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FfOb2qcFFCxJduELWtKb6%2Fimage.png?alt=media&amp;token=76930a31-d3e7-4841-85da-31bf0fd4a358" alt=""><figcaption></figcaption></figure></div>

### <mark style="color:blue;">Challenge Attachment</mark>

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

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FnWdHFDF0yXefSnrVQIwT%2Fimage.png?alt=media&amp;token=fd6a92f1-a9d0-4c91-9d2d-77dfed9dc185" alt=""><figcaption></figcaption></figure></div>

click on sign up to register a new user&#x20;

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2Faop51j0Cj1lJTCIEaOXv%2Fimage.png?alt=media&amp;token=128b6d7e-b8dc-4364-a1e3-24eb25aa55be" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FDAk2CKfoshySeUlIdKFA%2Fimage.png?alt=media&amp;token=73ecf1ba-4669-4b72-81e8-5ba54a1f9c91" alt=""><figcaption></figcaption></figure></div>

taking a look at the source we find in the routes the flag route which is located at `/grades_flag`

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2Fe1kaz7h3VZhjvhrR5Wn4%2Fimage.png?alt=media&amp;token=947517d2-9065-4368-8c21-88004e29c3af" alt=""><figcaption></figcaption></figure></div>

but for some reason it says invalid token

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FYValDQPCUb68IJAEeert%2Fimage.png?alt=media&amp;token=f2e21a45-297a-48f3-9aa0-c35ce59ba3a8" alt=""><figcaption></figcaption></figure></div>

let's decode the token and view the source code to find what is the token allowed to view the flag

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FghKOcJ76AJ221dRKfcXY%2Fimage.png?alt=media&amp;token=44e08242-552f-41f6-8cd8-4a11f522ff15" alt=""><figcaption></figcaption></figure></div>

let's decode it

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FMmeeZEjtuQoW2puR2bPZ%2Fimage.png?alt=media&amp;token=47b727aa-8f21-41c6-a109-6085f8be7a38" alt=""><figcaption></figcaption></figure></div>

if we take a look at the /grades\_flag route we can see that it checks if the teacher role is true&#x20;

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FPAi6PMcTANv835Dy5ZGX%2Fimage.png?alt=media&amp;token=9589cbf7-2bf9-4d61-917f-e97e69f8d86d" alt=""><figcaption></figcaption></figure></div>

and if we see how the token is generated after signing up we will see that a property called is\_teacher is set to false by default if no value is given which makes the is\_teacher\_role() function returns false which makes the route /grades\_flag didn't show because it requires that the user is a teacher not student

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FgVxrzd25POhFzzgFTqo9%2Fimage.png?alt=media&amp;token=c02c785f-fb86-44a1-949c-05a8d386f4cf" alt=""><figcaption></figcaption></figure></div>

so what we have to do is add the propertie is\_teacher ourselves when signing up and make it true so it's added to the token, first let's intercept the sign up request

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FgM5lFTedc3IgxQNenizM%2Fimage.png?alt=media&amp;token=70a608b7-3a11-4408-8f42-c39fe9fac968" alt=""><figcaption></figcaption></figure></div>

now let's add the is\_teacher=true

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FtqTQbKfM3APpiePWHJOS%2Fimage.png?alt=media&amp;token=f3b32626-7ad9-4640-8262-82a46ae8cd36" alt=""><figcaption></figcaption></figure></div>

copy the token returned in the response, let's decode it to check if the property is added successfully

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FbemwAzr8ACT0pvpMurNE%2Fimage.png?alt=media&amp;token=c9744960-51f0-4090-803a-3a4323a03518" alt=""><figcaption></figcaption></figure></div>

so let's use this token

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2Fo6WSJfnpQCPWIISjWw5w%2Fimage.png?alt=media&amp;token=d14c623d-c049-43ff-b552-89dce5260371" alt=""><figcaption></figcaption></figure></div>

refresh the page and boom we have got the flag

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2F1cvZ854AdVftv5Gln9wu%2Fimage.png?alt=media&amp;token=b1656a98-27dc-4312-b8f8-448ad3a5d616" alt=""><figcaption></figcaption></figure></div>

### <mark style="color:blue;">Flag</mark>

```
DUCTF{Y0u_Kn0W_M4Ss_A5s1GnM3Nt_c890ne89c3}
```
