Posted | Modified
Author

The researchers who work with binary data have eyes trained on recognizing patterns in hexdumps.

The pattern consists of bytes with redundancy in them. Such pattern may include array of correlated values, structures with fixed length, runs of bytes, textual data, machine instruction fragments, etc.

The researchers may look for patterns in hexdump of some file or memory content. That covers lots of more specific content types, such as varying file formats, malware samples, firmware images, process memory dumps, etc.

There are many reasons to analyze a hexdump. For each situation the reasons may vary. Here are few:

  • Improve data compression ratio of the compression algorithm.
  • Improve data mutation efficiency of the fuzzer.
  • Have an idea of how the program parses and processes the data, without reverse engineering the program (which may not even be available to access).
  • Improve decision making for telling if a sample is malware, and if it is malware, which family it can be associated with.
  • Recover data artifacts from a corrupted or an unknown sample. Recover concealed data from sample hidden by stenography techniques.
  • Hypothesize on the layout of the data.
  • Find anomaly in data such as in network traffic.
  • Decide on if data is random (when no redundancies are observed).

Being able to automate the manual pattern recognition task would have two important advantages:

  1. A tool would allow for anyone to assist in recognizing patterns in a hexdump.
  2. Analyses could have been done in batches and at scale.

The core strategy for automated hexdump analysis is like this.

The automation splits the input stream into blocks. I approximated the number of bytes I can manually process at a time when looking at hexdump and I came up with a number, so the block has a size of 64 bytes, which is just large enough to contain patterns in it.

The pattern recognition is being done through analyzers.

There is a set of analyzers for different patterns. Each analyzer runs on a block. The result of the analyzers are being compared that the analyzer with the best result, that is with the highest score, will describe the block.

When comparing the result between two analyzers, the one that covers for more bytes has the higher score. The higher score means more certainty. If the score is the absolute maximum it means 100% certainty.

The name of the analyzer should be as relevant as possible to every single byte incorporated in the pattern recognition.

Each analyzer is given a distinct priority. If two analyzers come back with the same score for a given block, the analyzer with the higher priority will describe the block.

The reason to maintain a priority list for the analyzers is because one analyzer is more specific than other and more meaningful than other.

The file notepad.exe is being opened in the prototype version of HexLasso Desktop which implements the core strategy of hexdump analysis.

Posted | Modified
Author

This is an important article to read if you use HexLasso CLI for analyzing files in a Windows installation.

Symptoms

When you use HexLasso CLI to analyze files in a Windows installation you may experience that the analysis result is unexpected on one or more files.

Cause

You may see unexpected result if you run HexLasso CLI on files that are subject to file system redirection.

The file system redirection is a feature of the 64-bit version of Windows and it redirects file access for backward compatibility reasons.

HexLasso CLI is not aware of this redirection. And therefore, for example, if you intend to analyze C:\Windows\System32\wermgr.exe, Windows will redirect the file access to C:\Windows\SysWOW64\wermgr.exe and so the latter file will be analyzed.

Workaround

  1. Copy the files of the Windows installation into a temporary folder using a copy utility. Most of the copy utilities can handle file system redirection.
  2. You can now run HexLasso CLI on the files of the temporary folder.

Remarks

Although Microsoft provides an API function to disable file system redirection for the application, it would require calling native function from the otherwise fully managed code. Looking ahead, keeping the fully managed code is preferred over addressing this platform specific issue via code change.

Posted | Modified
Author

It’s more straightforward to understand redundant data than non-redundant data. So when analyzing binaries we look for redundancy.

Low entropy score indicates the presence of redundant data. High entropy score, however, does not necessarily indicate the presence of non-redundant data. High entropy data may or may not be redundant.

To decide on if a high entropy data is redundant, additional analysis is required. There is no all-in-one solution to tell where the redundancies are.

The following examples describe organic samples that contain high entropy blocks and explain the redundancies in those blocks.

High Match Coverage in High Entropy Data

I created a plot with HexLasso by selecting ENTROPY and MATCH_COVERAGE_DWORD analyzers.

According the ENTROPY analyzer (red line), the block at offset 7168 has an entropy of over 90% which is more than 7.2 (out of 8).

The MATCH_COVERAGE_DWORD analyzer (green line) reports match coverage of over 90% for the same block.


The HexLasso plot of a sample showing high entropy (red) and high match coverage (green) between the data offsets 7168 and 8192.

After viewing the hexdump of the block, the pattern in the data becomes obvious.

The first part of the data is a sequence of bytes, in incremental order, from 00 to FF. The sequence is repeated till more than half of the block.

The second part of the data contains text with some words repeating few times.


The hexdump showing a block of high entropy data taken from a sample at offset 7168 (1C00h). Matches can be seen all over.

High Coverage for Runs of Bytes in High Entropy Data

I created a plot with HexLasso by selecting ENTROPY and RUNS_OF_BYTES_MINLEN_4 analyzers.

According the ENTROPY analyzer (red line), the block at offset 44032 has an entropy of about 99% which is about 7.9 (out of 8).

The RUNS_OF_BYTES_MINLEN_4 analyzer (green line) reports runs-of-bytes coverage of about 99% for the same block.


The HexLasso plot of a sample showing high entropy (red) and high coverage for runs of bytes (green) between the data offsets 44032 and 45056.

After viewing the hexdump of the block, the pattern in the data becomes obvious.

Most of the data (apart from the first 8 bytes) can be described as a sequence of varying DWORDs, and each byte in a DWORD is the same.


The hexdump showing a block of high entropy data taken from a sample at offset 44032 (AC00h). Runs of bytes can be seen all over.

Posted | Modified
Author

Introduction

HexLasso CLI is a binary data analysis utility with command line interface that allows for static exploration of binary data.

HexLasso CLI takes input files and produces an interactive HTML file that can be viewed from a web browser.


The HexLasso plot of a high entropy sample showing increased matches in the second half of the data in green.

When the HTML file is loaded in the web browser, you can choose out of a list of analysis plots to be drawn. Such plots include entropy, match coverage, and byte frequency plots among others.

Plots you choose are combined into one overall graph which comes with the advantage to see the correlation between them.

The horizontal axis is the position in the data, and the vertical axis is the score between 0 and 100.

You can mark positions in the plot to display the data offset of important location.

Plots

You can choose out of a list of analysis plots to be drawn.

ENTROPY
ENTROPY_IN_ORDER_1
BYTE_PREDICTION_IN_ORDER_1
COMPRESSED_SIZE_DEFLATE_OR_DATA_SIZE
UNIQUE_DWORD_CNT
UNIQUE_WORD_CNT
UNIQUE_BYTE_CNT
MATCH_COVERAGE_WORD
MATCH_COVERAGE_DWORD
MATCH_COVERAGE_QWORD
BYTE_FREQ_ASCII_CONTROL
BYTE_FREQ_ASCII_PRINTABLE
BYTE_FREQ_EXTENDED_ASCII
BYTE_FREQ_00
BYTE_FREQ_FF
BYTE_FREQ_8B
BYTE_FREQ_E8_E9
BYTE_FREQ_MULTIPLE_OF_4
BYTE_FREQ_MULTIPLE_OF_8
WORD_FREQ_FF15
WORD_FREQ_FF25
MOST_FREQ_BYTE_VALUE
MOST_FREQ_BYTE_COVERAGE
STRING_COVERAGE_ASCII_PRINTABLE_MINLEN_4
STRING_COVERAGE_ASCII_PRINTABLE_MINLEN_8
STRING_COVERAGE_UNICODE_PRINTABLE_MINLEN_4
STRING_COVERAGE_UNICODE_PRINTABLE_MINLEN_8
RUNS_OF_BYTES_MINLEN_4
RUNS_OF_BYTES_MINLEN_8
RELATIVE_REFERENCE
DELTA_CH

System Requirements

The minimum required OS to run HexLasso CLI is Windows XP. A web browser with SVG and JavaScript support is required to run the interactive HTML file.

Development Details

HexLasso CLI is being developed in Visual C# 2010 and .NET Framework 4. It is entirely implemented in managed code.

HexLasso CLI is a spin-off project of BinCovery.

Posted | Modified
Author

This collection of public utilities will be useful for the exploration of binary data.

Find Frequent 16-bit
FF-16 is a static analysis tool that finds frequently occurring local 16-bit patterns across the entire file. It can help to locate structures from frequent patterns and understand file layout.

HexLasso Online
With HexLasso Online you can visually explore the structure of binary data to spot varying redundancies. You can choose between many analyzers to spot blocks of specific bytes, strings, runs of bytes, matches and code fragments.

Binwalk
Binwalk is commonly used for firmware analysis. With a diverse set of signatures built-in to recognize compressed stream, executable code, cryptographic markers and so on, you can use Binwalk to scan arbitrary binaries.

Visual analysis of binary files
Binvis.io is an interactive online utility for the visual exploration of binary data.

BinVis
BinVis (not to be confused with binvis.io which was developed by another author) is a binary file visualization prototype supporting many plots including byte plot, bit plot, RGB plot, entropy plot, and so on.

binocle
binocle is a graphical tool to visualize binary data. It colorizes bytes according to different rules and renders them as pixels in a rectangular grid.

hobbits from Mahlet-Inc
hobbits is a multi-platform GUI for bit-based analysis, processing, and visualization.

Strings
Strings scans the input binary for ASCII and Unicode texts.

byte-stats.py of Didier Stevens Suite
byte-stats.py is a tool that computes byte-level statistics for files.

binGraph
binGraph is a command line tool to plot entropy and histogram charts of binary data.

entroPy
entroPy visualizes the entropy of binary data in bird eye view that the darker an area the lower entropy it has.

The many hex editors
Free and commercial hex editors.

HexEd.it
HexEd.it is an online hex editor with data inspector.

ImHex
ImHex is an open source hex editor with rich feature set including disassembler support and night mode.

Deepmage
Deepmage is a hex editor that can handle data in units of arbitrary bit width.

hexyl, hexsa
They are hex viewers that produce hex dumps in colors to distinguish different categories of bytes.

HexWalk
HexWalk is an open-source hex editor/viewer and analyzer based on qhexedit2, binwalk and QT.

Multidiff
Multidiff compares multiple binary files.

FV program
FV program is a well-known utility in the compression development industry. It is used to visualize the matches in the data. There is a reference to FV in the Data Compression Explained book.

DataSmoke
DataSmoke aims to distinguish different data types (in order to choose the best compression method). It has multiple short algorithms and some are based on entropy calculation.

ent – A Pseudorandom Number Sequence Test Program
Ent tests the randomness of the content of a file. It uses various algorithms including entropy, chi-squared test, arithmetic mean, correlation coefficient, and so on.

file2img
file2img interprets the content of the given file as image with the option to select the pixel format.

Dump2Picture
Dump2Picture adds a BMP header to arbitrary file. The result can be viewed as an image.

QuickBMS
QuickBMS allows to extract content from compressed and encryped file formats.

Signsrch
Signsrch scans files to recognize compressed stream, encryption, checksum, and so on. It uses an external signature file.

NIST Statistical Test Suite
This research project can be useful to learn about approaches to analyze binary data.

Feel free to send an email about other valuable utilities on the topic.