diff --git a/examples/Makefile b/examples/Makefile index 56f764b1e7cff41954b1eef0ee12cd3061b92efb..9d8cd4afbe9689f81b46c1ca9408b9779ec234fa 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -63,7 +63,7 @@ clean: rm -Rf peasoup_executable_directory.* rm -f strata.log.* rm -f *.sym - # if [ ! "X" = "X"${PGUSER} ]; then sh ../tools/db/drop_my_tables.sh; sh ../tools/db/pdb_setup.sh; fi + if [ ! "X" = "X"${PGUSER} ]; then sh ../tools/db/drop_my_tables.sh; sh ../tools/db/pdb_setup.sh; fi concclean: rm -Rf concolic.files_* diff --git a/tools/db/drop_my_tables.sh b/tools/db/drop_my_tables.sh index abd8299f2fb3d64299ebf279cc301c6530508660..1d03212a6099557ff90203d49c62ed7c5c52c57b 100755 --- a/tools/db/drop_my_tables.sh +++ b/tools/db/drop_my_tables.sh @@ -1,19 +1,16 @@ #!/bin/bash -psql << 'EOF' -CREATE LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION drop_tables(username IN VARCHAR) RETURNS void AS $$ -DECLARE - statements CURSOR FOR - SELECT tablename FROM pg_tables - WHERE tableowner = username; -BEGIN - FOR stmt IN statements LOOP - EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(stmt.tablename) || ' CASCADE;'; - END LOOP; -END; -$$ -LANGUAGE plpgsql; -EOF -psql -c "SELECT drop_tables('$PGUSER');" +functables=`psql -t -q -c "select function_table_name from variant_info"` +insntables=`psql -t -q -c "select instruction_table_name from variant_info"` +addrtables=`psql -t -q -c "select address_table_name from variant_info"` +othertables="variant_dependency variant_info file_info doip" + +for i in $insntables $addrtables $functables $othertables +do + echo -------------------------------------------------------------------------- + echo -n Dropping table $i..." " + psql -t -q -c "drop table $i cascade;" + echo Done. + echo -------------------------------------------------------------------------- +done diff --git a/tools/ps_analyze.sh b/tools/ps_analyze.sh index 250ab5bafd652b21b3360c1fb434c5ef554e84e5..b292896c9eac958d462d53edcc15f6de0ba7b425 100755 --- a/tools/ps_analyze.sh +++ b/tools/ps_analyze.sh @@ -71,6 +71,16 @@ echo Running IDA Pro static analysis phase ... $SMPSA_HOME/SMP-analyze.sh a.ncexe echo Done. +# +# Run concolic engine +# +echo Running concolic testing to generate inputs ... +#$PEASOUP_HOME/tools/do_concolic.sh a --iterations 25 --logging tracer,instance_times,trace +$PEASOUP_HOME/tools/do_concolic.sh a --iterations 25 --logging tracer,trace,inputs +# 2>&1 |egrep -e "INPUT VECTOR:" -e "1: argc =" +# >/dev/null 2>&1 +echo Done. + # # Populate IR Database @@ -99,7 +109,8 @@ if [ ! "X" = "X"$PGUSER ]; then $SECURITY_TRANSFORMS_HOME/libIRDB/test/fill_in_cfg.exe $cloneid # finish the initial IR $SECURITY_TRANSFORMS_HOME/libIRDB/test/fix_calls.exe $cloneid # fix call insns so they are OK for spri emitting $SECURITY_TRANSFORMS_HOME/libIRDB/test/ilr.exe $cloneid # perform ILR - $SECURITY_TRANSFORMS_HOME/libIRDB/test/generate_spri.exe $cloneid a.ncexe.aspri # generate the spri code + $SECURITY_TRANSFORMS_HOME/libIRDB/test/generate_spri.exe $cloneid a.irdb.aspri # generate the aspri code + $SECURITY_TRANSFORMS_HOME/tools/spasm/spasm a.irdb.aspri a.irdb.bspri # generate the bspri code fi fi echo ------------------------------------------------------------------------------- @@ -111,16 +122,6 @@ if [ ! "X" = "X"$PGUSER ]; then fi -# -# Run concolic engine -# -echo Running concolic testing to generate inputs ... -#$PEASOUP_HOME/tools/do_concolic.sh a --iterations 25 --logging tracer,instance_times,trace -$PEASOUP_HOME/tools/do_concolic.sh a --iterations 25 --logging tracer,trace,inputs -# 2>&1 |egrep -e "INPUT VECTOR:" -e "1: argc =" -# >/dev/null 2>&1 -echo Done. - # # Uncomment this part to test the P1 xform @@ -132,16 +133,16 @@ echo Done. #echo Starting the P1 transform #date #$PEASOUP_HOME/tools/p1xform.sh $newdir > p1xform.out 2> p1xform.err -# + #echo $current_dir/$newdir/p1.xform/p1.final -# + #if [ -f $current_dir/p1.xform/p1.final ]; then # echo List of functions transformed: # cat $current_dir/p1.xform/p1.final #else # echo P1 was unable to transform the subject program #fi -# + #date #echo Done with the P1 transform diff --git a/tools/ps_run.sh b/tools/ps_run.sh index 8ecf6e5f9f2fb17f6040f7c7b93cad023029903d..0ce55fa89ebef06ef3f62de8a7f40e86bc3e8ced 100755 --- a/tools/ps_run.sh +++ b/tools/ps_run.sh @@ -10,21 +10,19 @@ datapath=$1 # shift; +# +# Determine which SPRI file to use; first priorty goes to one generated from the IRDB. +# +if [ -f $datapath/a.irdb.bspri ]; then + export STRATA_SPRI_FILE=$datapath/a.irdb.bspri +elif [ -f $datapath/p1.xform/p1.final.bspri ]; then + export STRATA_SPRI_FILE=$datapath/p1.xform/p1.final.bspri +fi + # # Run the program with the proper env. vars set., and the arguments to the program specified # -if [ -f $datapath/p1.xform/p1.final.bspri ]; -then -STRATA_DOUBLE_FREE=1 \ - STRATA_HEAPRAND=1 \ - STRATA_PC_CONFINE=1 \ - STRATA_PC_CONFINE_XOR=1 \ - STRATA_PC_CONFINE_XOR_KEY_LENGTH=1024 \ - STRATA_ANNOT_FILE=$datapath/a.ncexe.annot \ - STRATA_SPRI_FILE=$datapath/p1.xform/p1.final.bspri \ - $datapath/a.stratafied "$@" -else STRATA_DOUBLE_FREE=1 \ STRATA_HEAPRAND=1 \ STRATA_PC_CONFINE=1 \ @@ -32,6 +30,5 @@ STRATA_DOUBLE_FREE=1 \ STRATA_PC_CONFINE_XOR_KEY_LENGTH=1024 \ STRATA_ANNOT_FILE=$datapath/a.ncexe.annot \ $datapath/a.stratafied "$@" -fi