@timmy_i_chen/

secret announcement

Python

This is a puzzle that contains a secret announcement. Use your steganography and reverse engineering skills to figure it out!

fork
loading
Files
  • main.py
  • out.png

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9565300117127198","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"ZnJvbSBQSUwgaW1wb3J0IEltYWdlCgojIHRvIHN0YXJ0LCBjbGljayBvbiBvdXQucG5nIGFuZCBkb3dubG9hZCB0aGUgaW1hZ2UKIyAoZG9uJ3QgZG93bmxvYWQgdGhlIGpwZyBmcm9tIHRoZSBuZXdzbGV0dGVyIC0gc2VlIGxhc3QgY29tbWVudCkKCiMgdGhlIG9yaWdpbmFsIHR3byBmaWxlcyBhcmUgbWlzc2luZwojIGNhbiB5b3UgcmV2ZXJzZSBlbmdpbmVlciB0aGlzIHByb2dyYW0KIyB0byBmaW5kIHRoZSBoaWRkZW4gbWVzc2FnZSBpbiB0aGUgcGljdHVyZT8KIyBoaW50OiBzdGVnYW5vZ3JhcGh5CnB1YmxpYyA9IEltYWdlLm9wZW4oImNvbXAuanBnIikuY29udmVydCgiUkdCIikKc2VjcmV0ID0gSW1hZ2Uub3Blbigic2VjcmV0LmpwZyIpLmNvbnZlcnQoIlJHQiIpCgpvdXQgPSBJbWFnZS5uZXcoIlJHQiIsICg2MDAsIDYwMCkpCgphbGxfZXhjZXB0X0xTQl9tYXNrID0gMjU0ICMgYmluYXJ5OiAxMTExMTExMApzaGlmdF9hbXQgPSA3Cgpmb3IgeCBpbiByYW5nZSg2MDApOgogIGZvciB5IGluIHJhbmdlKDYwMCk6CiAgICBzZWNyZXRfcGl4ID0gc2VjcmV0LmdldHBpeGVsKCh4LCB5KSkKICAgIHB1YmxpY19waXggPSBwdWJsaWMuZ2V0cGl4ZWwoKHgsIHkpKQoKICAgIHNlY3JldF9yZWQgPSBzZWNyZXRfcGl4WzBdID4+IHNoaWZ0X2FtdAogICAgc2VjcmV0X2dyZWVuID0gc2VjcmV0X3BpeFsxXSA+PiBzaGlmdF9hbXQKICAgIHNlY3JldF9ibHVlID0gc2VjcmV0X3BpeFsyXSA+PiBzaGlmdF9hbXQKCiAgICBwdWJsaWNfcmVkID0gcHVibGljX3BpeFswXSAmIGFsbF9leGNlcHRfTFNCX21hc2sKICAgIHB1YmxpY19ncmVlbiA9IHB1YmxpY19waXhbMV0gJiBhbGxfZXhjZXB0X0xTQl9tYXNrCiAgICBwdWJsaWNfYmx1ZSA9IHB1YmxpY19waXhbMl0gJiBhbGxfZXhjZXB0X0xTQl9tYXNrCiAgICAKICAgIGZpbmFsID0gKAogICAgICBzZWNyZXRfcmVkICsgcHVibGljX3JlZCwKICAgICAgc2VjcmV0X2dyZWVuICsgcHVibGljX2dyZWVuLAogICAgICBzZWNyZXRfYmx1ZSArIHB1YmxpY19ibHVlCiAgICApCgogICAgb3V0LnB1dHBpeGVsKCh4LCB5KSwgZmluYWwpCgojIG11c3QgYmUgcG5nISBubyBqcGcgYmVjYXVzZSBjb21wcmVzc2lvbiBpcyBldmlsIDooCm91dC5zYXZlKCdvdXQucG5nJykK"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from PIL import Image

# to start, click on out.png and download the image
# (don't download the jpg from the newsletter - see last comment)

# the original two files are missing
# can you reverse engineer this program
# to find the hidden message in the picture?
# hint: steganography
public = Image.open("comp.jpg").convert("RGB")
secret = Image.open("secret.jpg").convert("RGB")

out = Image.new("RGB", (600, 600))

all_except_LSB_mask = 254 # binary: 11111110
shift_amt = 7

for x in range(600):
  for y in range(600):
    secret_pix = secret.getpixel((x, y))
    public_pix = public.getpixel((x, y))

    secret_red = secret_pix[0] >> shift_amt
    secret_green = secret_pix[1] >> shift_amt
    secret_blue = secret_pix[2] >> shift_amt

    public_red = public_pix[0] & all_except_LSB_mask
    public_green = public_pix[1] & all_except_LSB_mask
    public_blue = public_pix[2] & all_except_LSB_mask
    
    final = (
      secret_red + public_red,
      secret_green + public_green,
      secret_blue + public_blue
    )

    out.putpixel((x, y), final)

# must be png! no jpg because compression is evil :(
out.save('out.png')