Understanding C Pointer Magic Arithmetic | Ep. 07

preview_player
Показать описание
We debug the line that causes the heap overflow. And it's a great opportunity to understand pointers in C.

Episode 07:
00:00 - Intro & Motivation
00:46 - Create Debug Build
01:02 - The Crashing Location
01:43 - Scary Pointer Magic
02:10 - *to++ = *from
02:56 - Explaining: from++
04:03 - Explaining: *from
04:56 - Explaining: to++
05:23 - Explaining: *to = *from
05:54 - The Copy While Loop
06:26 - Explaining: from[0] vs *from
07:14 - The Bug!
08:35 - Wrong Allocation Size Calculated
09:30 - Unescape Logic
10:15 - Why though?

-=[ ❤️ Support ]=-

-=[ 🐕 Social ]=-

Рекомендации по теме
Комментарии
Автор

A "hold my hand to understand the assembly language" series is what I need.

JohnSmith-ihcj
Автор

The professor that taught me C is an ethical hacker I look up to a lot. I love realizing how things he taught me actually fit into the context of security.

CubensisEnjoyer
Автор

1:50 "I know this looks intimidating, but let's look at this in assembly" should be a meme :-D
*to++ = *from++ is a memcpy()/strcpy() (that assumes no overlap) even without looking at the assembler. Hats off that this is simpler for you through reading the asm 😉

Gregorius
Автор

I know you might not hear this often, but the captions really does really help me understand, thanks so much for adding them.

mapleint
Автор

This series needs more love. It also needs a sequel

szymach
Автор

fun fact, not only are "*from" and "from[0]" semantically equivalent, so is "0[from]"

wtthehll
Автор

one of the most important things to know when doing work like this, great content as always man

_..---
Автор

My Professor gave us this exact pointer magic for finals

He never explained how ++ interacts with pointers and No on got it right in the exam

Running the code after compiling gave me the right answer but I never understood it until now thank you

Zedoy
Автор

This is my favorite YT channel hands down. Damn the cliff hangers though!!

thatcreole
Автор

i have try to understand this cve for 4 days ago. and now, i am seeing your video :))) i wish it come more earlier

chittodihoc
Автор

This is why I advocate to bring back assembly in colleges. A semester of hardware design and building a small 8 bit system and developing in assembly.
I had no issue with pointers when we finally learned C, because I had been programming in 6502/Z80 already for 3 or 4 years. The other students couldn’t grasp it as easily.
So my syllabus would look like:
-Hardware design assembler
-C
-And some high level OO language.

And boy this code is shotty for such an important security tool.
You would do the stripping of the slashes first and have that result string copied.
These are two separate functional operations, that you should not combine. Unless speed is an issue but that can’t be the case in sudo :)

CallousCoder
Автор

I remember learning c in uni, good times 👍

andyli
Автор

650k sub I think I subscribed when he was under 5000k it's amazing to see channels growing !

peaceandfood
Автор

Man that jeff (gef) guy is so awesome 😂

flamendless
Автор

Do you know about the -Og flag? It's specifically listed for use with debugging in the manual page

qwertywifi
Автор

I really enjoy your videos thank you 🙏😁

FedoraRose
Автор

nice bro, your video's very helpful to me

--_mr.who_--
Автор

I love learning new thing thanks for the video

reastle
Автор

Hey i'm curious about OSCP instead of my college degree. So after then can i get a pentesting job??

gamesinloop
Автор

I notice you referred to '0' as "ASCII null" a couple of times. "null" is the German word for English "zero", right?

MCLooyverse