可以加密PNG而不会丢失exif数据吗?

时间:2014-01-16 07:19:06

标签: image encryption steganography

我一直在研究这个Reddit难题:

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

并且线程中的大多数用户都被难倒了。完全披露,我很想赢得奖品,但通过关注它并寻求帮助,我明白我减少了机会,但此时我想知道图像的内容比什么都重要。

我们将密码缩小为带有PNG exif数据的文本文件的URL,但是当作为PNG打开时,它会被破坏。这个PNG是否可以加密或故意损坏,以保留exif数据以及解开它的最佳方法是什么?请注意,数字字符串和“AK”明确地链接到这个线索,所以我只能假设可能有一个异步键或Arjen Kampf Lenstra或一些愤怒的孩子背后的一些标准。

1 个答案:

答案 0 :(得分:1)

当然,像这样使用ImageMagick:

# 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

现在在图片中添加评论并将其加密为encrypted.png

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

检查加密图像的标题,看看EXIF数据和评论以及其他数据是否可见 - 是的,它们是:

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

现在看看加密的图像 - 垃圾

enter image description here

将图像解密为decrypted.jpg - 对我来说看起来像一朵玫瑰: - )

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

enter image description here