session:06
Differences
This shows you the differences between two versions of the page.
| session:06 [2018/06/28 14:08] – [Overwriting the stored return address] Add code snippets link archive Maria-Elena MIHĂILESCU (25616) | session:06 [2020/07/19 09:49] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | = 0x06. Buffer | + | ====== 0x05. Buffer |
| - | == Slides | + | ===== Resources ===== |
| - | Slides are available | + | [[https:// |
| - | [[https:// | + | [[https:// |
| [[https:// | [[https:// | ||
| - | == Tutorials | ||
| - | == Buffers | + | / |
| + | |||
| + | ===== Tutorials ===== | ||
| + | |||
| + | ===== Buffers | ||
| A buffer is an area of contiguous data in memory, determined by a starting address, contents and length. Understanding how buffers are used (or misused) is vital for both offensive and defensive purposes. | A buffer is an area of contiguous data in memory, determined by a starting address, contents and length. Understanding how buffers are used (or misused) is vital for both offensive and defensive purposes. | ||
| Line 215: | Line 218: | ||
| Can you guess how the resulting code will look like, disassembled? | Can you guess how the resulting code will look like, disassembled? | ||
| - | === Stack buffer overflows | + | ==== Stack buffer overflows |
| As we have seen in previous sessions, the stack serves multiple purposes: | As we have seen in previous sessions, the stack serves multiple purposes: | ||
| Line 405: | Line 408: | ||
| </ | </ | ||
| - | === Diverting code execution | + | ==== Diverting code execution |
| We attempted to use the wonderful '' | We attempted to use the wonderful '' | ||
| Line 548: | Line 551: | ||
| </ | </ | ||
| - | === Overwriting the stored return address | + | ==== Overwriting the stored return address |
| Let's wrap up our stack smashing adventure by changing the code flow through overwriting the return address stored on the stack. | Let's wrap up our stack smashing adventure by changing the code flow through overwriting the return address stored on the stack. | ||
| Line 706: | Line 709: | ||
| </ | </ | ||
| - | == Challenges | + | ===== Challenges |
| <note important> | <note important> | ||
| Line 725: | Line 728: | ||
| Use the following [[http:// | Use the following [[http:// | ||
| - | === 01. Parrot | + | ==== 01. Parrot |
| Some programs feature a "stack smashing protection" | Some programs feature a "stack smashing protection" | ||
| Line 731: | Line 734: | ||
| We have implemented our very own '' | We have implemented our very own '' | ||
| - | === 02. Indexing | + | <note tip> |
| + | Values are little endian. So if you want to send '' | ||
| + | </ | ||
| + | |||
| + | <note tip> | ||
| + | When providing input to a program and wanting to maintain connection to its standard input, run: | ||
| + | < | ||
| + | cat payload - | ./program | ||
| + | </ | ||
| + | |||
| + | Or, if you have a payload generator program such as '' | ||
| + | < | ||
| + | cat <(python payload.py) - | ./program | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ==== 02. Indexing | ||
| More complex programs require some form of protocol or user interaction. This is where the great [[https:// | More complex programs require some form of protocol or user interaction. This is where the great [[https:// | ||
| Line 737: | Line 756: | ||
| Here's an interactive script to get you started: | Here's an interactive script to get you started: | ||
| - | <code python> | + | <code python |
| # | # | ||
| from pwn import * | from pwn import * | ||
| Line 752: | Line 771: | ||
| </ | </ | ||
| - | === 03. Smashthestack Level7 | + | <note tip> |
| + | Go through GDB when aiming to solve this challenge. As all input values are strings, you can input them at the keyboard and follow their effect in GDB. | ||
| + | </ | ||
| + | |||
| + | <note tip> | ||
| + | You can inspect the behavior of a program for a given input by doing: | ||
| + | < | ||
| + | cat payload | strace ./program | ||
| + | </ | ||
| + | That is, you will trace the program being exploited and see '' | ||
| + | </ | ||
| + | ==== 03. Smashthestack Level7 | ||
| Now you can tackle a real challenge. See if you can figure out how you can get a shell from this one. | Now you can tackle a real challenge. See if you can figure out how you can get a shell from this one. | ||
| - | === 04. Neighbourly | + | <note tip> |
| + | There' | ||
| + | </ | ||
| - | Let's overwrite a structure' | + | <note tip> |
| + | What are the four 32 bit values that multiplied by '' | ||
| + | </ | ||
| - | === 05. Bonus: Birds | + | <note tip> |
| + | In order to run a program that receives command line arguments under gdb, you can do the following: | ||
| - | Time for a more complex challenge. Be patient and don't speed through | + | <code gdb> |
| + | $ gdb ./main | ||
| + | gdb$ set args arg1 arg2 arg3 | ||
| + | gdb$ start | ||
| + | </ | ||
| + | </ | ||
| + | ==== 04. Neighbourly ==== | ||
| + | |||
| + | Let's overwrite | ||
| + | |||
| + | <note tip> | ||
| + | The '' | ||
| + | </ | ||
| - | === 06. Uninitialized | + | ==== 05. Uninitialized |
| There' | There' | ||
| Line 771: | Line 818: | ||
| Do **not** use pwntools for this task. | Do **not** use pwntools for this task. | ||
| </ | </ | ||
| - | === 07: Bonus: Uninitialized 2 | + | ==== 06: Bonus: Uninitialized 2 ==== |
| There' | There' | ||
| <note tip> | <note tip> | ||
| - | Use '' | + | Use '' |
| </ | </ | ||
| Line 782: | Line 829: | ||
| Create a pwntools-based script to solve both the initial executable and the bonus one. | Create a pwntools-based script to solve both the initial executable and the bonus one. | ||
| </ | </ | ||
| + | |||
| + | ==== 05. Bonus: Birds ==== | ||
| + | |||
| + | Time for a more complex challenge. Be patient and don't speed through it. | ||
session/06.1530194926.txt.gz · Last modified: by Maria-Elena MIHĂILESCU (25616)
