FooBar CTF 2023

https://foobar.nitdgplug.org/challenges


image


Crypto:

Pixelite :

we are given with two files: chall.py and pixelite.png

and we are also given this number: 1678519928.9423187

looking at code we know that this code is doing xor of every pixel of flag.png with random int between 0 to 255

flag_matrix[i, j] = tuple(
    map(
        lambda x: x ^ random.randint(0, 255),
        flag_matrix[i, j]
    )
)          

Here the random module of python can be predicted. If we know the seed value than all the next random int are same every time.

random.seed(time.time())

The seed is set to time.time() and we are given this value in challenge: 1678519928.9423187

know we can easily reverse this xor operation to get original image.

Click to see code :diamond_shape_with_a_dot_inside:

flag.png:

image

GLUG{Y0u_4Re_noT_5o_w34k}

funwithrandom-1:

description: randcrack is fun or is it . let's see if you can create your own

nc chall.foobar.nitdgplug.org 30001

file: chall.py

In this code we have rand_gen() function. if mt_index > 624 than it go inside if statement. else it will do the following operations:

getstate() Return an object capturing the current internal state of the generator. and the seed is set through os.urandom(8) which is not predictable.

here output is filled 624 times with rand_gen() function.

again looking at this code we know that it will do this operations on mt aaray from 0 to 624 index.

and we are given with the output's value so by reversing this operations we can get the value of mt.

with this small trial and error experiment:

now we know that only y ^= (y << 12) & TemperingMaskB this operation is effective rest are not making any changes.

so now we have to reverse this tempering here is python code for that:

now from output[] we can get mt[]. but the for loop was run 624 times so next time we call rand_gen() it will go inside if condition.

we will apply the same changes to our recovered mt[].

now we can get the next 5 int by applying this operations to first 5 elements of mt[].

now that we have the next 5 random element we can get the flag.

final python script:

Click to see code :diamond_shape_with_a_dot_inside:

flag: GLUG{R4nd0m_Numb3r_G3n3r470r_15_tru3ly_r4nd0m_0r_15_17}

Web:

inspect:

Description: Don't think too much. Just push to production http://chall.foobar.nitdgplug.org:30045/

Rest API was boring so I used modern technology.

Let's open this website

image

Hmn Cannot GET /

I tried robots.txt and checked http response headers but nothing, so I did directory bruteforce and got this endpoint: /graphql GraphQL is a query language developed by Facebook

http://chall.foobar.nitdgplug.org:30045/graphql

image

Reference : https://blog.yeswehack.com/yeswerhackers/how-exploit-graphql-endpoint-bug-bounty/

Introspection is the ability to query which resources are available in the current API schema. Given the API, via introspection, we can see the queries, types, fields, and directives it supports.

GraphQL introspection payload:

response:

image

This secret field looks interesting let's extract this.

payload:

response:

image

when I saw the flag I immediately tried to submit it, but it was wrong then I realised that there are multiple flags.

75 in total.

first I thought it is rabbit hole, but I went through every flag and found this:

image

this makes sense inspect is challenge name and graphql is endpoint.

flag: GLUG{1nsp3c7_1n_gr4phq6}

This is correct one.

:octocat: Happy Hacking :octocat:

Last updated

Was this helpful?