diff --git a/tools/cover.sh b/tools/cover.sh index e2893c7298d8d6a1f2a792cae520d7ca2deb1598..b9d7fee0c110cc02f16a65e86c27f2bfd18cbfbe 100755 --- a/tools/cover.sh +++ b/tools/cover.sh @@ -4,16 +4,15 @@ # # inputs -ORIGINAL_BINARY=$1 # a.ncexe -ANNOTATION_FILE=$2 # a.ncexe.annot -EXECUTED_ADDRESS_FILE=$3 # from GrACE, list of executed addresses -FILTER_FILE=$4 # list of known functions to blacklist, e.g. libc +ORIGINAL_BINARY=$1 # a.ncexe +ANNOTATION_FILE=$2 # a.ncexe.annot +EXECUTED_ADDRESS_FILE=$3 # list of executed addresses (e.g. Grace or manual) +FILTER_FILE=$4 # list of known functions to blacklist, e.g. libc # outputs -OUTPUT_COVERAGE_FILE=$5 # output file with coverage info per function -OUTPUT_BLACKLIST_FILE=$6 # output file with list of functions to blacklist +OUTPUT_COVERAGE_FILE=$5 # output file with coverage info per function +OUTPUT_BLACKLIST_FILE=$6 # output file with list of functions to blacklist # other - CANDIDATE_FNS_PRE_LIBC=`dirname $6`/p1.candidates.prelibc # diff --git a/tools/do_p1transform.sh b/tools/do_p1transform.sh index 273f9324867b591342d111f4dc9780e2626dd200..5d92c788eeb8e26b18cd33f9fff80a9c07c786ca 100755 --- a/tools/do_p1transform.sh +++ b/tools/do_p1transform.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # do_p1transform.sh <originalBinary> <MEDS annotationFile> <cloneId> <BED_script> # @@ -10,8 +10,7 @@ CLONE_ID=$1 ORIGINAL_BINARY=$2 MEDS_ANNOTATION_FILE=$3 BED_SCRIPT=$4 - -echo "P1: transforming binary: cloneid=$CLONE_ID bed_script=$BED_SCRIPT" +TIMEOUT_VALUE=$5 # configuration variables P1_DIR=p1.xform @@ -22,9 +21,21 @@ LIBC_FILTER=$PEASOUP_HOME/tools/libc_functions.txt BLACK_LIST=$P1_DIR/p1.filtered_out # list of functions to blacklist COVERAGE_FILE=$P1_DIR/p1.coverage +PN_BINARY=$SECURITY_TRANSFORMS_HOME/tools/transforms/p1transform.exe + +echo "P1: transforming binary: cloneid=$CLONE_ID bed_script=$BED_SCRIPT timeout_value=$TIMEOUT_VALUE" + +execute_pn() +{ + echo "P1: issuing command: $SECURITY_TRANSFORMS_HOME/tools/transforms/p1transform.exe $1 $2 $3 with timeout value=$TIMEOUT_VALUE" + + # On timeout send SIGUSR1 + timeout -10 $TIMEOUT_VALUE $PN_BINARY $1 $2 $3 +} + mkdir $P1_DIR -# generate coverage info for manually-specified tests +# generate coverage info for manually-specified tests (if any) $PEASOUP_HOME/tools/do_manual_cover.sh # merge all execution traces @@ -36,14 +47,13 @@ $PEASOUP_HOME/tools/cover.sh $ORIGINAL_BINARY $MEDS_ANNOTATION_FILE $EXECUTED_AD if [ $? -eq 0 ]; then if [ -f $COVERAGE_FILE ]; then - echo "P1: issuing command: $SECURITY_TRANSFORMS_HOME/tools/transforms/p1transform.exe $cloneid $BLACK_LIST" - $SECURITY_TRANSFORMS_HOME/tools/transforms/p1transform.exe $CLONE_ID $BED_SCRIPT $BLACK_LIST + execute_pn $CLONE_ID $BED_SCRIPT $BLACK_LIST $TIMEOUT_VALUE else echo "No coverage file -- do not attempt P1 transform" > p1transform.out exit 1 fi else - $SECURITY_TRANSFORMS_HOME/tools/transforms/p1transform.exe $CLONE_ID $BED_SCRIPT $LIBC_FILTER + execute_pn $CLONE_ID $BED_SCRIPT $LIBC_FILTER $TIMEOUT_VALUE fi exit 0 diff --git a/tools/p1xform_v2.sh b/tools/p1xform_v2.sh index 2b94aff425db288045d1731cac4f3139ac7e1986..2500dc525c54059df7de6e5c65a2022f07ea5d42 100755 --- a/tools/p1xform_v2.sh +++ b/tools/p1xform_v2.sh @@ -5,7 +5,7 @@ # Run this script from top-level directory created by the peasoup script # -CURRENT_DIR=`pwd` +TOP_LEVEL=`pwd` variantid=$1 aspri=$2 @@ -20,13 +20,13 @@ $SECURITY_TRANSFORMS_HOME/tools/spasm/spasm $aspri $bspri $P1_DIR/stratafier.o.e # remove any candidate functions not covered # this will go away once GrACE gives us the instruction coverage information # -CONCOLIC=concolic.files_a.stratafied_0001 +CONCOLIC=$TOP_LEVEL/concolic.files_a.stratafied_0001 echo "=====================================================" echo "P1: Validating transformed binary..." echo "=====================================================" if [ -f $bspri ]; then - $PEASOUP_HOME/tools/ps_validate.sh ./a.stratafied $bspri $CONCOLIC > ps_validate.out 2> ps_validate.err + $PEASOUP_HOME/tools/ps_validate.sh ${TOP_LEVEL}/a.stratafied $bspri $CONCOLIC > ps_validate.out 2> ps_validate.err if [ $? -eq 0 ]; then echo "Successfully validated p1-transformed functions against inputs" exit 0;