################################################################################ # # Date: May 18 2018 # Author: Vincent Dary # File: exploit_ascii_filter_sample.gdb # Licence: GPLv3 # Description: Debug script for vuln_ascii_filter_sample.c exploitation. # This script uses exploit_ascii_filter_sample.sh to generate the # Payload injected in the vuln_ascii_filter_sample binary. # # Use example: # $ gdb -q --command=exploit_ascii_filter_sample.gdb vuln_ascii_filter_sample ################################################################################ # hardcoded memory addresses ## .code segment set $addr_first_fgets_call = 0x8049255 set $addr_strlen_call = 0x80492b5 ## .stack segment set $addr_buffer_info_comment = 0xffffdc24 set $addr_in_ascii_shellcode = 0xffffdc91 set $addr_esp_eip_crossing = 0xffffdcdc define sleep_and_continue shell sleep 1 continue end # Debug the stack overflow in b_info.book_ref define stack_overflow_dbg break *$addr_first_fgets_call commands x/140xw $esp x/i $eip sleep_and_continue end break *$addr_strlen_call commands x/140xw $esp x/i $eip sleep_and_continue end end # ASCII shellcode debuging define ascii_shellcode_dbg_break_settings thbreak *$addr_buffer_info_comment commands x/48i $eip i r $esp sleep_and_continue end thbreak *$addr_in_ascii_shellcode commands x/40i $eip i r $esp sleep_and_continue end thbreak *$addr_esp_eip_crossing commands x/20i $eip i r $eip i r $esp delete 1 2 3 sleep_and_continue end end # main gdb function define exploit_ascii_filter_dbg set disassembly-flavor intel set height 0 set pagination off set exec-wrapper ./exec_wrapper break *main commands stack_overflow_dbg ascii_shellcode_dbg_break_settings x/3i *main+26 sleep_and_continue end run < /tmp/exploit_ascii_filter_stdin_gdb end exploit_ascii_filter_dbg