Dynamic binary visualization
Abstract
The “Binary Visualization Dataset” project introduces a unique approach to data representation ; transforming raw binary files into visual images. This novel dataset, created using a Rust script, aims to make data analysis more intuitive and accessible, thereby democratizing the process. Beyond the dataset creation, demonstrate the state of art of the dynamic binary visualization domain.
The project leverages the power of data visualization to simplify complex data, transforming a complex and compute intensive task into a simple one: recognize visual patterns. Beyond simplifying complex data analysis, this project offers a fascinating gateway to the exploration of raw binary files. Potential applications include data recovery, malware understanding, document clustering and traffic analysis. The dataset creation involves collecting binary files, preprocessing, visualizing, annotating, and validating the data. Preliminary results show promise, but also highlight challenges such as complexity in interpreting visualizations of large binary files. Future work includes improving and validating the dataset, and exploring its potential applications in depth.
The following figures illustrate the visualizations produced from six distinct raw binary files:
Context
Dynamic binary visualization is an old concept that aims to help reverse engineer analyzing and working with raw binary data. As presented by Chris Domas in his talk [1], the traditional approach to reverse engineering involves viewing binary data in a hex dump or disassembly format, which can be unreasonably complex and difficult to deal with. The challenge lies in the fact that there is a significant gap between the raw binary data and the high-level analysis tools available, leaving reverse engineers to rely on their intuition and experience to bridge this gap.
The goal of dynamic binary visualization is to bridge this gap by providing a visual representation of binary data that is both accurate and intuitive. This approach leverages the power of the human visual cortex, which is highly adept at processing spatial and 3D information, to analyze binary data in a more efficient and effective manner. By transforming the difficult task of understanding binary data into a problem that the human brain is well-equipped to handle, dynamic binary visualization has the potential to make reverse engineering more accessible and efficient.
In his talk [1], Chris Domas also highlights the limitations of current reverse engineering tools, which are heavily dependent on known structures and are unable to keep up with the rapidly evolving information landscape. The need for a better way to analyze binary data that is independent of structure is therefore crucial, and dynamic binary visualization presents a promising solution to this challenge.
In the following sections, we will discuss the methods used to generate binary visualizations, the creation of a dataset with these images and the potential applications of this dataset in various fields, including data recovery, malware understanding, and document clustering.
Generate visualizations
The generation of visualizations in the Binary Visualization Dataset project involves transforming raw binary data into images using a simple Rust script. This script, which can be found in the project’s repository [2], takes binary data as input and outputs an image of 256 x 256 pixels representing the binary data.
The script works by looping through the entire binary file and taking pairs of bytes using a sliding window approach. These byte pairs are then treated as coordinates on a plane, with the first byte representing the x-coordinate and the second byte representing the y-coordinate. This results in a 256x256 image due to the inherent property of a byte, which has a value in the range of 0 to 255.
It’s important to note that the technique used in this script is a naive one, which means it does not take into account the locality of bytes or search for specific patterns. In future work, more sophisticated mathematical tools could be employed to preserve locality and detect compressed or encrypted zones within the binary data.
To better understand the script’s functionality, let’s visualize it in a simple way:
One limitation of the script is its inability to handle large binary files effectively, such as the executables of complex applications or high-resolution images. While this is not a significant issue for images since the entire binary represents an image, it is not practical to take all the data from a large executable binary and condense it into a small 256x256 image.
To address this limitation and improve the understanding of larger files, the script employs a chunking approach. The script divides the binary file into smaller chunks, allowing for more precise exploration and the ability to identify patterns within larger binary files. This chunk size can be parameterized, providing flexibility in the exploration process. By analyzing smaller sections of the binary file, it becomes easier to identify patterns and gain insights into the structure of the data.
Space filling curves
In his exploration of binary file visualization, Aldo Cortesi experimented with a more advanced approach using space-filling curves [3]. This technique is particularly interesting because it allows for the preservation of locality, meaning that elements that are close together in one dimension are kept as close as possible to each other in two dimensions.
The basic idea behind this approach is to sample the file at regular intervals, translate each sampled byte to a color, and write the corresponding pixel to an image. The challenge lies in determining the best way to arrange the pixels in the image. Cortesi explored three different methods for arranging the pixels: a zig-zag pattern, a Z-order curve, and a Hilbert curve.
Of the three methods, Cortesi found that the Hilbert curve produced the best results in terms of locality preservation. However, this method is also the most complex to generate. The Z-order curve, while not as effective at preserving locality, is easier and quicker to compute. The zig-zag pattern, on the other hand, tends to lose small-scale features and is therefore less satisfying.
Get Random-long-int’s stories in your inbox
Join Medium for free to get updates from this writer.
Unfortunately, due to time constraints, I was unable to incorporate this approach into my research. However, I believe that it is a promising avenue for future exploration. By using space-filling curves, it is possible to create visualizations that reveal the overall structure of a binary file at a glance, making it easier to identify patterns and anomalies. For example, Cortesi’s implementation of this approach uses a Hilbert curve to create a visualization of the ksh binary distributed with OSX, revealing distinct regions of code and data [4].
In conclusion, while I was unable to incorporate space-filling curves into my research, I believe that it is a valuable technique for binary file visualization. Cortesi’s work on this topic is particularly noteworthy, as his articles [3] and [4] provide a clear and accessible introduction to the subject. I highly recommend them to anyone interested in learning more about the global behavior of binary data and the potential applications of space-filling curves for visualization. Future researchers may find it fruitful to explore this approach further and build upon Cortesi’s work.
Dataset Creation
The Binary Visualization Dataset was created by collecting a diverse range of binary files, preprocessing them, visualizing them, annotating them, and validating the data. The dataset contains various types of binary files, including images (jpg, png, bitmap) and audio files (wav).
To collect the binary files, I used Kaggle databases and also gathered executables from a personal laptop running on ARM architecture. The dataset includes both ARM and x86_64 executables. During the collection process, I verified if all the binary files had metadata or any other additional information and cleaned it to ensure that only the raw binary data was used for visualization. I also selected different types of images and audio files to ensure the diversity of the dataset.
The preprocessing step involved cleaning and formatting the binary files to ensure they were suitable for visualization. This step included removing any metadata or other unnecessary information from the binary files. The visualization was performed using the Rust script [2] described in the previous section. The script takes binary data as input and outputs an image of 256 x 256 pixels representing the binary data. The script does not employs a chunking approach to handle larger binary files, it is something I am working on for the next version (or the upgraded version of the dataset).
To make the visualization process faster and more efficient, I modified the script to loop over directories and process multiple binary files at once. I also used a simple labeling process, where each visualization was labeled based on the folder it was in, indicating its category.
Here’s an example of the folder structure for the Binary Visualization Dataset:
binary_visualization_dataset/
├── audio/
│ ├── wav/
│ │ ├── audio_file_1.wav.bvtool.png
│ │ └── ...
│ └── ...
├── executables/
│ ├── ARM/
│ │ ├── executable_file_1.bin.bvtool.png
│ │ ├── executable_file_2.bin.bvtool.png
│ │ └── ...
│ └── x86_64/
│ └── ...
├── images/
│ └── bitmap/
│ └── ...
└── ...To ensured that the original names of the binary files were preserved in the visualizations, I added the suffix “.bvtool.png” to the original file name. This helps in retrieving the original binary used for the visualization and also helps in crediting the original dataset.
The validation step involved verifying the accuracy of the visualizations and ensuring that they were representative of the original binary data. The resulting dataset contains a diverse range of visualizations that can be used for various applications, such as data recovery, malware understanding, document clustering, and traffic analysis. The dataset is publicly available and can be accessed through the project’s repository [2].
The preliminary results of the Binary Visualization Dataset have shown promising outcomes, but there are still challenges to be addressed, such as the complexity in interpreting visualizations of large binary files. Although I have not yet developed a satisfactory machine learning model for this purpose, I am currently working on it. The future work includes improving and validating the dataset with more executable, exploring its potential applications, and developing an effective machine learning model. I welcome contributions from other researchers to help build upon this work and advance the field of binary visualization.
Conclusion
Through the process of creating the Binary Visualization Dataset, I have gained a deeper appreciation for the power of data visualization in simplifying complex tasks. By transforming raw binary data into visual images, we can leverage the human brain’s natural ability to recognize patterns and make data analysis more intuitive and accessible.
However, I have also encountered challenges in interpreting visualizations of large binary files. While the current script employs a chunking approach to improve understanding, there is still work to be done in developing more sophisticated mathematical tools to preserve locality and detect compressed or encrypted zones within the binary data.
In exploring the field of dynamic binary visualization, I have discovered a fascinating new domain that combines reverse engineering and data visualization. The tools and techniques used in this field are incredibly ingenious, and I am excited to continue learning and contributing to this area.
One of the most rewarding aspects of this project has been the potential applications of the dataset. From data recovery to malware understanding, document clustering, and traffic analysis, the possibilities are vast and varied. I am eager to continue exploring these applications and developing effective machine learning models to improve the accuracy and efficiency of binary data analysis.
Overall, I am grateful for the opportunity to contribute to this field and look forward to seeing how it continues to evolve in the future.
I also want to extend my special thanks to Sylvie Ratté for the super interesting course at the ETS Montréal on NLP and the help for this article and other stuff related.
References
[1] C. Domas, “The Future of RE,” REcon 2013, Jun. 2013. [Online Video]. Available: https://youtu.be/C8--cXwuuFQ?si=_c6jxkFlbyfeNE3r.
[2] P.L. Létoquart, Rust script for dynamic binary visualization, Apr 2024. [Github Repository]. Available: https://github.com/PierreLouisLetoquart/bvtool
[3] A. Cortesi, “Visualizing binaries with space-filling curves” Dec 2011. [Online]. Available: https://corte.si/posts/visualisation/binvis/
[4] A. Cortesi, “Visualizing entropy in binary files” May 2016. [Online]. Available: https://corte.si/posts/visualisation/entropy/.
[5] KyoungSoo Han, BooJoong Kang, Eul Gyu Im, “Malware Analysis Using Visualized Image Matrices”, The Scientific World Journal, vol. 2014, Article ID 132713, 15 pages, 2014. https://doi.org/10.1155/2014/132713
[6] Naeem, H. Detection of Malicious Activities in Internet of Things Environment Based on Binary Visualization and Machine Intelligence. Wireless Pers Commun 108, 2609–2629 (2019). https://doi.org/10.1007/s11277-019-06540-6
[7] L. Nataraj, S. Karthikeyan, G. Jacob, and B. S. Manjunath. 2011. Malware images: visualization and automatic classification. In Proceedings of the 8th International Symposium on Visualization for Cyber Security (VizSec ‘11). Association for Computing Machinery, New York, NY, USA, Article 4, 1–7. https://doi.org/10.1145/2016904.2016908








