lnk

The lnk module parses Windows Link files (.lnk), and exposes metadata contained in those files to YARA.


Module structure

FieldTypeDescription
is_lnkboolTrue if the file is a LNK file.
namestringA description of the shortcut that is displayed to end users to identify the purpose of the link.
creation_timeintegerTime when the LNK file was created.
access_timeintegerTime when the LNK file was last accessed.
write_timeintegerTime when the LNK files was last modified.
file_sizeintegerSize of the target file in bytes. The target file is the file that this link references to. If the link target file is larger than 0xFFFFFFFF, this value specifies the least significant 32 bits of the link target file size.
file_attributesintegerAttributes of the link target file.
icon_locationstringLocation where the icon associated to the link is found. This is usually an EXE or DLL file that contains the icon among its resources. The specific icon to be used is indicated by the icon_index field.
icon_indexintegerIndex of the icon that is associated to the link, within an icon location.
show_commandShowCommandExpected window state of an application launched by this link.
drive_typeDriveTypeType of drive the link is stored on.
drive_serial_numberintegerDrive serial number of the volume the link target is stored on.
volume_labelstringVolume label of the drive the link target is stored on.
local_base_pathstringString used to construct the full path to the link target by appending the common_path_suffix field.
common_path_suffixstringString used to construct the full path to the link target by being appended to the local_base_path field.
relative_pathstringLocation of the link target relative to the LNK file.
working_dirstringPath of the working directory to be used when activating the link target.
cmd_line_argsstringCommand-line arguments that are specified when activating the link target.
overlay_sizeintegerSize in bytes of any extra data appended to the LNK file.
overlay_offsetintegerOffset within the LNK file where the overlay starts.
tracker_dataTrackerDataDistributed link tracker information.

TrackerData

These are the fields in the tracker_data structure, which contains data that can be used to resolve a link target if it is not found in its original location when the link is resolved. This data is passed to the Link Tracking service [MS-DLTW] to find the link target.

FieldType
versioninteger
machine_idstring
droid_volume_idstring
droid_file_idstring
droid_birth_volume_idstring
droid_birth_file_idstring

Example

import "lnk"

rule lnk_cdrom {
    condition:
        lnk.tracker_data.machine_id == "chris-xps"
}

DriveType

These are the possible values for the drive_type field.

NameValue
DriveType.UNKNOWN0
DriveType.NO_ROOT_DIR1
DriveType.REMOVABLE2
DriveType.FIXED3
DriveType.REMOTE4
DriveType.CDROM5
DriveType.RAMDISK6

Example

import "lnk"

rule lnk_cdrom {
    condition:
        lnk.drive_type == lnk.DriveType.CDROM 
}

FileAttributes

NameValue
FILE_ATTRIBUTE_READONLY0x0001
FILE_ATTRIBUTE_HIDDEN0x0002
FILE_ATTRIBUTE_SYSTEM0x0004
FILE_ATTRIBUTE_DIRECTORY0x0010
FILE_ATTRIBUTE_ARCHIVE0x0020
FILE_ATTRIBUTE_NORMAL0x0080
FILE_ATTRIBUTE_TEMPORARY0x0100
FILE_ATTRIBUTE_SPARSE_FILE0x0200
FILE_ATTRIBUTE_REPARSE_POINT0x0400
FILE_ATTRIBUTE_COMPRESSED0x0800
FILE_ATTRIBUTE_OFFLINE0x1000
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED0x2000
FILE_ATTRIBUTE_ENCRYPTED0x4000

ShowCommand

These are the possible values for the show_command field.

NameValue
ShowCommand.NORMAL1
ShowCommand.MAXIMIZED3
ShowCommand.MIN_NO_ACTIVE7

Example

import "lnk"

rule lnk_maximized {
    condition:
        lnk.show_command == lnk.ShowCommand.MAXIMIZED
}