test_lnk.c (3646B)
1 /* 2 This file is part of libextractor. 3 Copyright (C) 2026 Vidyut Samanta and Christian Grothoff 4 5 libextractor is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published 7 by the Free Software Foundation; either version 3, or (at your 8 option) any later version. 9 10 libextractor is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with libextractor; see the file COPYING. If not, write to the 17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 /** 21 * @file plugins/test_lnk.c 22 * @brief testcase for the lnk plugin 23 * @author Christian Grothoff 24 * 25 * The input is generated by contrib/gen_lnk_testdata.sh, which owns 26 * every constant asserted here. 27 */ 28 #include "platform.h" 29 #include "test_lib.h" 30 31 32 /** 33 * Shorthand for a solution whose value is spelled out in full. 34 */ 35 #define TEXT(type, value) \ 36 { type, EXTRACTOR_METAFORMAT_UTF8, "text/plain", value, \ 37 strlen (value) + 1, 0, 0, NULL } 38 39 40 /** 41 * Main function for the shell link testcase. 42 * 43 * @param argc number of arguments (ignored) 44 * @param argv arguments (ignored) 45 * @return 0 on success 46 */ 47 int 48 main (int argc, char *argv[]) 49 { 50 struct SolutionData lnk_sol[] = { 51 TEXT (EXTRACTOR_METATYPE_MIMETYPE, 52 "application/x-ms-shortcut"), 53 /* the target's timestamps, taken from the shell link header */ 54 TEXT (EXTRACTOR_METATYPE_CREATION_DATE, 55 "2021-03-04T05:06:07Z"), 56 TEXT (EXTRACTOR_METATYPE_ACCESS_DATE, 57 "2022-07-08T09:10:11Z"), 58 TEXT (EXTRACTOR_METATYPE_MODIFICATION_DATE, 59 "2021-06-15T14:30:00Z"), 60 TEXT (EXTRACTOR_METATYPE_EMBEDDED_FILE_SIZE, 61 "123456"), 62 TEXT (EXTRACTOR_METATYPE_ATTRIBUTES, 63 "READONLY, ARCHIVE"), 64 /* the VolumeID inside the LinkInfo structure */ 65 TEXT (EXTRACTOR_METATYPE_VOLUME_SERIAL, 66 "1A2B-3C4D"), 67 TEXT (EXTRACTOR_METATYPE_FILESYSTEM_TYPE, 68 "fixed disk"), 69 TEXT (EXTRACTOR_METATYPE_VOLUME_NAME, 70 "EVIDENCE"), 71 /* LocalBasePathUnicode joined with CommonPathSuffixUnicode */ 72 TEXT (EXTRACTOR_METATYPE_TARGET_PATH, 73 "C:\\Users\\analyst\\Desktop\\evidence.txt"), 74 /* the UTF-16 string data section */ 75 TEXT (EXTRACTOR_METATYPE_DESCRIPTION, 76 "Evidence file from the lab machine"), 77 TEXT (EXTRACTOR_METATYPE_TARGET_PATH, 78 "..\\..\\Desktop\\evidence.txt"), 79 TEXT (EXTRACTOR_METATYPE_WORKING_DIRECTORY, 80 "C:\\Users\\analyst\\Desktop"), 81 TEXT (EXTRACTOR_METATYPE_COMMAND_LINE, 82 "/quiet /log C:\\temp\\out.log"), 83 TEXT (EXTRACTOR_METATYPE_URI, 84 "%SystemRoot%\\system32\\shell32.dll"), 85 /* the TrackerDataBlock: the machine that made the shortcut */ 86 TEXT (EXTRACTOR_METATYPE_SOURCE_HOST, 87 "lab-ws-07"), 88 TEXT (EXTRACTOR_METATYPE_SYSTEM_IDENTIFIER, 89 "9b3a5e1c-7d42-4f80-a1e6-0c2d4b6f8a31"), 90 TEXT (EXTRACTOR_METATYPE_SYSTEM_IDENTIFIER, 91 "5f3e2d1c-a4b6-11d2-8ae7-001b44113ab7"), 92 /* the node field of that version 1 UUID */ 93 TEXT (EXTRACTOR_METATYPE_MAC_ADDRESS, 94 "00:1b:44:11:3a:b7"), 95 { 0, 0, NULL, NULL, 0, -1, 0, NULL } 96 }; 97 struct ProblemSet ps[] = { 98 { "testdata/lnk_test.lnk", 99 lnk_sol }, 100 { NULL, NULL } 101 }; 102 103 return ET_main ("lnk", ps); 104 } 105 106 107 /* end of test_lnk.c */