Challenge 1 - fiddler

Alright. So I have absolutely no idea what this is… Should be fun!

I downloaded the 7z archive and extracted it. Message.txt is the same as the banner on the website.

Reading through the python code, I can see that earning about 100 Billion coins will "win" the game and reward with the flag.

def game_screen():

    global current_coins, current_autoclickers, buying

    screen = pg.display.set_mode((640, 480))

    clock = pg.time.Clock()

    heading = Label(10, 10, 'Click on Kitty to send her out to catch mice to earn money',

                    color=pg.Color('green'),

                    font=pg.font.Font('fonts/arial.ttf', 20))

    heading2 = Label(10, 30, 'Earn about 100 Billion coins to win and reveal the flag.',

                    color=pg.Color('green'),

                    font=pg.font.Font('fonts/arial.ttf', 20))

Found the code for displaying the flag.

def victory_screen(token):

    screen = pg.display.set_mode((640, 160))

    clock = pg.time.Clock()

    heading = Label(20, 20, 'If the following key ends with @flare-on.com you probably won!',

                    color=pg.Color('gold'), font=pg.font.Font('fonts/arial.ttf', 22))

    flag_label = Label(20, 105, 'Flag:', color=pg.Color('gold'), font=pg.font.Font('fonts/arial.ttf', 22))

    flag_content_label = Label(120, 100, 'the_flag_goes_here',

                               color=pg.Color('red'), font=pg.font.Font('fonts/arial.ttf', 32))

    controls = [heading, flag_label, flag_content_label]

    done = False

    flag_content_label.change_text(decode_flag(token))

Also found the encoded flag itself.

def decode_flag(frob):

    last_value = frob

    encoded_flag = [1135, 1038, 1126, 1028, 1117, 1071, 1094, 1077, 1121, 1087, 1110, 1092, 1072, 1095, 1090, 10>

                    1127, 1040, 1137, 1030, 1127, 1099, 1062, 1101, 1123, 1027, 1136, 1054]

    decoded_flag = []

    for i in range(len(encoded_flag)):

        c = encoded_flag[i]

        val = (c - ((i%2)*1 + (i%3)*2)) ^ last_value

        decoded_flag.append(val)

        last_value = c

    return ''.join([chr(x) for x in decoded_flag])

Can I just call the decode_flag(frob) instead of main?

Pasted image 20220904175155

Nope, it failed. Need to install pygame module real quick. I ended up installing it with apt.

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··································· 7m 31s    11:16:24   ─╮

❯ python fidler.py                                                                                            ─╯

Traceback (most recent call last):

  File "fidler.py", line 1, in <module>

    import pygame as pg

ImportError: No module named pygame

Another error, this time complaining there's no file where there should be. Just need to move it over, cool.

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··············································· 11:21:06   ─╮

❯ python3 fidler.py                                                                                           ─╯

pygame 1.9.6

Hello from the pygame community. [https://www.pygame.org/contribute.html](https://www.pygame.org/contribute.html)

xcb_connection_has_error() returned true

xcb_connection_has_error() returned true

Traceback (most recent call last):

  File "fidler.py", line 3, in <module>

    from controls import *

  File "/home/borari/cybersecurity/flare-on/2020/1-fiddler/controls.py", line 4, in <module>

    DEFAULT_FONT = pg.font.Font('fonts/arial.ttf', 22)

FileNotFoundError: [Errno 2] No such file or directory: 'fonts/arial.ttf'

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··············································· 11:22:20   ─╮

❯ ll                                                                                                          ─╯

total 23M

drwxrwx--- 1 root vboxsf   576 Sep 13 11:22 .

drwxrwx--- 1 root vboxsf    96 Sep 13 11:22 ..

-rwxrwx--- 1 root vboxsf   11M Sep 13 10:58 1_-_fidler.7z

-rwxrwx--- 1 root vboxsf 1013K Sep 15  2018 arial.ttf

-rwxrwx--- 1 root vboxsf   219 Jul 27 12:54 btndown.png

-rwxrwx--- 1 root vboxsf   222 Jul 27 12:54 btnup.png

-rwxrwx--- 1 root vboxsf   192 Jul 27 16:38 clock.png

-rwxrwx--- 1 root vboxsf   249 Jul 27 12:53 coin.png

-rwxrwx--- 1 root vboxsf  5.6K Jul 28 08:07 controls.py

-rwxrwx--- 1 root vboxsf  787K Sep 15  2018 courbd.ttf

-rwxrwx--- 1 root vboxsf   55K Jul 27 11:53 fbi.png

-rwxrwx--- 1 root vboxsf  9.8M Sep 10 09:39 fidler.exe

-rwxrwx--- 1 root vboxsf  9.3K Sep 13 11:16 fidler.py

drwxrwx--- 1 root vboxsf    64 Sep 13 11:04 fonts

drwxrwx--- 1 root vboxsf    64 Sep 13 11:04 img

-rwxrwx--- 1 root vboxsf   36K Jul 27 15:52 kittyelaine.png

-rwxrwx--- 1 root vboxsf   432 Sep 11 09:40 Message.txt

drwxrwx--- 1 root vboxsf    96 Sep 13 11:22 __pycache__

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··············································· 11:22:42   ─╮

❯ ll fonts                                                                                                    ─╯

total 0

drwxrwx--- 1 root vboxsf  64 Sep 13 11:04 .

drwxrwx--- 1 root vboxsf 576 Sep 13 11:22 ..

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··············································· 11:22:49   ─╮

❯ mv arial.ttf fonts                                                                                          ─╯

I'm missing a positional argument 'frob'.

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··············································· 11:22:53   ─╮

❯ python3 fidler.py                                                                                           ─╯

pygame 1.9.6

Hello from the pygame community. [https://www.pygame.org/contribute.html](https://www.pygame.org/contribute.html)

xcb_connection_has_error() returned true

xcb_connection_has_error() returned true

Traceback (most recent call last):

  File "fidler.py", line 252, in <module>

    decode_flag()

TypeError: decode_flag() missing 1 required positional argument: 'frob'

Here's the target amount of coins.

target_amount = (2**36) + (2**35)

        if current_coins > (target_amount - 2**20):

            while current_coins >= (target_amount + 2**20):

                current_coins -= 2**20

            victory_screen(int(current_coins / 10**8))

            return

I need to calculate the target coin integer.

    ~ ······································································ 1h 6m 30s    11:01:45   ─╮

❯ python                                                                                                      ─╯

Python 2.7.18 (default, Apr 20 2020, 20:30:41)

[GCC 9.3.0] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> 2**36

68719476736

>>> (((2**36)+(2**35))+(2**20))/10**8)

  File "<stdin>", line 1

    (((2**36)+(2**35))+(2**20))/10**8)

                                     ^

