diff --git a/.gitattributes b/.gitattributes index ca55419c50ab9d6cf32333366f97dbfba9152604..802375e2f0d507df39a077843b4ee8084b3e9e0d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -22,8 +22,10 @@ examples/Makefile -text examples/block_copy.c -text examples/cmd_args_005.c -text examples/concolic_test_handshake.c -text -examples/dumbledore.c -text examples/dumbledore_cmd.c -text +examples/dumbledore_file.c -text +examples/dumbledore_file_with_fopen_check.c -text +examples/dumbledore_stdin.c -text examples/fptest.c -text examples/globalfield.c -text examples/hanoi.c -text diff --git a/examples/Makefile b/examples/Makefile index 50eb753dd2d027e3dcce57d668941a165f91007f..410262d9507c49c88fab5920ef442f9b009c914c 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -9,7 +9,7 @@ LD=DO_NOT_USE .SUFFIXES: .o .c .cpp .exe -exes=hanoi.exe hanoi_overrun.exe hanoi_heap_overrun.exe hanoi_stack_overrun.exe print_ptr.exe malloc.exe block_copy.exe hello.exe hanoi_overrun_tainted.exe hanoi_overrun_taintedenv.exe memcpy.exe cmd_args_005.exe dumbledore.exe dumbledore_cmd.exe +exes=hanoi.exe hanoi_overrun.exe hanoi_heap_overrun.exe hanoi_stack_overrun.exe print_ptr.exe malloc.exe block_copy.exe hello.exe hanoi_overrun_tainted.exe hanoi_overrun_taintedenv.exe memcpy.exe cmd_args_005.exe dumbledore_stdin.exe dumbledore_cmd.exe dumbledore_file.exe all: env_check ${exes} @@ -32,6 +32,8 @@ all: env_check ${exes} chopzero: @ if [ ! -f chopzero ]; then gcc chopzero.c -o chopzero -O3 ; fi +$(exes): ${STRATA}/lib/x86_linux/libstrata.a + env_check: diff --git a/examples/dumbledore_file.c b/examples/dumbledore_file.c new file mode 100644 index 0000000000000000000000000000000000000000..f7c5e203b6e1139822e01be0697c4612fa08da48 --- /dev/null +++ b/examples/dumbledore_file.c @@ -0,0 +1,46 @@ +#include <stdio.h> +#include <sys/mman.h> +#include <string.h> +#include <stdlib.h> + +enum {BUFSIZE = 98}; + +char grade = 'D'; +char Name[BUFSIZE]; +FILE *f; + +void readString(char *s) { + char buf[BUFSIZE]; + int i = 0; + int c; + + for (;;) + { + c = fgetc(f); + if ((c == EOF) || (c == '\n')) + break; + buf[i] = c; + i++; + } + buf[i] = '\0'; + + for (i = 0; i < BUFSIZE; i++) + s[i] = buf[i]; +} + + +int main(void) +{ + f = fopen("data.txt", "r"); + + readString(Name); + + if (strcmp(Name, "Wizard in Training") == 0) + grade = 'B'; + + printf("Thank you, %s.\n", Name); + printf("I recommend that you get a grade of %c on this assignment.\n", grade); + + exit(0); +} + diff --git a/examples/dumbledore_file_with_fopen_check.c b/examples/dumbledore_file_with_fopen_check.c new file mode 100644 index 0000000000000000000000000000000000000000..06d056a7459c0bdf3ec4ff2286d3683da70cd372 --- /dev/null +++ b/examples/dumbledore_file_with_fopen_check.c @@ -0,0 +1,46 @@ +#include <stdio.h> +#include <sys/mman.h> +#include <string.h> +#include <stdlib.h> + +enum {BUFSIZE = 98}; + +char grade = 'D'; +char Name[BUFSIZE]; +FILE *f; + +void readString(char *s) { + char buf[BUFSIZE]; + int i = 0; + int c; + + for (;;) + { + c = fgetc(f); + if ((c == EOF) || (c == '\n')) + break; + buf[i] = c; + i++; + } + buf[i] = '\0'; + + for (i = 0; i < BUFSIZE; i++) + s[i] = buf[i]; +} + + +int main(void) +{ + f = fopen("data.txt", "r"); + + readString(Name); + + if (strcmp(Name, "Wizard in Training") == 0) + grade = 'B'; + + printf("Thank you, %s.\n", Name); + printf("I recommend that you get a grade of %c on this assignment.\n", grade); + +// exit(0); +} + diff --git a/examples/dumbledore.c b/examples/dumbledore_stdin.c similarity index 90% rename from examples/dumbledore.c rename to examples/dumbledore_stdin.c index 02e2f05c1105deb85faf5281272fda79cb817f74..44c93c0b31f99c4784e1cfbb7260122463b04088 100644 --- a/examples/dumbledore.c +++ b/examples/dumbledore_stdin.c @@ -32,8 +32,11 @@ void readString(char *s) { int main(void) { +#if 0 +/* needed for some exploit, but not really part of the program! */ mprotect((void*)((unsigned int)Name & 0xfffff000), 1, PROT_READ | PROT_WRITE | PROT_EXEC); +#endif readString(Name); if (strcmp(Name, "Wizard in Training") == 0) diff --git a/tools/do_concolic.sh b/tools/do_concolic.sh index 5a58b6b2ff397aec6c9bd374ce89cf99871f4fc5..0890767b53ce891a334b488f1cc29d3a52fcd757 100755 --- a/tools/do_concolic.sh +++ b/tools/do_concolic.sh @@ -13,7 +13,7 @@ whoami=`whoami` # simple error checking # if [ $GRACE_HOME"X" = "X" ]; then echo Failed to set GRACE_HOME; exit 2; fi -if [ ! -f $GRACE_HOME/concolic/src/util/linux/meds_annot_to_grace ]; then +if [ ! -f $GRACE_HOME/concolic/src/util/linux/objdump_to_grace ]; then echo "Failed to set GRACE_HOME properly (i.e. wrong path)" exit 3 fi @@ -28,7 +28,7 @@ line=`cat $annot|egrep " FUNC GLOBAL exit"|sed "s/ */ /g"` stop_ea=`echo $line |cut -d" " -f1` # assume grace_home env is set. -$GRACE_HOME/concolic/src/util/linux/meds_annot_to_grace $annot +$GRACE_HOME/concolic/src/util/linux/objdump_to_grace $strata_exe if [ ! -f $sym ]; then echo Failed to produce .sym file exit 1; @@ -39,7 +39,7 @@ for i in `ipcs -q|grep $whoami |cut -d" " -f 2`; do ipcrm -q $i done -STRATA_GRACE=1 controller $extra_args --start $start_ea --stop $stop_ea --symbols $sym $strata_exe +STRATA_GRACE=1 controller $extra_args --start $start_ea --stop $stop_ea --symbols $sym --outputs replay $strata_exe echo cleaning up killall -q controller diff --git a/tools/ps_analyze.sh b/tools/ps_analyze.sh index 4a70487ef52f69315dccdfb3f0852395fb0708db..527d18348b2bd107273279fa1e76c1b93d92ed17 100755 --- a/tools/ps_analyze.sh +++ b/tools/ps_analyze.sh @@ -69,7 +69,8 @@ $SMPSA_HOME/SMP-analyze.sh a.ncexe echo Done. echo Running concolic testing to generate inputs ... -$PEASOUP_HOME/tools/do_concolic.sh a 2>&1 |egrep -e "INPUT VECTOR:" -e "1: argc =" +$PEASOUP_HOME/tools/do_concolic.sh a --iterations 50 --logging tracer +# 2>&1 |egrep -e "INPUT VECTOR:" -e "1: argc =" # >/dev/null 2>&1 echo Done. diff --git a/tools/ps_run.sh b/tools/ps_run.sh index d10b42bbbf6bacf6c03c2b7597144aa610e8df3f..83e7f77a860a093a2b3ac84014badf6741fd3160 100755 --- a/tools/ps_run.sh +++ b/tools/ps_run.sh @@ -1,8 +1,24 @@ #!/bin/sh +# +# determine the directory that contains the files for peasoup +# datapath=$1 + +# +# grab the rest of the args in $* +# shift; -STRATA_ANNOT_FILE=$datapath/a.ncexe.annot STRATA_PC_CONFINE=1 $datapath/a.stratafied $* +# +# Run the program with the proper env. vars set., and the arguments to the program specified +# +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 \ + $datapath/a.stratafied $*