Flowers

Category

Anly

Description

Another Valentine classic… flowers! Flowers can be expensive, so I bought a bunch of them cheap online. Turns out they’re infested with some kind of bug and I need to buy a specialized pesticide to take care of them. The pesticide is really expensive, but the online seller is willing to give me a discount code if I can analyze a program he gives me. As I said, I’m nine years old sooooooooooo… do it for me? Enter your answers at the given link.

Solution

Attached is a file called flowers.fish.txt and a link to a web page where we can submit some values.

Submission web page

Taking a look at the file we get some gibberish.

9718236450  \
 n;n        x       2        <
   l
   ^         6           /   x
   >    n   \     4      x   <

                             n
>  5        r     5          ^

 $
            >         n      ^


^^     r  7783           x

 >    $     r     l      9   /


                         _

But the fish part of the name suggest that it might be some fish esolang code.

Using a fish interpreter written in python, we can execute the code.

python3 fish.py flowers.fish.txt
894

But we need to run the program 1000 times and count the individual numbers to get the values for the web page.

The following bash script will run the program 1000 times and count the numbers.

#!/bin/bash

instances () {
    echo "$1:"
    cat out.txt | tr -cd "$1" | wc -c
}

echo "Running script 1000 times"
for i in `seq 1 1000`; do
    python3 fish.py flowers.fish.txt >> out.txt
done

echo "Instances of each number"
for i in `seq 0 9`; do
    instances $i
done

And after running this we get some output like the following.

Instances of each number
0:
305
1:
233
2:
533
3:
141
4:
545
5:
1324
6:
51
7:
720
8:
1261
9:
1633

Submitting the values on the web page gives us the flag.

valentine{fly1n9_purp13_p3t4l_e4ter5}

n00bz

Home of the n00bz CTF team.


By n00bz, 2023-02-15