MalDev Study
Advanced Module 1advanced6 code files

Binary Metadata Modification

Binaries can include metadata that provides information about the file such as a file description, version number, company name and more. The image below shows the metadata of G...

Jump to Section (15)

Introduction

Binaries can include metadata that provides information about the file such as a file description, version number, company name and more. The image below shows the metadata of Google's chrome.exe binary.

Binary Metadata Modification figure

Although including metadata information may not directly decrease the likelihood of detection, it can contribute to making the binary appear less suspicious. Security teams are cautious about users executing binaries, especially ones downloaded from untrusted sources on the internet. Therefore, embedding metadata in the binary can help reduce its suspicious appearance, potentially making it less prone to being analyzed by the security team.

The goal is to essentially make the malicious binary appear as ordinary as possible. This module will demonstrate how to include this metadata information in a compiled binary.

Modifying Metadata

The steps below will show how to modify a binary's metadata.

Step 1 - Create a Solution

Open up Visual Studio and create a new solution.

Binary Metadata Modification figure

Step 2 - Add a New Item

Right-click the project, select 'Add' > 'New Item'

Binary Metadata Modification figure

Step 3 - Add a Resource (.rc) File

Add a new resource file to the project. Renaming the file is not necessary, but for this module, it will be renamed to metadata.rc.

Binary Metadata Modification figure

Step 4 - Exit Resource Viewer

When the file is added, Visual Studio will automatically open the file up in the resource viewer. This is not required and therefore exit the resource reviewer by clicking the X.

Binary Metadata Modification figure

Step 5 - Edit Resource File

After exiting the resource viewer, right-click the resource file and select 'Open With' > 'Source Code Text) Editor'.

Binary Metadata Modification figure
Binary Metadata Modification figure

Step 6 - Insert Metadata

Scroll down to the bottom of the file and insert the following contents.

POWERSHELL
1 VERSIONINFO
 FILEVERSION 112,0,5615,88 // File version separated by commas
 PRODUCTVERSION 1,0,0,0
 FILEFLAGSMASK 0x0L
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x0L
 FILETYPE 0x0L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904B0"
        BEGIN 
            // Modify the values below
            VALUE "CompanyName", "Google LLC."
            VALUE "FileDescription", "Google Chrome"
            VALUE "InternalName", "Chrome"
            VALUE "LegalCopyright", "Copyright 2023 Google LLC."
            VALUE "OriginalFilename", "chrome.exe"
            VALUE "ProductName", "Google Chrome"
            VALUE "ProductVersion", "112.0.5615.86"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END
Binary Metadata Modification figure

Step 6 - Compile & View the Results

Finally, build the solution and view the properties of the newly compiled binary.

Binary Metadata Modification figure

Video Demo

Binary Metadata Modification figure

Binary Icon

It's also possible to give the binary an icon, which again is a step towards making the binary appear less suspicious. The steps to add an icon to a binary are shown below.

Step 1 - .ico File Placement

Download a .ico file that will serve as the icon for the executable. Next, place the file in the same location where the .sln file is located.

Binary Metadata Modification figure

Step 2 - Modify The Resource File

In the resource file, insert the following line.

CPP
// chrome.ico is the name of the icon from the previous step
IDI_ICON1 ICON "chrome.ico"
Binary Metadata Modification figure

Step 3 - Compile & View the Results

Finally, build the solution and the binary should now have an icon.

Binary Metadata Modification figure

Video Demo

Binary Metadata Modification figure
Diagram

Companion Project & Source Code

6 readable source/config files extracted directly from the archive

Download Module 1 - FileAttributesDemo.zip
0.1 KB
#include <stdio.h>

int main()
{
    printf("MalDev Academy Demo");
}
Full Archive Manifest (8 files inside .zip)
  • FileAttributesDemo/FileAttributesDemo.cpp
  • FileAttributesDemo/FileAttributesDemo.sln
  • FileAttributesDemo/FileAttributesDemo.vcxproj
  • FileAttributesDemo/chrome.ico
  • FileAttributesDemo/metadata.aps
  • FileAttributesDemo/metadata.rc
  • FileAttributesDemo/resource.h
  • FileAttributesDemo/resource1.h

Search all modules and companion code

No matching modules or source files found for “”.
    Covers all 91 Core + 38 Advanced modules + source archives

    Reader Settings & Progress

    Color Theme

    Reading Font Size

    Study Progress & Cross-Device Backup

    0/129
    Completed
    0
    Bookmarked
    0
    Module Notes

    Progress is saved locally in your browser. Export a JSON backup to move your progress between laptop and phone.