I will add ret gadget to avoid the stack alignment.
My script
It doesn't show me anything; however, my work is totally similar to level 1.0.
My script
It gives me full information; however, I will debug it to be legit=)).
I will check win_stage_1 and win_stage_2
Hmmmm, it is so complicated and unclear. Therefore, I will download the file challenge and use IDA to check it clearly.
v3 = strlen("content in fileflag")/2
len / 2
from the beginning of the file to bufv3 = strlen("content in fileflag")/2
len / 2
from the beginning of the file to bufI must call both win_stage_1 and win_stage_2 to have full flag
My script
It doesn't show me anything; however, my work is totally similar to level 2.0.
My script
It gives me full information; however, I will debug it to be legit=)).
I will check win_stage_1 and win_stage_2
Hmmmm, it is so complicated and unclear. Therefore, I will download the file challenge and use IDA to check it clearly.
v3 = strlen("content in fileflag")/2
len / 2
from the beginning of the file to bufv3 = strlen("content in fileflag")/2
len / 2
from the beginning of the file to bufI must call both win_stage_1 and win_stage_2 to have full flag
My script
It doesn't show me anything; however, my work is totally similar to level 2.0.
My script
It gives me full information; however, I will debug it to be legit=)).
Each win_stage_ divides my content into the file "/flag", so I must call both of them to get the flag
However, I need to pass agrument to each function. Acccording to the calling convention
, I need pass the agrument to rdi
offset: 104
My script
It doesn't show me anything; however, my work is totally similar to level 3.0.
My script
I don't see the useful information to get the flag; so, I need to check the gadget
No function can be used for getting the flag, so I must find the gadget or something to do it.
I will pass the string "/flag" somewhere in the stack, where I know the address of it, to make the pointer for the agrument when I use syscall
Hmm, i think about the syscall, such as open, read and write the flag
However, I can't find the useful gadget to get the file descriptor from register rax ro rdi for my read syscall
Thus, I find many ways to do read syscall, but it doesn't work.
So, I try to pass file descriptor is 3. Luckily, it is successful.
I will use chmod syscall; afterward, I will cat "/flag"
It doesn't show me anything; however, my work is totally similar to level 4.0.
open, read, write syscall
chmod syscall
Let's check the gadget
As you see, there are no stack leaks and ASLR is enable
However, I see the useful gadget to pass my input to the address.
I don't know the address of stack, so I try to check the other region.
.data: 0x0000000000404078
In debug
So, I pick the address 0x4040ff for my "/flag" and open, read, and write a system call like in the previous challenge.
One of the ouputs I receive
I don't know why it contains those instructions; therefore, I try to go with the bigger offset 0x4041ff
.
It still doesn't work
I have tried and tried to find other writeable space, but there is no hope!!!
I was stuck and panic.
After many attempts to think about this challenge, I have succeeded.
I will use libc to do my work. I think about using system() to get the shell with root permission.
The interesting is that root permission
How can do it???
I see setuid
I find some informations about this, and take the reuslt.
setuid(0) fails to execute for root owned program
Okeyyyyy, it is possible to do it.
Next, we will find the address of string "/bin/sh", system(), setuid() depend the offset between them and the address of puts, and use them.
So, I will find the information in /lib/x86_64-linux-gnu/libc.so.6
puts_got: 0x404028
puts_plt : 0x401110
Okey, it leaks for me the address of puts; I will take it as the hex value
What happens if I call the main again?
This idea sound good.
It seems that I call the main again unsuccessful.
I have spent many time for this, and have the result.
I use IDA to see this, View -> Graphs -> Function calls
I try with _start and it works.
offset of puts in libc: 0x84420
offset of system in libc: 0x52290
offset of "/bin/sh" in libc: 0x1b45bd
offset of setuid in libc: 0xe4150
The step
My script
It is totally similar to level 5.0; however, to make it simple, I will use the power of pwntools to write my script.
It is totally similar to level 5; however, to make it simple, I will use the power of pwntools to write my script.
They are the same as the previous challenge =)))))
It is a special challenge, I need to use stack pivot to solve this.
0x4140e0 <data+65536>
, this address is not in the stack. However, it will copy 0x18(24) bytes from this address into rbp+8(this save return address)leave is exactly equivalent to
mov %rbp, %rsp # rsp = rbp, mov rsp,rbp in Intel syntax
pop %rbp
This is win function.
However, PIE enable,hm…
I can't find the address of gadget to use it.
Notably
As you see, PIE is not random all byte.
Therefore, I can overwrite the least significant(with 0x2f) byte to use gadget
In this challenge, I also download this challenge and the libc of this challenge. I spent many times to think to solve this challenge without brute-force =)))).
First, we need to know challenge work.
leave ; ret
gadget in the challenge
Yepp, I also need to find gadget "leave ; ret" to use technique stack pivot. Because the program return to libc, so I need to find it in libc.
As you see, I need to brute-force more nibble than in the previous challenge. Thus, I see it is not legitable to do this method, I find other ways to resolve challenge.
Until I'm stuck and panic because of spending many times. Finnaly, I brute-force and wait to get the flag. Because the libc in the sever of pwncollege is not the same as my local. So, I will find the offset of gadget in sever.