From 0809619aded7a17b38df1481b829e0e2f03b3d4a Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Sun, 11 Feb 2024 22:34:53 +0100 Subject: [PATCH] mostly finished second part --- buffer-overflow/src/project.meta | 7 +- .../src/scenes/overwriting-locals.tsx | 91 +++++++++++++++---- 2 files changed, 75 insertions(+), 23 deletions(-) diff --git a/buffer-overflow/src/project.meta b/buffer-overflow/src/project.meta index cfdd6d0..5ebc5fc 100644 --- a/buffer-overflow/src/project.meta +++ b/buffer-overflow/src/project.meta @@ -21,11 +21,10 @@ "resolutionScale": 1, "colorSpace": "srgb", "exporter": { - "name": "@motion-canvas/core/image-sequence", + "name": "@motion-canvas/ffmpeg", "options": { - "fileType": "image/png", - "quality": 100, - "groupByScene": false + "fastStart": true, + "includeAudio": true } } } diff --git a/buffer-overflow/src/scenes/overwriting-locals.tsx b/buffer-overflow/src/scenes/overwriting-locals.tsx index 00e6cc6..426c290 100644 --- a/buffer-overflow/src/scenes/overwriting-locals.tsx +++ b/buffer-overflow/src/scenes/overwriting-locals.tsx @@ -1,6 +1,6 @@ import {Circle, Layout, Node, Ray, Rect, Txt, makeScene2D} from '@motion-canvas/2d'; import { CodeBlock, remove, insert, edit, lines } from '@motion-canvas/2d/lib/components/CodeBlock'; -import {DEFAULT, Reference, all, beginSlide, createRef, createSignal} from '@motion-canvas/core'; +import {DEFAULT, Reference, all, beginSlide, createRef, createSignal, delay, makeRef} from '@motion-canvas/core'; const BACKGROUND = '#282C34'; const RED = '#E06C75'; @@ -224,6 +224,7 @@ export default makeScene2D(function* (view) { const rect = createRef(); const rbpRect = createRef(); + const padRect = createRef(); const local_cRect = createRef(); const local_30Rect = createRef(); @@ -254,6 +255,14 @@ export default makeScene2D(function* (view) { > + ); - yield* all( - code().selection(DEFAULT, .5), - code().x(-code().width() / 2, 1), - rect().opacity(1, .5), - rect().x(rect().width() / 2 + 150, 1) - ); - const writeArrow = createRef(); const metaInfo = createRef(); + const texts: Reference[] = []; view.add( rect().x() - rect().width() / 2 - 50} + toX={() => rect().x() - rect().width() / 2 - 50} endArrow lineWidth={4} stroke={GRAY} @@ -303,22 +306,72 @@ export default makeScene2D(function* (view) { toY={local_30Rect().y() + local_30Rect().height() / 2} lineDash={[10, 10]} /> - rbpRect().topRight().addX(rect().x() + 16)} text="RBP" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> - rbpRect().right().addX(rect().x() + 16)} text="8" fill={GRAY} fontSize={36} /> - rbpRect().bottomRight().addX(rect().x() + 16)} text="RBP - 0x8" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> - local_cRect().right().addX(rect().x() + 16)} text="4" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> - local_cRect().bottomRight().addX(rect().x() + 16)} text="RBP - 0xC" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> - local_30Rect().right().addX(rect().x() + 16)} text="44" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> - local_30Rect().bottomRight().addX(rect().x() + 16)} text={"RSP\n= RBP - 0x38"} fill={GRAY} fontFamily={'monospace'} fontSize={36} /> + rbpRect().topRight().addX(rect().x() + 16)} text="RBP + 0x8" fill={GRAY} fontSize={36} /> + rbpRect().right().addX(rect().x() + 16)} text="8" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> + padRect().topRight().addX(rect().x() + 16)} text="RBP" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> + padRect().right().addX(rect().x() + 16)} text="8" fill={GRAY} fontSize={36} /> + padRect().bottomRight().addX(rect().x() + 16)} text="RBP - 0x8" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> + local_cRect().right().addX(rect().x() + 16)} text="4" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> + local_cRect().bottomRight().addX(rect().x() + 16)} text="RBP - 0xC" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> + local_30Rect().right().addX(rect().x() + 16)} text="44" fill={GRAY} fontFamily={'monospace'} fontSize={36} /> + local_30Rect().bottomRight().addX(rect().x() + 16)} text={"RSP\n= RBP - 0x38"} fill={GRAY} fontFamily={'monospace'} fontSize={36} /> ) let writeArrowTo = writeArrow().to(); - writeArrowTo.y = local_30Rect().y() - local_30Rect().height() / 2; yield* all( metaInfo().opacity(1, 1), - writeArrow().to(writeArrowTo, 1) + writeArrow().to(() => { + writeArrowTo.y = local_30Rect().y() - local_30Rect().height() / 2; + writeArrowTo.x = rect().x() - rect().width() / 2 - 50; + return writeArrowTo; + }, 1), + code().selection(DEFAULT, .5), + code().x(-code().width() / 2, 1), + rect().opacity(1, .5), + rect().x(rect().width() / 2 + 150, 1) ); yield* beginSlide('Memory visualization'); + + code().language('shell'); + code().code( + `$ python3 -c "print('A' * 43)" | ./main +Enter your name: +Welcome AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!` + ); + + yield* beginSlide('Shell part1'); + + yield* all( + writeArrow().to(() => { + writeArrowTo.y = local_30Rect().y() - local_30Rect().height() / 2 - 50; + return writeArrowTo; + }, 1), + delay(.5, writeArrow().stroke(RED, 1)), + code().edit(1.5, false)` +$ python3 -c "print('A' * ${edit("43", "44")})" | ./main +Enter your name: +Welcome AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA${insert("A")}!${insert("\nYou win!")}` + ); + + yield* beginSlide('Shell part2'); + + + yield* all( + writeArrow().to(() => { + writeArrowTo.y = local_30Rect().y() - local_30Rect().height() / 2 - 300; + return writeArrowTo; + }, 1), + delay(.5, writeArrow().stroke(RED, 1)), + code().edit(1.5, false)` +$ python3 -c "print('A' * ${edit("44", "56")})" | ./main +Enter your name: +Welcome AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA${insert("...")}! +You win!${insert(`fish: Process 50623, './main' from job 1, +'python3 -c "print('A' * 56)" | …' +terminated by signal SIGSEGV (Address boundary error)`)}` + ); + + yield* beginSlide("Shell part3"); }); \ No newline at end of file