X-NUCA(牛咖)联赛11月Crypto&Misc专题赛赛前--p1ng的解题思路 

X-NUCA(牛咖)联赛11月Crypto&Misc专题赛赛前--p1ng的解题思路

发表于:2016-11-18 10:00:00 来源:  合天网安实验室 阅读数(0人)

binwalk p1ng


DECIMAL HEXADECIMAL DESCRIPTION


——————————————————————

0 0x0 PNG image, 180 x 76, 8-bit/color RGBA, non-interlaced


99 0x63 Zlib compressed data, best compression


4987 0x137B Zlib compressed data, best compression


.


.


.


146983 0x23E27 Zlib compressed data, best compression


使用如下代码。即可得到答案


<?php
function splitapng($data) {
  $parts = array();

  // Save the PNG signature
  $signature = substr($data, 0, 8);
  $offset = 8;
  $size = strlen($data);
  while ($offset < $size) {
    // Read the chunk length
    $length = substr($data, $offset, 4);
    $offset += 4;

    // Read the chunk type
    $type = substr($data, $offset, 4);
    $offset += 4;

    // Unpack the length and read the chunk data including 4 byte CRC
    $ilength = unpack('Nlength', $length);
    $ilength = $ilength['length'];
    $chunk = substr($data, $offset, $ilength+4);
    $offset += $ilength+4;

    if ($type == 'IHDR')
      $header = $length . $type . $chunk;  // save the header chunk
    else if ($type == 'IEND')
      $end = $length . $type . $chunk;     // save the end chunk
    else if ($type == 'IDAT')
      $parts[] = $length . $type . $chunk; // save the first frame
    else if ($type == 'fdAT') {
      // Animation frames need a bit of tweaking.
      // We need to drop the first 4 bytes and set the correct type.
      $length = pack('N', $ilength-4);
      $type = 'IDAT';
      $chunk = substr($chunk,4);
      $parts[] = $length . $type . $chunk;
    }
  }

  // Now we just add the signature, header, and end chunks to every part.
  for ($i = 0; $i < count($parts); $i++) {
    $parts[$i] = $signature . $header . $parts[$i] . $end;
  }

  return $parts;
}

$filename = 'p1ng';

$handle = fopen($filename, 'rb');
$filesize = filesize($filename);
$data = fread($handle, $filesize);
fclose($handle);

$parts = splitapng($data);

for ($i = 0; $i < count($parts); $i++) {
  $handle = fopen("part-$i.png",'wb');
  fwrite($handle,$parts[$i]);
  fclose($handle);
}

相关新闻

大家都在学

课程详情

网络安全漫谈

课程详情

信息安全基础

课程详情

网络安全基础