
Analyzing Windows Lnk Files For Artifacts
- 186 installs
- 27.3k repo stars
- Updated August 2, 2026
- mukul975/anthropic-cybersecurity-skills
Analyzing Windows LNK Files for Artifacts is an agent skill that supports forensic examination of Windows shortcut files for security and incident-response artifact extraction.
About
Analyzing Windows LNK Files for Artifacts is a security-oriented agent skill aimed at defenders and builders who need structured help examining Windows shortcut files for execution paths, timestamps, and other forensic indicators. Solo operators running small SaaS or internal tools still encounter Windows clients, phishing lures, and compromised laptops; this skill slots into a ship-phase security mindset when you are validating whether a machine or artifact chain looks benign before you trust production access. The catalog ingest for this entry is thin on procedural steps in the excerpt Prism received, so treat it as a specialized forensics helper to pair with your own tooling and legal scope. Use when triaging suspected malicious shortcuts or documenting artifact fields for a report, not as a substitute for full disk imaging or certified IR playbooks.
- Focuses on Windows .lnk shortcut files as forensic evidence sources
- Fits incident response and malware triage workflows on Windows endpoints
- Part of a broader Anthropic cybersecurity skills collection
- Apache 2.0 licensed skill packaging in the ingested repo
Analyzing Windows Lnk Files For Artifacts by the numbers
- 186 all-time installs (skills.sh)
- +9 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #803 of 2,203 Security skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill analyzing-windows-lnk-files-for-artifactsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 186 |
|---|---|
| repo stars | ★ 27.3k |
| Security audit | 3 / 3 scanners passed |
| Last updated | August 2, 2026 |
| Repository | mukul975/anthropic-cybersecurity-skills ↗ |
What it does
Parse Windows shortcut (LNK) files to extract forensic artifacts during security or incident-response analysis.
Who is it for?
Best when you're doing Windows-focused security review, malware triage, or IR homework on shortcut artifacts.
Skip if: Pure application feature work with no Windows endpoint risk, or teams without authorization to perform forensic analysis.
When should I use this skill?
When examining Windows .lnk shortcut files for forensic or security artifacts as part of triage or review.
What you get
You get agent-guided structure for LNK-focused forensic analysis to support security triage or documentation.
- Structured artifact notes from LNK examination
- Inputs for a security or IR report
Files
Analyzing Windows LNK Files for Artifacts
When to Use
- When reconstructing user file access history from Windows shortcut files
- For tracking accessed files, network shares, and removable media
- During investigations to prove a user opened specific documents
- When correlating file access with other timeline artifacts
- For identifying accessed paths on remote systems or USB devices
Prerequisites
- Access to LNK files from forensic image (Recent, Desktop, Quick Launch)
- LECmd (Eric Zimmerman), python-lnk, or LnkParser for analysis
- Understanding of LNK file structure (Shell Link Binary format)
- Knowledge of LNK file locations on Windows systems
- Forensic workstation with analysis tools installed
Workflow
Step 1: Collect LNK Files from Forensic Image
# Mount forensic image
mount -o ro,loop,offset=$((2048*512)) /cases/case-2024-001/images/evidence.dd /mnt/evidence
mkdir -p /cases/case-2024-001/lnk/{recent,desktop,startup,custom}
# Copy Recent items LNK files (primary source)
cp /mnt/evidence/Users/*/AppData/Roaming/Microsoft/Windows/Recent/*.lnk \
/cases/case-2024-001/lnk/recent/ 2>/dev/null
# Copy automatic destinations (Jump Lists)
cp /mnt/evidence/Users/*/AppData/Roaming/Microsoft/Windows/Recent/AutomaticDestinations/*.automaticDestinations-ms \
/cases/case-2024-001/lnk/recent/ 2>/dev/null
# Copy custom destinations (pinned Jump List items)
cp /mnt/evidence/Users/*/AppData/Roaming/Microsoft/Windows/Recent/CustomDestinations/*.customDestinations-ms \
/cases/case-2024-001/lnk/custom/ 2>/dev/null
# Copy Desktop shortcuts
cp /mnt/evidence/Users/*/Desktop/*.lnk /cases/case-2024-001/lnk/desktop/ 2>/dev/null
# Copy Startup folder shortcuts (persistence)
cp /mnt/evidence/Users/*/AppData/Roaming/Microsoft/Windows/Start\ Menu/Programs/Startup/*.lnk \
/cases/case-2024-001/lnk/startup/ 2>/dev/null
cp "/mnt/evidence/ProgramData/Microsoft/Windows/Start Menu/Programs/Startup"/*.lnk \
/cases/case-2024-001/lnk/startup/ 2>/dev/null
# Find all LNK files on the system
find /mnt/evidence/ -name "*.lnk" -type f 2>/dev/null > /cases/case-2024-001/lnk/all_lnk_locations.txt
# Count and hash
ls /cases/case-2024-001/lnk/recent/ | wc -l
sha256sum /cases/case-2024-001/lnk/recent/*.lnk > /cases/case-2024-001/lnk/lnk_hashes.txt 2>/dev/nullStep 2: Parse LNK Files with LECmd
# Using Eric Zimmerman's LECmd (Windows or via Mono)
# Process all LNK files in a directory
LECmd.exe -d "C:\cases\lnk\recent\" --csv "C:\cases\analysis\" --csvf lnk_analysis.csv
# Process a single LNK file with verbose output
LECmd.exe -f "C:\cases\lnk\recent\document.pdf.lnk"
# Process Jump List files
JLECmd.exe -d "C:\cases\lnk\recent\" --csv "C:\cases\analysis\" --csvf jumplist_analysis.csv
# Output includes:
# - Source file path
# - Target path (file that was accessed)
# - Target creation, modification, access timestamps
# - LNK creation and modification timestamps
# - Working directory
# - Command line arguments
# - Volume serial number and label
# - Drive type (Fixed, Removable, Network)
# - Machine ID (NetBIOS name)
# - MAC address (from tracker database)
# - File size of targetStep 3: Parse LNK Files with Python
pip install LnkParse3
python3 << 'PYEOF'
import LnkParse3
import os, json, csv
from datetime import datetime
lnk_dir = '/cases/case-2024-001/lnk/recent/'
results = []
for filename in sorted(os.listdir(lnk_dir)):
if not filename.lower().endswith('.lnk'):
continue
filepath = os.path.join(lnk_dir, filename)
try:
with open(filepath, 'rb') as f:
lnk = LnkParse3.lnk_file(f)
info = lnk.get_json()
parsed = {
'lnk_file': filename,
'target_path': '',
'working_dir': '',
'arguments': '',
'target_created': '',
'target_modified': '',
'target_accessed': '',
'file_size': '',
'drive_type': '',
'volume_serial': '',
'volume_label': '',
'machine_id': '',
'mac_address': '',
}
# Extract header timestamps
header = info.get('header', {})
parsed['target_created'] = str(header.get('creation_time', ''))
parsed['target_modified'] = str(header.get('modified_time', ''))
parsed['target_accessed'] = str(header.get('accessed_time', ''))
parsed['file_size'] = str(header.get('file_size', ''))
# Extract link info
link_info = info.get('link_info', {})
if link_info:
local_path = link_info.get('local_base_path', '')
network_path = link_info.get('common_network_relative_link', {}).get('net_name', '')
parsed['target_path'] = local_path or network_path
vol_info = link_info.get('volume_id', {})
if vol_info:
parsed['drive_type'] = str(vol_info.get('drive_type', ''))
parsed['volume_serial'] = str(vol_info.get('drive_serial_number', ''))
parsed['volume_label'] = str(vol_info.get('volume_label', ''))
# Extract string data
string_data = info.get('string_data', {})
parsed['working_dir'] = str(string_data.get('working_dir', ''))
parsed['arguments'] = str(string_data.get('command_line_arguments', ''))
# Extract tracker data (machine ID and MAC)
extra = info.get('extra', {})
tracker = extra.get('DISTRIBUTED_LINK_TRACKER_BLOCK', {})
if tracker:
parsed['machine_id'] = str(tracker.get('machine_id', ''))
parsed['mac_address'] = str(tracker.get('mac_address', ''))
results.append(parsed)
# Print summary
print(f"\n{filename}")
print(f" Target: {parsed['target_path']}")
print(f" Modified: {parsed['target_modified']}")
print(f" Drive: {parsed['drive_type']} (Serial: {parsed['volume_serial']})")
if parsed['machine_id']:
print(f" Machine: {parsed['machine_id']}")
except Exception as e:
print(f" Error parsing {filename}: {e}")
# Write results to CSV
with open('/cases/case-2024-001/analysis/lnk_analysis.csv', 'w', newline='') as f:
writer = csv.DictWriter(f, fieldnames=results[0].keys() if results else [])
writer.writeheader()
writer.writerows(results)
print(f"\n\nTotal LNK files parsed: {len(results)}")
PYEOFStep 4: Analyze for Investigative Value
# Identify files accessed from removable media
python3 << 'PYEOF'
import csv
with open('/cases/case-2024-001/analysis/lnk_analysis.csv') as f:
reader = csv.DictReader(f)
print("=== FILES ACCESSED FROM REMOVABLE MEDIA ===\n")
removable = []
network = []
for row in reader:
if 'DRIVE_REMOVABLE' in row.get('drive_type', '').upper() or \
'removable' in row.get('drive_type', '').lower():
removable.append(row)
print(f" {row['target_modified']} | {row['target_path']} | Vol: {row['volume_serial']}")
if 'network' in row.get('drive_type', '').lower() or \
row.get('target_path', '').startswith('\\\\'):
network.append(row)
print(f"\n=== FILES ACCESSED FROM NETWORK SHARES ===\n")
for row in network:
print(f" {row['target_modified']} | {row['target_path']}")
print(f"\nRemovable media files: {len(removable)}")
print(f"Network share files: {len(network)}")
# Check for unique machines (tracker data)
machines = set()
for row in [*removable, *network]:
if row.get('machine_id'):
machines.add(row['machine_id'])
if machines:
print(f"\nMachine IDs found: {machines}")
PYEOF
# Check Startup folder LNK files for persistence
echo "=== STARTUP FOLDER SHORTCUTS (PERSISTENCE) ===" > /cases/case-2024-001/analysis/startup_persistence.txt
for lnk in /cases/case-2024-001/lnk/startup/*.lnk; do
python3 -c "
import LnkParse3
with open('$lnk', 'rb') as f:
lnk = LnkParse3.lnk_file(f)
info = lnk.get_json()
target = info.get('link_info', {}).get('local_base_path', 'Unknown')
args = info.get('string_data', {}).get('command_line_arguments', '')
print(f' $(basename $lnk): {target} {args}')
" >> /cases/case-2024-001/analysis/startup_persistence.txt 2>/dev/null
doneKey Concepts
| Concept | Description |
|---|---|
| Shell Link (.lnk) | Windows shortcut file format containing target path, timestamps, and metadata |
| Target timestamps | Creation, modification, and access times of the file the shortcut points to |
| Volume serial number | Unique identifier of the drive volume where the target file resides |
| Machine ID | NetBIOS name embedded by the Distributed Link Tracking service |
| MAC address | Network adapter MAC from the machine that created the LNK file |
| Jump Lists | Recent and pinned file lists per application (contain embedded LNK data) |
| Automatic Destinations | System-managed Jump List entries for recently opened files |
| Custom Destinations | User-pinned Jump List items that persist until manually removed |
Tools & Systems
| Tool | Purpose |
|---|---|
| LECmd | Eric Zimmerman command-line LNK file parser with CSV/JSON output |
| JLECmd | Eric Zimmerman Jump List parser |
| LnkParse3 | Python library for programmatic LNK file analysis |
| lnk_parser | Alternative Python LNK parsing tool |
| Autopsy | Forensic platform with LNK file analysis module |
| KAPE | Automated LNK and Jump List artifact collection |
| Plaso | Timeline tool with LNK file parser for super-timeline creation |
| LNK Explorer | GUI tool for interactive LNK file examination |
Common Scenarios
Scenario 1: Data Exfiltration via USB Drive Analyze Recent folder LNK files for targets on removable drives, correlate volume serial numbers with USBSTOR registry entries, build a list of files accessed from USB devices, establish which documents were opened from the removable drive, correlate with file copy timestamps.
Scenario 2: Malware Persistence via Startup Shortcuts Examine Startup folder LNK files for malicious targets, check target path and arguments for encoded commands or suspicious executables, verify target file exists and examine it, correlate creation timestamp with initial compromise time.
Scenario 3: Network Share Access Investigation Filter LNK files with network paths (UNC targets), identify which network shares were accessed and when, correlate machine IDs with known corporate systems, check if sensitive file servers were accessed outside of normal duties, build access timeline for compliance investigation.
Scenario 4: Document Access Timeline for Legal Proceedings Extract all Recent folder LNK files, build chronological list of documents accessed by the user, identify specific files relevant to the case, present target timestamps showing when files were opened, correlate with email and communication timelines.
Output Format
LNK File Analysis Summary:
User Profile: suspect_user
Total LNK Files: 234 (Recent: 198, Desktop: 23, Startup: 5, Other: 8)
File Access Statistics:
Local drive (C:): 156 files
Removable media: 23 files (3 unique volume serials)
Network shares: 15 files (\\server01, \\fileserver)
Other drives: 4 files
Machine IDs Found: DESKTOP-ABC123, LAPTOP-XYZ789
MAC Addresses: AA:BB:CC:DD:EE:FF, 11:22:33:44:55:66
Removable Media Access:
Volume Serial 1234-ABCD:
2024-01-15 14:32 - E:\Confidential\financial_report.xlsx
2024-01-15 14:45 - E:\Confidential\customer_database.csv
2024-01-15 15:00 - E:\Projects\source_code.zip
Startup Persistence:
updater.lnk -> C:\ProgramData\svc\updater.exe (SUSPICIOUS)
OneDrive.lnk -> C:\Users\...\OneDrive.exe (Legitimate)
Timeline: /cases/case-2024-001/analysis/lnk_analysis.csv
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to the Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by the Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding any notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. Please do not remove or change
the license header comment from a contributed file except when
necessary.
Copyright 2026 mukul975
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
API Reference: Analyzing Windows LNK Files for Artifacts
LnkParse3
Parse a Single LNK File
import LnkParse3
with open("shortcut.lnk", "rb") as f:
lnk = LnkParse3.lnk_file(f)
info = lnk.get_json()
# Access header timestamps
header = info["header"]
print(header["creation_time"], header["modified_time"], header["accessed_time"])
# Access target path
link_info = info.get("link_info", {})
print(link_info.get("local_base_path"))
# Access volume info
vol = link_info.get("volume_id", {})
print(vol.get("drive_type"), vol.get("drive_serial_number"))
# Access tracker data (machine ID, MAC)
extra = info.get("extra", {})
tracker = extra.get("DISTRIBUTED_LINK_TRACKER_BLOCK", {})
print(tracker.get("machine_id"), tracker.get("mac_address"))LNK JSON Structure
{
"header": {
"creation_time": "2024-01-15 14:32:00",
"modified_time": "2024-01-15 14:32:00",
"accessed_time": "2024-01-15 14:32:00",
"file_size": 45056
},
"link_info": {
"local_base_path": "E:\\Documents\\report.xlsx",
"volume_id": {
"drive_type": "DRIVE_REMOVABLE",
"drive_serial_number": "1234-ABCD",
"volume_label": "KINGSTON"
}
},
"string_data": {
"working_dir": "E:\\Documents",
"command_line_arguments": ""
},
"extra": {
"DISTRIBUTED_LINK_TRACKER_BLOCK": {
"machine_id": "DESKTOP-ABC123",
"mac_address": "AA:BB:CC:DD:EE:FF"
}
}
}Key LNK File Locations
| Location | Description |
|---|---|
%APPDATA%\Microsoft\Windows\Recent\ | Recently accessed files |
%APPDATA%\...\Recent\AutomaticDestinations\ | Jump Lists |
%APPDATA%\...\Recent\CustomDestinations\ | Pinned Jump List items |
%USERPROFILE%\Desktop\ | Desktop shortcuts |
%APPDATA%\...\Startup\ | User startup (persistence) |
%PROGRAMDATA%\...\Startup\ | System startup (persistence) |
Drive Types
| Value | Meaning |
|---|---|
| DRIVE_REMOVABLE | USB, SD card |
| DRIVE_FIXED | Internal HDD/SSD |
| DRIVE_REMOTE | Network share |
| DRIVE_CDROM | Optical media |
References
- LnkParse3: https://pypi.org/project/LnkParse3/
- Shell Link Binary Format: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-shllink/
- LECmd: https://github.com/EricZimmerman/LECmd
#!/usr/bin/env python3
"""Agent for analyzing Windows LNK shortcut files for forensic artifacts."""
import os
import json
import csv
import argparse
from datetime import datetime
import LnkParse3
def parse_lnk_file(filepath):
"""Parse a single LNK file and extract forensic artifacts."""
with open(filepath, "rb") as f:
lnk = LnkParse3.lnk_file(f)
info = lnk.get_json()
parsed = {
"lnk_file": os.path.basename(filepath),
"target_path": "",
"working_dir": "",
"arguments": "",
"target_created": "",
"target_modified": "",
"target_accessed": "",
"file_size": "",
"drive_type": "",
"volume_serial": "",
"volume_label": "",
"machine_id": "",
"mac_address": "",
}
header = info.get("header", {})
parsed["target_created"] = str(header.get("creation_time", ""))
parsed["target_modified"] = str(header.get("modified_time", ""))
parsed["target_accessed"] = str(header.get("accessed_time", ""))
parsed["file_size"] = str(header.get("file_size", ""))
link_info = info.get("link_info", {})
if link_info:
local_path = link_info.get("local_base_path", "")
net_link = link_info.get("common_network_relative_link", {})
network_path = net_link.get("net_name", "") if net_link else ""
parsed["target_path"] = local_path or network_path
vol_info = link_info.get("volume_id", {})
if vol_info:
parsed["drive_type"] = str(vol_info.get("drive_type", ""))
parsed["volume_serial"] = str(vol_info.get("drive_serial_number", ""))
parsed["volume_label"] = str(vol_info.get("volume_label", ""))
string_data = info.get("string_data", {})
parsed["working_dir"] = str(string_data.get("working_dir", ""))
parsed["arguments"] = str(string_data.get("command_line_arguments", ""))
extra = info.get("extra", {})
tracker = extra.get("DISTRIBUTED_LINK_TRACKER_BLOCK", {})
if tracker:
parsed["machine_id"] = str(tracker.get("machine_id", ""))
parsed["mac_address"] = str(tracker.get("mac_address", ""))
return parsed
def parse_lnk_directory(directory):
"""Parse all LNK files in a directory."""
results = []
for filename in sorted(os.listdir(directory)):
if not filename.lower().endswith(".lnk"):
continue
filepath = os.path.join(directory, filename)
try:
parsed = parse_lnk_file(filepath)
results.append(parsed)
except Exception as e:
print(f" Error parsing {filename}: {e}")
return results
def filter_removable_media(results):
"""Filter LNK files that point to removable media."""
return [r for r in results if "removable" in r.get("drive_type", "").lower()]
def filter_network_shares(results):
"""Filter LNK files pointing to network shares."""
return [
r for r in results
if "network" in r.get("drive_type", "").lower()
or r.get("target_path", "").startswith("\\\\")
]
def detect_suspicious_startup(startup_dir):
"""Analyze Startup folder LNK files for potential persistence."""
suspicious = []
for filename in os.listdir(startup_dir):
if not filename.lower().endswith(".lnk"):
continue
filepath = os.path.join(startup_dir, filename)
try:
parsed = parse_lnk_file(filepath)
target = parsed["target_path"].lower()
args = parsed["arguments"].lower()
if any(s in target for s in ["temp", "appdata", "programdata", "public"]):
parsed["risk"] = "HIGH"
suspicious.append(parsed)
elif any(s in args for s in ["-enc", "powershell", "cmd /c", "wscript"]):
parsed["risk"] = "HIGH"
suspicious.append(parsed)
except Exception:
pass
return suspicious
def export_csv(results, output_path):
"""Export parsed LNK results to CSV."""
if not results:
return
with open(output_path, "w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=results[0].keys())
writer.writeheader()
writer.writerows(results)
def extract_unique_machines(results):
"""Extract unique machine IDs and MAC addresses from LNK files."""
machines = {}
for r in results:
mid = r.get("machine_id", "")
mac = r.get("mac_address", "")
if mid:
machines[mid] = mac
return machines
def main():
parser = argparse.ArgumentParser(description="Windows LNK File Forensic Analysis Agent")
parser.add_argument("--lnk-dir", required=True, help="Directory containing LNK files")
parser.add_argument("--startup-dir", help="Startup folder to check for persistence")
parser.add_argument("--output-dir", default="./lnk_analysis")
parser.add_argument("--action", choices=[
"parse_all", "removable", "network", "startup", "machines", "full_analysis"
], default="full_analysis")
args = parser.parse_args()
os.makedirs(args.output_dir, exist_ok=True)
all_results = parse_lnk_directory(args.lnk_dir)
print(f"[+] Parsed {len(all_results)} LNK files")
if args.action in ("parse_all", "full_analysis"):
csv_path = os.path.join(args.output_dir, "lnk_analysis.csv")
export_csv(all_results, csv_path)
print(f"[+] Exported to {csv_path}")
if args.action in ("removable", "full_analysis"):
removable = filter_removable_media(all_results)
print(f"[+] Removable media files: {len(removable)}")
for r in removable:
print(f" {r['target_modified']} | {r['target_path']} | Vol: {r['volume_serial']}")
if args.action in ("network", "full_analysis"):
network = filter_network_shares(all_results)
print(f"[+] Network share files: {len(network)}")
if args.action in ("startup", "full_analysis") and args.startup_dir:
suspicious = detect_suspicious_startup(args.startup_dir)
print(f"[+] Suspicious startup LNK: {len(suspicious)}")
for s in suspicious:
print(f" [{s.get('risk')}] {s['lnk_file']} -> {s['target_path']}")
if args.action in ("machines", "full_analysis"):
machines = extract_unique_machines(all_results)
print(f"[+] Unique machines: {len(machines)}")
for mid, mac in machines.items():
print(f" Machine: {mid} | MAC: {mac}")
print(json.dumps({"total_lnk": len(all_results), "generated_at": datetime.utcnow().isoformat()}, indent=2))
if __name__ == "__main__":
main()
Related skills
How it compares
Specialized Windows forensics skill—not a generic dependency audit or cloud posture scanner.
FAQ
Who is analyzing-windows-lnk-files-for-artifacts for?
Developers and operators with a security or incident-response need to interpret Windows LNK shortcut artifacts.
When should I use analyzing-windows-lnk-files-for-artifacts?
During ship security reviews or operate incident loops when a Windows shortcut is part of the evidence chain.
Is analyzing-windows-lnk-files-for-artifacts safe to install?
Check the Security Audits panel on this Prism page and only run forensics on systems and data you are permitted to analyze.