「2023.007|EN」Issues Series: Blurry Screen in Kali When Connecting By Win-KeX In WSL

Issue Description

  • The WSL (Windows Subsystem for Linux) includes the official Kali WSL distribution and supports connecting to Kali's GUI interface using Win-KeX.
  • There are three modes for connecting to Kali's GUI interface using Win-KeX:
    • Enhanced Mode
    • Seamless Mode
    • Windows Mode: Default mode
  • After experimenting, I find that the default mode, Windows Mode, provides the best experience.
  • However, when connecting to Kali's GUI interface through Windows Mode, the display is very blurry. This blurriness is especially pronounced when using certain tools such as BurpSuite, making the interface text difficult to read. Attempts to adjust the resolution within Kali have proven ineffective.

Relevant Information

Others online have encountered and raised the same issue:

  • Win-Kex Screen Resolution: Identifies the problem's cause and provides some solutions.
  • Win-KEX Resolution: A user's query on the official Kali forum, as of the time of writing this article, remains unanswered.

Issue Analysis

  1. Win-Kex Screen Resolution > Answer #1 suggests that changing the Settings > Display > Scale & layout > Scale to 100% can resolve the issue. While this indeed makes Kali's GUI clearer, it also alters the scale of the host system, which could have negative effects for some users. For instance, if a user is employing a high-resolution monitor (such as 2K or higher), windows and text will appear very small and hard to discern.
  2. Win-Kex Screen Resolution > Answer #2 provides a potential solution approach. The author states that GUI rendering is achieved through the win-kex-win-x64 executable file within the Windows host system. Therefore, modifying the High DPI Settings of this executable could potentially resolve the issue. However, the author later finds that he couldn't locate the win-kex-win-x64 executable in the Windows host system; it only exists within the Kali WSL distribution at \\wsl.localhost\kali-linux\usr\lib\win-kex\TigerVNC.

Both Answer #1 and Answer #2 don't offer definitive solutions, but they provide valuable insights that lead us towards ultimately resolving the problem.

Issue Solution

Let's continue to explore the approach mentioned in Answer #2, which involves "locating and modifying the Windows host system's executable program related to rendering the Kali WSL GUI, and modifying its DPI settings." Alternatively, we can "locate and modify the executable program responsible for starting the Kali WSL distribution and adjust its DPI settings." We succeeded through the latter approach.

According to the WSL documentation, we can start the Kali WSL distribution in the Windows host system's CMD / PowerShell by executing kali, which is the abbreviated form of kali.exe in CMD / PowerShell. In reality, kali.exe corresponds to an executable file located in one of the paths within the system environment variable Path, as shown below:

Let's find the path to kali.exe using the command Get-Command -ShowCommandInfo kali:

Next, open the folder containing kali.exe using Windows Explorer, and then:

  1. Right-click on kali.exe and select Properties from the context menu.
  2. Go to the Compatibility tab and click on Change high DPI settings.
  3. In the resulting sub-window, select Use this setting to fix scaling problems for this program instead of the one in settings.

As shown below:

Observant readers might notice that the file size of kali.exe in the image above is shown as O bytes. This is not an issue affecting the feasibility of this solution method.

Now within the Kali WSL distribution, execute kex --wtstart to initiate kex Windows Mode. This will provide a clear Kali GUI with the ability to freely adjust the window size of the Kali GUI (it starts in full-screen mode by default, and you can exit full-screen mode using the menu accessed by pressing F8). The display resolution will also adapt to changes in window size (unlike the other two kex modes).