Search code examples
imageencryptionsteganography

Can a PNG be encrypted without losing the exif data?


I've been working on this Reddit puzzle:

http://www.reddit.com/r/playitforward/comments/1v6jfh/contest_first_one_to_solve_this_riddle_gets_my/

and most of users in the thread are stumped. Full disclosure, I'd love to win the prize, but by bringing attention to it and asking for assistance, I understand that I lessen my chances, but at this point I want to know what the image says more than anything.

We narrowed down the cyphers to a URL to a text file with PNG exif data, but when opened as a PNG, it turns out corrupted. Could this PNG be encrypted or purposely corrupted in a way to preserve the exif data and what would be the best way to unravel it? Note that the string of numbers and "AK" were explicitly linked to this clue, so I can only assume there is maybe an Asynchronous Key involved or some standard pioneered by Arjen Kampf Lenstra or some Angry Kid behind it all.


Solution

  • Sure, using ImageMagick like this:

    # Look at rose image before we start, and its header
    identify -verbose rose.jpg
    

    enter image description here

    Image: rose.jpg
      Format: JPEG (Joint Photographic Experts Group JFIF format)
      Mime type: image/jpeg
      Class: DirectClass
      Geometry: 70x46+0+0
      Units: Undefined
      Type: TrueColor
      Endianess: Undefined
      Colorspace: sRGB
      Depth: 8-bit
      Channel depth:
        red: 8-bit
        green: 8-bit
        blue: 8-bit
      Channel statistics:
        Pixels: 3220
        Red:
          min: 31 (0.121569)
          max: 255 (1)
          mean: 145.56 (0.570825)
          standard deviation: 69.1755 (0.271277)
          kurtosis: -1.38839
          skewness: 0.139004
          entropy: 0.97057
        Green:
          min: 27 (0.105882)
          max: 255 (1)
          mean: 89.2475 (0.34999)
          standard deviation: 52.4516 (0.205693)
          kurtosis: 2.60505
          skewness: 1.80798
          entropy: 0.869705
        Blue:
          min: 21 (0.0823529)
          max: 255 (1)
          mean: 80.4214 (0.315378)
          standard deviation: 54.9267 (0.215399)
          kurtosis: 2.93861
          skewness: 1.9566
          entropy: 0.85334
      Image statistics:
        Overall:
          min: 21 (0.0823529)
          max: 255 (1)
          mean: 105.076 (0.412064)
          standard deviation: 59.3109 (0.232592)
          kurtosis: 1.24657
          skewness: 1.44732
          entropy: 0.897872
      Rendering intent: Perceptual
      Gamma: 0.454545
      Chromaticity:
        red primary: (0.64,0.33)
        green primary: (0.3,0.6)
        blue primary: (0.15,0.06)
        white point: (0.3127,0.329)
      Background color: white
      Border color: srgb(223,223,223)
      Matte color: grey74
      Transparent color: black
      Interlace: None
      Intensity: Undefined
      Compose: Over
      Page geometry: 70x46+0+0
      Dispose: Undefined
      Iterations: 0
      Compression: JPEG
      Quality: 92
      Orientation: Undefined
      Properties:
        date:create: 2015-10-04T18:46:03+01:00
        date:modify: 2015-10-04T18:46:03+01:00
        jpeg:colorspace: 2
        jpeg:sampling-factor: 1x1,1x1,1x1
        signature: 38a8912b601557d5a377bff360f03804c383c3298b48d9917504b488e8f4152b
      Artifacts:
        filename: rose.jpg
        verbose: true
      Tainted: False
      Filesize: 2.65KB
      Number pixels: 3.22K
      Pixels per second: 3.22EB
      User time: 0.000u
      Elapsed time: 0:01.000
      Version: ImageMagick 6.9.1-10 Q32 x86_64 2015-10-02 http://www.imagemagick.org
    

    Now add a comment into the image and encrypt it as encrypted.png:

    convert -comment "Freddy frog" rose.jpg -encipher passphrase.txt encrypted.png
    

    Check the header of encrypted image to see if EXIF data and comment and other data are visible within it - yes, they are:

    identify -verbose encrypted.png
    
    Image: encrypted.png
      Format: PNG (Portable Network Graphics)
      Mime type: image/png
      Class: DirectClass
      Geometry: 70x46+0+0
      Units: Undefined
      Type: TrueColor
      Endianess: Undefined
      Colorspace: sRGB
      Depth: 8-bit
      Channel depth:
        red: 8-bit
        green: 8-bit
        blue: 8-bit
      Channel statistics:
        Pixels: 3220
        Red:
          min: 0 (0)
          max: 255 (1)
          mean: 126.755 (0.497077)
          standard deviation: 73.7824 (0.289343)
          kurtosis: -1.18047
          skewness: 0.0142557
          entropy: 0.99254
        Green:
          min: 0 (0)
          max: 255 (1)
          mean: 127.937 (0.501712)
          standard deviation: 75.0501 (0.294314)
          kurtosis: -1.23185
          skewness: -0.0233363
          entropy: 0.992485
        Blue:
          min: 0 (0)
          max: 255 (1)
          mean: 127.594 (0.500368)
          standard deviation: 74.64 (0.292706)
          kurtosis: -1.22352
          skewness: -0.0177342
          entropy: 0.992544
      Image statistics:
        Overall:
          min: 0 (0)
          max: 255 (1)
          mean: 127.428 (0.499719)
          standard deviation: 74.4927 (0.292128)
          kurtosis: -1.21239
          skewness: -0.00900116
          entropy: 0.992523
      Rendering intent: Perceptual
      Gamma: 0.45455
      Chromaticity:
        red primary: (0.64,0.33)
        green primary: (0.3,0.6)
        blue primary: (0.15,0.06)
        white point: (0.3127,0.329)
      Background color: white
      Border color: srgb(223,223,223)
      Matte color: grey74
      Transparent color: black
      Interlace: None
      Intensity: Undefined
      Compose: Over
      Page geometry: 70x46+0+0
      Dispose: Undefined
      Iterations: 0
      Compression: Zip
      Orientation: Undefined
      Properties:
        cipher:mode: CTR
        cipher:nonce: d3d57ca43eacb27a9d72b65ef976923e5b761c7aaaee1d1914d1769ca4834488
        cipher:type: AES
        comment: Freddy frog                                      <--- comment is visible
        date:create: 2015-10-04T18:48:43+01:00
        date:modify: 2015-10-04T18:48:43+01:00
        png:bKGD: chunk was found (see Background color, above)
        png:cHRM: chunk was found (see Chromaticity, above)
        png:gAMA: gamma=0.45454544 (See Gamma, above)
        png:IHDR.bit-depth-orig: 8
        png:IHDR.bit_depth: 8
        png:IHDR.color-type-orig: 2
        png:IHDR.color_type: 2 (Truecolor)
        png:IHDR.interlace_method: 0 (Not interlaced)
        png:IHDR.width,height: 70, 46
        png:sRGB: intent=0 (Perceptual Intent)
        png:text: 6 tEXt/zTXt/iTXt chunks were found
        signature: 273e3934027f6ffbcf00b3eca7eb0c576d8fd180e87133112ecacd59225986ee
      Artifacts:
        filename: encrypted.png
        verbose: true
      Tainted: False
      Filesize: 10.1KB
      Number pixels: 3.22K
      Pixels per second: 3.22EB
      User time: 0.000u
      Elapsed time: 0:01.000
      Version: ImageMagick 6.9.1-10 Q32 x86_64 2015-10-02 http://www.imagemagick.org
    

    Now look at the encrypted image - junk

    enter image description here

    Decrypt image as decrypted.jpg - looks like a rose to me :-)

    convert encrypted.png -decipher passphrase.txt decrypted.jpg
    

    enter image description here