Haha I'm a noob at these CTF challenges and had troubles solving this one for some reason. Looking through it with your guidance I'm like "Wow I'm an idiot, it was so simple" lol
i think the stack smashing wasnt detected probably the way gcc was compiled, its default could have been -fno-stack-protector, so default build task will never include a canary
Thank you for all the beginner-friendly content A question as an absolute newbie into binary: only an input of length>=20 causes the SIGSEGV, i.e. it doesn’t happen with say 17. Is there a way to know or estimate how many more bytes I need?
The segfault is triggered by overwriting the return address on the stack (changing its value to some random garbage makes the program try to jump to that address and read code from there which the OS does not allow and sends the segfault signal) how many bytes you need to modify depends on the layout of the stack. You can use a debugger and look at the addresses of the local variables or look at the disassembly to see how much space is being allocated on the stack, but in this particular case the extra four bytes are the space on the stack for the local variable input. The layout of the stack is return address, then input then the buffer (though the stack grows down so these end up at decreasing addresses). When you put an input less than 16 characters it fits into the buffer. If you put 16-19 characters it starts clobbering the local variable input, and only once you put in 20 or more characters does it start touching the return address and cause the segfault.
I don't understand how just adding a few extra characters causes the flag to magically appear. Is it because added the extra characters causes some specific code to execute? If so which part?
All what required is to enter input of size more than 16 char length. That will cause buffer overflow. That fires the handler setup by signal(SIGSEGV,... Which gives the flag😂 SIGSEGV (Signal Segmentation Violation) Invalid access to storage − When a program tries to read or write outside the memory it is allocated for it.
I was at that part in my Security+ chapter about buffer-overflow and I was looking for an example of what it really did in C. Thanks man !! :)
Maybe putting -fstack-protector when compiling would have worked? Not sure
Dude, following along right with you, even going ahead now until I get stuck! Please keep going, this is great and I appreciate you so much!
Thanks John. We appreciate how you thoroughly explain everything and keep it simple at the same time. You're a rockstar!!
Thank you John, every time I watch one of your videos I always learn something new :)
Great series! Keep it coming!
These videos are so awesome. Thanks so much John
Loving this series, John. Please finish it!
Super cool series, always a pleasure to watch them! Keep it up!
it seems to be a kali linux thing having no stack-protector when building with gcc, as it works on my machine (ubuntu)
You have to pass “fstack-protector" when compiling with gcc
Haha I'm a noob at these CTF challenges and had troubles solving this one for some reason. Looking through it with your guidance I'm like "Wow I'm an idiot, it was so simple" lol
This was fun! Please more John. :)
Awesome
Enjoyed the video. Keep them coming.
You the best John, thanks a lot for these material and your explanations,
You are a master mind my friend
3 ways to fail the computer systems course I did ~20 years ago: 1) cheat 2) do way too little adequate work 3) use gets()
6:34 a minor correction: the char array buf1 is 100*sizeof(char) Bytes long
you already know it but let me tell you one more time YOU ARE AWESOME.
Done Watching Cool Thanks John
I wanted to subscribe, but I've completely forgotten that I already was. Anyway, thanks for another informative video!
sigsegv stands for signal segmentation violation
i think the stack smashing wasnt detected probably the way gcc was compiled, its default could have been -fno-stack-protector, so default build task will never include a canary
Thank you for all the beginner-friendly content
A question as an absolute newbie into binary: only an input of length>=20 causes the SIGSEGV, i.e. it doesn’t happen with say 17. Is there a way to know or estimate how many more bytes I need?
The segfault is triggered by overwriting the return address on the stack (changing its value to some random garbage makes the program try to jump to that address and read code from there which the OS does not allow and sends the segfault signal) how many bytes you need to modify depends on the layout of the stack. You can use a debugger and look at the addresses of the local variables or look at the disassembly to see how much space is being allocated on the stack, but in this particular case the extra four bytes are the space on the stack for the local variable input. The layout of the stack is return address, then input then the buffer (though the stack grows down so these end up at decreasing addresses). When you put an input less than 16 characters it fits into the buffer. If you put 16-19 characters it starts clobbering the local variable input, and only once you put in 20 or more characters does it start touching the return address and cause the segfault.
@@hedgechasing thanks for the explanation! I definitely have to look at it more
Oh the days I coded in C/C++, flush of output buffer is not guaranteed without the flush
09:00 laughs in format string vulnerability and return-to-libc
What is the version of Sublime text you are using?? Please answer
If this is training wheels, I am still at the crawling phase XD. I'll get there one day :')
Nice'n'easy :)
I don't understand how just adding a few extra characters causes the flag to magically appear. Is it because added the extra characters causes some specific code to execute? If so which part?
This is rust will dominated the c language 😂😂 but hey nice reverse engineer 😀 😉
Is overflow on this the same as overflow on Hacknet?
I think strcpy is the most used function to demonstrate bufferoverflows.
you don’t explain how the buffer overflow even works though..?
Do you have references / explanation about the {,_COMPLETE}, i searched all day long on Shell expansion and no one say a thing about this tips :)
It's a bash feature called brace expansion.
👍
you made a 64bit version, so there more buffers i think.
How can this be dangerous?
NVIDIA should be tried for unfair profit and hoarding...
I gave the 69th like 😁
2nd?
All what required is to enter input of size more than 16 char length. That will cause buffer overflow.
That fires the handler setup by signal(SIGSEGV,...
Which gives the flag😂
SIGSEGV
(Signal Segmentation Violation) Invalid access to storage − When a program tries to read or write outside the memory it is allocated for it.
1st?