• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2#
3# Script to downloads test data and build the corpus
4#
5# Copyright 2021 Google Inc.
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11#      http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19################################################################################
20
21# Test data provided by:
22#
23# The Fuzzing Project: https://fuzzing-project.org/resources.html
24#   As CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
25#   https://creativecommons.org/publicdomain/zero/1.0/
26#
27# The dfVFS project: https://github.com/log2timeline/dfvfs
28#   As Apache 2 https://github.com/log2timeline/dfvfs/blob/main/LICENSE
29
30# Files to use for fls fuzz targets
31declare -A FLS_TEST_FILES=(
32  ["apfs"]="https://github.com/log2timeline/dfvfs/blob/main/test_data/apfs.raw?raw=true"
33  ["ext"]="https://files.fuzzing-project.org/filesystems/ext2.img"
34  ["fat"]="https://files.fuzzing-project.org/filesystems/exfat.img https://files.fuzzing-project.org/filesystems/fat12.img https://files.fuzzing-project.org/filesystems/fat16.img https://files.fuzzing-project.org/filesystems/fat32.img"
35  ["hfs"]="https://files.fuzzing-project.org/filesystems/hfsplus.img"
36  ["iso9660"]="https://files.fuzzing-project.org/discimages/iso9660.iso"
37  ["ntfs"]="https://files.fuzzing-project.org/filesystems/ntfs.img"
38)
39
40# Files to use for mmls fuzz targets
41declare -A MMLS_TEST_FILES=(
42  ["dos"]="https://files.fuzzing-project.org/discimages/partition-dos"
43  ["gpt"]="https://files.fuzzing-project.org/discimages/partition-gpt"
44  ["mac"]="https://files.fuzzing-project.org/discimages/partition-mac"
45)
46
47
48for type in ${!FLS_TEST_FILES[@]}; do
49  fuzz_target="sleuthkit_fls_${type}_fuzzer"
50
51  mkdir -p "test_data/${fuzz_target}"
52
53  IFS=" "; for url in ${FLS_TEST_FILES[$type]}; do
54    filename=$( echo ${url} | sed 's/?[^?]*$//' )
55    filename=$( basename ${filename} )
56
57    curl -L -o "test_data/${fuzz_target}/${filename}" "${url}"
58  done
59
60  (cd "test_data/${fuzz_target}" && zip ${OUT}/${fuzz_target}_seed_corpus.zip *)
61done
62
63
64for type in ${!MMLS_TEST_FILES[@]}; do
65  fuzz_target="sleuthkit_mmls_${type}_fuzzer"
66
67  mkdir -p "test_data/${fuzz_target}"
68
69  IFS=" "; for url in ${MMLS_TEST_FILES[$type]}; do
70    filename=$( echo ${url} | sed 's/?[^?]*$//' )
71    filename=$( basename ${filename} )
72
73    curl -L -o "test_data/${fuzz_target}/${filename}" "${url}"
74  done
75
76  (cd "test_data/${fuzz_target}" && zip ${OUT}/${fuzz_target}_seed_corpus.zip *)
77done
78