linux - 数字取证 : what can i get out from my . 原始文件?

标签 linux file format

我有一个扩展名为 .raw 的文件(原始图像格式),但我无法打开它。我尝试使用命令 file filename.rawexiv2 printexiftoolufraw绘制。因为它看起来是一个二进制文件,所以我尝试使用 strings filename.rawhexdumpxxd 提取信息。令人惊讶的是,该文件似乎没有任何元数据。怀疑文件扩展名错误,文件被操纵

我还能如何确定类型?我怎样才能提取任何信息?

非常感谢您的任何建议。

编辑:可以下载示例文件 here .

最佳答案

嗯……嗯,

//从文件的字节数来看:

//1447600

//这个数字正好。

//3 x 499 x 967

//这很奇怪,但这意味着如果这是一个图像,那么它必须是每个像素 3 个字节,并且是 499 x 967 或 967 x 499

编辑:分辨率错误。也可能是每个 channel 的位数,这就是我在半夜使用 bc 而不是 WA 得到的结果。

实际因子是2^4*5^2*7*11*47,也就是说不可能是3Bytes per pixel。可能正在进行一些流压缩?但可能不是,这个数字太好了。

查看一些数据,其中大部分都非常嘈杂,这适合带有嘈杂数字传感器的相机:

00000000  0e 08 06 02 04 06 00 02  00 04 01 04 0e 03 05 01  |................|
00000010  03 01 06 04 00 03 01 05  01 00 02 00 06 02 04 01  |................|
00000020  00 07 0c 0d 05 01 0a 0d  03 08 11 08 0c 03 06 06  |................|
00000030  08 02 07 04 01 01 07 02  05 06 10 04 07 01 04 02  |................|
00000040  02 01 0c 09 07 02 05 01  0d 04 00 05 0e 01 00 07  |................|
00000050  00 02 04 0a 11 04 07 04  01 00 0d 07 0f 06 03 02  |................|
00000060  06 04 0a 0b 03 08 02 0c  00 08 00 04 06 09 03 03  |................|
00000070  04 00 0a 04 01 06 00 00  02 08 0a 07 04 09 01 0b  |................|
00000080  01 0c 0d 04 03 03 05 00  02 11 09 00 07 08 08 05  |................|
00000090  04 07 02 0c 00 13 01 06  07 02 08 0a 07 05 02 01  |................|

这个区域,在文件的开头,很可能接近全黑。

因此,在常见的每像素 3 字节格式中,有 BGR24、RGB24 或 YUV24。

因为处理 RGB 或 BGR 格式更简单,让我们使用 libpng 编写一些短代码将其转储为 png。

第一次尝试:

#include <png.h>
#include <exception>
#include <memory>

int main() {
  FILE * fpout;
  FILE * fpin;
  png_structp png_ptr = nullptr;
  png_infop info_ptr = nullptr;
  const unsigned width = 499;
  const unsigned height = 967;
  const unsigned channels = 3;

  fpin = fopen("sample.raw", "rb");
  if (!fpin)
    throw std::exception();

  std::unique_ptr<char[]> data(new char[width*height*channels]);
  fread(data.get(), width*height*channels, 1, fpin);
  fclose(fpin);

  fpout = fopen("output.png", "wb");
  if (!fpout)
    throw std::exception();

  png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
  if (!png_ptr) {
    fclose (fpout);
    throw std::exception();
  }

  info_ptr = png_create_info_struct(png_ptr);
  if (!info_ptr) {
    png_destroy_write_struct(&png_ptr, nullptr);
    fclose (fpout);
    throw std::exception();
  }

  if (setjmp(png_jmpbuf (png_ptr))) {
    png_destroy_write_struct(&png_ptr, &info_ptr);
    fclose (fpout);
    throw std::exception();
  }

  png_set_IHDR(png_ptr,
      info_ptr,
      width,
      height,
      8,
      PNG_COLOR_TYPE_RGB,
      PNG_INTERLACE_NONE,
      PNG_COMPRESSION_TYPE_DEFAULT,
      PNG_FILTER_TYPE_DEFAULT);

  /* Initialize rows of PNG. */

  std::unique_ptr<png_bytep[]> row_ptrs(new png_bytep[height]);
  size_t stride = width * 8 * channels / 8;
  for (size_t i = 0; i < height; ++i) {
    size_t q = i * stride;
    row_ptrs[i] = (png_bytep)data.get() + q;
  }

  /* Write the image data to "fp". */

  png_init_io(png_ptr, fpout);
  png_set_rows(png_ptr, info_ptr, row_ptrs.get());
  png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, nullptr);

  png_destroy_write_struct(&png_ptr, &info_ptr);
  fclose (fpout);
}

给我们:

http://i.imgur.com/Iwi3M.jpg

这令人振奋,因为似乎我们只是分辨率有误。所以检查图像,看起来条形图每 467 个像素左右重复一次。但是,看起来数据中没有任何有趣的东西。所以它可能不是简单的 RBG 或 BGR 或 YUV 编码,否则,它看起来会更好。

Raw Therapee 无法识别它。所以,我现在问你。你用什么相机拍的?

关于linux - 数字取证 : what can i get out from my . 原始文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13906450/

相关文章:

c++ - 文件二进制与文本

java - udp文件传输项目-是否必须进行错误检查?

python - 如何格式化 float 以千位、反点和逗号分隔?

linux - 动态创建 bash 变量并访问其先前定义的值

linux - 如何使用 Linux 内核中的内存屏障

linux - 如何在linux上监控各种进程

linux - 根据映射对字符串进行更改

c - 文件输入/输出 : two file pointes

c# - .NET String.Format() 在数字的千位添加逗号

format - nim 中的多类型格式化(相当于 boost 格式)