How can I view this encoded file? [closed]

I receive data every day from a client, but I can't read it. It's an encoded file. If I open it directly with cat, less or vi, I can't read it.

The customer shared the data file as file_name.ZIP.zip (120 Mb). After I extracted the contents I got one more zip file like file_name.ZIP.zip (120 Mb) and file_name.ZIP (125 mb). Once again extracting I get file_name (4-5 GB) with file type application/octet-stream; charset=binary format.

NOTE: I receive the file in some different formats, like binary, ISO8859, etc.

Sample data:

$ hexdump -C file_name | head 00000000 40 40 40 40 60 60 40 40 40 40 40 40 40 40 40 40 |@@@@``@@@@@@@@@@| 00000010 40 40 40 40 40 00 00 00 00 00 00 00 00 00 00 00 |@@@@@...........| 00000020 00 00 00 00 00 60 60 40 40 40 40 40 40 60 60 40 |.....``@@@@@@``@| 00000030 40 40 40 40 40 40 40 40 40 40 00 00 00 00 00 00 |@@@@@@@@@@......| 00000040 00 00 00 00 00 00 00 00 00 00 60 60 40 40 40 40 |..........``@@@@| 00000050 40 40 60 60 40 40 40 40 40 40 40 40 40 40 00 00 |@@``@@@@@@@@@@..| 00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 60 60 |..............``| 00000070 40 40 40 40 40 40 60 60 40 40 40 40 40 40 40 40 |@@@@@@``@@@@@@@@| 00000080 40 40 40 00 00 00 00 00 00 00 00 00 00 00 00 00 |@@@.............| 00000090 00 00 00 60 60 40 40 40 40 40 40 60 60 40 40 40 |...``@@@@@@``@@@| 

Checking the file format/type,

$ file -bi file_name application/octet-stream; charset=binary 

Afterwards I tried to change the file format using iconv -l,

iconv -f ascii -t utf-8 file_name > New_file_name.txt; 

or

iconv -f ISO8859-1 -t utf-8 file_name -o New_file_name.txt; 

How can I decode or view this file in human readable format?

If I use hexdump,

$ hexdump -C file_name | head 00000000 40 40 40 40 60 60 40 40 40 40 40 40 40 40 40 40 |@@@@``@@@@@@@@@@| 00000010 40 40 40 40 40 00 00 00 00 00 00 00 00 00 00 00 |@@@@@...........| 00000020 00 00 00 00 00 60 60 40 40 40 40 40 40 60 60 40 |.....``@@@@@@``@| 00000030 40 40 40 40 40 40 40 40 40 40 00 00 00 00 00 00 |@@@@@@@@@@......| 00000040 00 00 00 00 00 00 00 00 00 00 60 60 40 40 40 40 |..........``@@@@| 00000050 40 40 60 60 40 40 40 40 40 40 40 40 40 40 00 00 |@@``@@@@@@@@@@..| 00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 60 60 |..............``| 00000070 40 40 40 40 40 40 60 60 40 40 40 40 40 40 40 40 |@@@@@@``@@@@@@@@| 00000080 40 40 40 00 00 00 00 00 00 00 00 00 00 00 00 00 |@@@.............| 00000090 00 00 00 60 60 40 40 40 40 40 40 60 60 40 40 40 |...``@@@@@@``@@@| 
5

1 Answer

It is inappropriate to use iconv on non-text files.

What you can do is use a hex-dump program to view the contents of a binary file.

$ hexdump -C binary.data | head 00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............| 00000010 02 00 3e 00 01 00 00 00 c0 0e 40 00 00 00 00 00 |..>.......@.....| 00000020 40 00 00 00 00 00 00 00 80 56 00 00 00 00 00 00 |@........V......| 00000030 00 00 00 00 40 00 38 00 08 00 40 00 1f 00 1e 00 |....@.8...@.....| 00000040 06 00 00 00 05 00 00 00 40 00 00 00 00 00 00 00 |........@.......| 00000050 40 00 40 00 00 00 00 00 40 00 40 00 00 00 00 00 |@.@.....@.@.....| 00000060 c0 01 00 00 00 00 00 00 c0 01 00 00 00 00 00 00 |................| 00000070 08 00 00 00 00 00 00 00 03 00 00 00 04 00 00 00 |................| 00000080 00 02 00 00 00 00 00 00 00 02 40 00 00 00 00 00 |..........@.....| 00000090 00 02 40 00 00 00 00 00 1c 00 00 00 00 00 00 00 |..@.............| 

In many cases, this will not be immediately enlightening, you need to do one of two things

  • Get a specification for the file format and obtain or write a decoder that presents the data in human readable form.
  • Use any knowledge of the content domain and deductive reasoning to examine the binary contents and work out (reverse engineer) the structure and meaning. This is usually hard work.
3

You Might Also Like