[BUUCTF]PWN——picoctf_2018_buffer overflow 0

picoctf_2018_buffer overflow 0

annex
Insert picture description here

step

  1. Routine inspection, 32-bit program, nx protection is turned on
    Insert picture description here
  2. Prompt for ssh link
    Insert picture description here
  3. After ssh was connected, I tried a little bit, it seems that the program vuln can read the flag
    Insert picture description here
  4. 32 is ida loading test file.
    Insert picture description here
    Baidu clicked on signal and found that 11 is (SIGSEGV), a signal for invalid access to storage.
    Line 15 means that a function sigsegv_handler is set to handle invalid access to storage when the program generates.
    Insert picture description here
    That is to say, when the program causes invalid memory access, it will output flag.
    Looking down on the vuln function,
    Insert picture description here
    copy src to dest, which can cause overflow.
    There are two solutions:
    1. Overwrite ret to put, and then output the value of the flag address,
    payload='a'*(0x18+4 )+p32(puts)+p32(0)+p32(flag_addr)
    Insert picture description here
    Insert picture description here
    ./vuln aaaaaaaaaaaaaaaaaaaaaaaa\xc0\x84\x04\x08\x00\x00\x00\x00\x80\xa0\x04\x08
    Insert picture description here
    2. The above analysis also outputs flag when the memory access error is caused. Due to the overflow of vlun, we can easily cause illegal memory access
    Insert picture description here

Guess you like

Origin blog.csdn.net/mcmuyanga/article/details/114576788