Last active
August 2, 2019 16:57
-
-
Save jweyrich/286c55ec8f4ed932420738edddf7a99c to your computer and use it in GitHub Desktop.
Simple script to run a pev binary on multiple samples and generate a single output file which is validated by a linter at the end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SAMPLES_DIRECTORY="../pev/samples/" | |
OUTPUT_FILE="result.json" | |
PEV_TOOL_COMMAND="./src/build/readpe -f json" | |
# npm install jsonlint -g | |
LINTER_COMMAND="jsonlint" | |
counter=0 | |
echo "{" > $OUTPUT_FILE | |
find "$SAMPLES_DIRECTORY" -name "*.dll" -or -name "*.exe" -type f -print | while read -r line; | |
do | |
if [ "${counter}" -ne "0" ]; then | |
echo "," >> $OUTPUT_FILE | |
fi | |
counter=$((counter +1)) | |
echo "File: \"$line\"" # Print to stdout/console which file is being analysed | |
echo "\"$line\":" >> $OUTPUT_FILE | |
$PEV_TOOL_COMMAND "$line" >> $OUTPUT_FILE | |
EXIT_CODE=$? | |
if [ $EXIT_CODE -ne 0 ]; | |
then | |
echo "{ \"error\": \"exit status $EXIT_CODE\" }" >> $OUTPUT_FILE | |
fi | |
done | |
echo "}" >> $OUTPUT_FILE | |
$LINTER_COMMAND $OUTPUT_FILE > /dev/null && echo "VALID JSON" || echo "INVALID JSON" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment