diff --git a/reverse-engineering/cimg-quest-1/_0/quest.py b/reverse-engineering/cimg-quest-1/_0/quest.py index 13955f0..538ee98 100755 --- a/reverse-engineering/cimg-quest-1/_0/quest.py +++ b/reverse-engineering/cimg-quest-1/_0/quest.py @@ -144,6 +144,7 @@ def game(): flag = b"ERROR: /flag permission denied" hidden_bytes = [ bytes([b]) for b in flag ][::-1] + hidden_x = random.randrange(w) hidden_y = random.randrange(h) revealed_bytes = [ ] @@ -192,21 +193,27 @@ def game(): # render everyone screen.blank() + correct_bytes = '' for rx,ry,r,g,b,c in revealed_bytes: - screen.render_patch_monochrome([ c ], rx, ry, r=r, g=g, b=b) + screen.render_patch_monochrome([c], rx, ry, r=r, g=g, b=b) + correct_bytes += str(c.decode()) if hidden_bytes: screen.render_patch_monochrome( - [ b"?" ], hidden_x, hidden_y, + [b"?"], hidden_x, hidden_y, r=random.randrange(256), g=random.randrange(256), b=random.randrange(256) ) else: - while True: - screen.animate_text("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", 10, hidden_y) - screen.animate_text("!!! CONGRATULATIONS, YOU DID IT !!!", 10, hidden_y+1) - screen.animate_text("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", 10, hidden_y+2) - screen.animate_text("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", 10, hidden_y+1) - - screen.render_patch_monochrome([ b"B" ], bomb_x, bomb_y) + try: + while True: + screen.animate_text("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", 10, hidden_y) + screen.animate_text("!!! CONGRATULATIONS, YOU DID IT !!!", 10, hidden_y + 1) + screen.animate_text(correct_bytes, 10, hidden_y + 2) + screen.animate_text("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", 10, hidden_y + 1) + except KeyboardInterrupt: + print(flag.decode(), file=sys.stderr) # Print decoded flag to stderr + break + + screen.render_patch_monochrome([b"B"], bomb_x, bomb_y) screen.render_sprite(our_sprite, x, y) screen.flush()