DLL Hijacking and How It Is Done?


Windows application comprises various folders and files. These files include executables, DLL and various other formats. A DLL is loaded dynamically and the code of the DLL is only executed by an executable. Many applications nowadays do not verify the integrity and the authenticity of the DLL due to which it becomes quite common for attackers to replace the existing DLL with a DLL crafted with malicious code. This vulnerability is known as DLL hijacking.

The vulnerability arises from the fact that unlike executable files, a malicious DLL is generally not detected by antivirus applications.

Here is the scenario to replicate this issue in a vulnerable application.

First, we need a malicious DLL. Just for demonstration, we are simply using a malicious DLL that shows a popup when the application is vulnerable.

In our case, we are using a vulnerable application named Mezzmo version 5.0.5.0 which is vulnerable to DLL hijacking. We need to identify the vulnerable DLL. One simple way to do that is to try every DLL in the application folder one by one. We tried replacing the file “avcodec-57.dll” with our malicious DLL with the same name

As an attacker, we can do this by creating an executable using WinRAR that extracts the file into the mezzmo directory and replaces the old one. We can create a silent one as shown in the screenshot below.

When the mezzmo.exe is executed the DLL also executes as shown in the below screenshot.

Even after showing us the error the program executes just fine.

In order to actually exploit this issue one can construct a DLL using a Metasploit that will provide us a reverse shell.

Manpreet Singh

This post was last modified on June 15, 2023 11:50

Share
Manpreet Singh
Published by
Manpreet Singh

Recent Posts

Managed WAF: A Must-Have to Stop Website Attacks

A Managed WAF is a comprehensive cybersecurity service offered by specialized providers to oversee, optimize,… Read More

2 days ago

Top 10 Best Practices for Attack Surface Reduction

Explore crucial tactics like Asset Inventory, Patch Management, Access Control & Authentication, and additional best… Read More

1 week ago

10 Important Data Privacy Questions You Should be Asking Now

Delve into the data privacy questions including consent protocols, data minimization strategies, user rights management,… Read More

2 weeks ago