SyntaxError: invalid syntax

>>> (((2**36)+(2**35))+(2**20))/(10**8)

1030

>>>

I update the fidler.py code with this int.

  |  ~/cybersecurity/flare-on/2020/1-fiddler ······································· 5s    11:35:12   ─╮

❯ tail fidler.py                                                                                              ─╯

def main():

    if password_screen():

        game_screen()

    else:

        password_fail_screen()

    pg.quit()

if __name__ == '__main__':

    decode_flag(1030)

Another error.

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··············································· 11:35:16   ─╮

❯ python3 fidler.py                                                                                           ─╯

pygame 1.9.6

Hello from the pygame community. [https://www.pygame.org/contribute.html](https://www.pygame.org/contribute.html)

xcb_connection_has_error() returned true

xcb_connection_has_error() returned true

I need to update main to call decode_flag, while leaving the very last bit alone?

   |  ~/cybersecurity/flare-on/2020/1-fiddler ···································· 3m 4s    11:39:20   ─╮

❯ tail fidler.py                                                                                              ─╯

def main():

    #if password_screen():

    #    game_screen()

    #else:

    #    password_fail_screen()

    #pg.quit()

    decode_flag(1030)

if __name__ == '__main__':

    main()

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··············································· 11:39:23   ─╮

❯

Ok, I need to run it in the background with &, and I need to make sure my X11 forward is still open. The source is loading properly now. Pasted image 20220904175500 Shit, it ran successfully, but I didn’t get any output lol.

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··········································    11:46:38   ─╮

❯ pygame 1.9.6                                                                                                ─╯

Hello from the pygame community. [https://www.pygame.org/contribute.html](https://www.pygame.org/contribute.html)

[2]  + 4248 done       python3 fidler.py

It ran again, but outputed just a bunch of numbers, I must have put the print() function in a loop.

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··········································    11:46:38   ─╮

❯ python3 fidler.py&                                                                                          ─╯

[2] 4258

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··········································    11:49:54   ─╮

❯ pygame 1.9.6                                                                                                ─╯

Hello from the pygame community. [https://www.pygame.org/contribute.html](https://www.pygame.org/contribute.html)

105

100

108

101

95

119

105

116

104

95

107

105

116

116

121

64

102

108

97

114

101

45

111

110

46

99

111

109

[2]  + 4258 done       python3 fidler.py

Ok, got it fixed. I changed the return command in the decode_flag function to print(). I left the main definition a call to decode_flag(1036) or whatever that int was, and got the flag!

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··········································    11:49:54   ─╮

❯ python3 fidler.py&                                                                                          ─╯

[2] 4267

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··········································    11:53:07   ─╮

❯ pygame 1.9.6                                                                                                ─╯

Hello from the pygame community. [https://www.pygame.org/contribute.html](https://www.pygame.org/contribute.html)

idle_with_kitty@flare-on.com

[2]  + 4267 done       python3 fidler.py

   |  ~/cybersecurity/flare-on/2020/1-fiddler ··········································    11:53:07   ─╮

❯

chal-1-completed