Skip to content

Commit

Permalink
Add scripts to generate a dictionary and seed corpus for the config f…
Browse files Browse the repository at this point in the history
…uzzing
  • Loading branch information
tomrittervg committed Oct 21, 2019
1 parent df86635 commit 3807675
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
27 changes: 27 additions & 0 deletions osquery/main/harnesses/gen_fuzz_config_dict.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# If this is not commented out, we get 'sed' commands in our output below
#set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

function usage() {
echo "${BASH_SOURCE[0]} destination-file"
}

function main() {
if [[ $# < 1 ]]; then
usage
exit 1
fi

# dict format is keyword="value" or just "value" - so we need to make sure our output is quoted.

egrep -h -R -o "HasMember\\(\"([^\"]+)\"\\)" * | sed 's/HasMember(//' | sed 's/)//' > tmp
egrep -h -o -e "\"([^\"]+)\"" $SCRIPT_DIR/../../../tools/tests/*.conf >> tmp

sort tmp | uniq > $1
rm tmp
}

main $@
20 changes: 20 additions & 0 deletions osquery/main/harnesses/gen_fuzz_config_seed_corpus.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

function usage() {
echo "${BASH_SOURCE[0]} destination-file"
}

function main() {
if [[ $# < 1 ]]; then
usage
exit 1
fi

zip -j $1 $SCRIPT_DIR/../../../tools/tests/*.conf
}

main $@

0 comments on commit 3807675

Please sign in to comment.