Ret2Win (phần 2)

 RET TO WIN

Mình nhặt được challenge này trên mạng:

View source code c của đề: 
Thoạt nhìn qua thì ta có thấy hàm void flag() không hề được nhắc đến or gọi ở hàm void main() ==> Như ở phần 1 thì chắc hẳn là các bạn nghĩ ngay phải ret nó vào hàm main để nó 
puts("Exploited!!!!!"); .Ngoài ra thì chúng ta vẫn còn 1 lỗi nữa là Stack Overflow. Nếu bạn nào đã xem được phần 1 thì bạn có thể dừng ở đây và tập thực hành với bài này. 
Cú pháp để compiler nó gcc source.c -o vuln -no-pie -fno-stack-protector -z execstack -m32
 

I. Start

    1. Checksec
        

    2. Analysis

        Set breakpoint at 0x0804919d of gets function and 0x080491aa of ret instruction
        Run this program with debugger gdb-peda: 
            We will have an arguments to use for gets function. It at 0xffffd078. Your task is must be calculate distance from this argument to rsp. After that, we will overwrite a few bytes to ret to void flag(). Now continue this program and it is stop at 0x080491aa. 
        
We see the rsp, it at 0xffffd0ac. We calc that we must be overwrite  52 byte. Oke Let's write payload to exploit

    3. Find flag function address

        I will find it by pdis flag 
            

        I make out that 
0x080491c3 is flag function address
        
       
       It may be different from what you saw in part 1, You should read and understand pwntools. Its useful for binary exploit. 
          Tada...
    
    Successfully!!
Goodluck!!
Write by Kinabler

Comments

Popular posts from this blog

Ret2Shellcode

LACTF2023 - MISC