2SMOL (pwnable)
vulnerability
First, Check the protection. All of protection is turned off.
It called only read
functions. but the size of read is bigger than buffer. It is Buffer OverFlow.
And NXbit is turned off, So I can use shellcode to exploit.
But we only have 0x8 size to write. It is not enough to write shellcode on the stack, and also even if we can write shellcode on the stack, we can’t leak the stack address.
So we have to write on memory which we know address. It is 0x402000
. We can change the flow by using leave ret
gadgets. then we can write shellcode on memory. Lastly, overwrite return address to shellcode’s address.
exploit
1 | from pwn import * |
resolve (pwnable)
vulnerability
First, Check the protection. No canary, No pie and Partial RELRO. It is easy to overwrite stack buffer.
The main function only call get@plt
. It can occur overflow here. But there is no way to leak libc address and also doesn’t have system functions which can call /bin/sh
in binary. But the method for exploit can be inferred from the name of the problem. The name is resolve
. So i used return-to-dl-resolve
.
If you don’t know well about this, Please refer to the reference.
https://www.lazenca.net/pages/viewpage.action?pageId=19300744
Then let’s find gadgets for exploit.
There is get
function. so i only need to control rdi
for calling function.
And get section address what i need. like plt
, bss
, dynsym
, dynstr
, rela.plt
…
Using ROP
, make fake structure which is used by lazy binding
and write on the memory which i know address.
In my case, I wrote on 0x404508. The red is fake structure of Elf64_Rela. And the orange is about Elf64_Sym. The last things are system
and /bin/sh
.
After making fake structure, The system function is executed by invoking the plt
.
Finally, I can call system(/bin/sh/)
exploit
1 | from pwn import * |