Skip to content
Snippets Groups Projects
Commit d1022da5 authored by Anh Nguyen-Tuong's avatar Anh Nguyen-Tuong
Browse files

Handle -PIE main execs

parent abf7a902
No related branches found
No related tags found
No related merge requests found
...@@ -17,16 +17,23 @@ grep "<main>:" $tmp_objdump >/dev/null 2>&1 ...@@ -17,16 +17,23 @@ grep "<main>:" $tmp_objdump >/dev/null 2>&1
if [ ! $? -eq 0 ]; then if [ ! $? -eq 0 ]; then
grep -B1 libc_start_main@plt $tmp_objdump >/dev/null 2>&1 grep -B1 libc_start_main@plt $tmp_objdump >/dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
main_addr=$(grep -B1 libc_start_main@plt $tmp_objdump | grep mov | grep rdi | cut -d':' -f2 | cut -d'm' -f2 | cut -d',' -f1 | cut -d'x' -f2) grep -B1 start_main $tmp_objdump | grep rdi | grep rip
if [ "$main_addr" = "" ]; then if [ $? -eq 0 ]; then
echo "Zafl: Error inferring main" echo "Zafl: Main exec is PIE... unable to infer address of main. Automatically insert fork server (not as efficient as inferring main though)"
exit 1 options=" $options -o zafl:--autozafl "
fi else
main_addr=$(grep -B1 libc_start_main@plt $tmp_objdump | grep mov | grep rdi | cut -d':' -f2 | cut -d'm' -f2 | cut -d',' -f1 | cut -d'x' -f2)
if [ "$main_addr" = "" ]; then
echo "Zafl: Error inferring main"
exit 1
fi
echo "Zafl: Inferring main to be at: 0x$main_addr" echo "Zafl: Inferring main to be at: 0x$main_addr"
options=" -o zafl:'-e 0x$main_addr'" options=" $options -o zafl:'-e 0x$main_addr'"
fi
fi fi
fi fi
rm $tmp_objdump
echo "Zafl: Transforming input binary $input_binary into $output_zafl_binary" echo "Zafl: Transforming input binary $input_binary into $output_zafl_binary"
#cmd="$PSZ $input_binary $output_zafl_binary -c move_globals=on -c zafl=on -o move_globals:--elftables -o zipr:--traceplacement:on -o zafl:--stars $*" #cmd="$PSZ $input_binary $output_zafl_binary -c move_globals=on -c zafl=on -o move_globals:--elftables -o zipr:--traceplacement:on -o zafl:--stars $*"
...@@ -46,3 +53,4 @@ if [ $? -eq 0 ]; then ...@@ -46,3 +53,4 @@ if [ $? -eq 0 ]; then
exit 1 exit 1
fi fi
fi fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment