Stack Attacks Flashcards

1
Q

In 64 bit where are the arguments for a function past?

A

The first 6 go into registers, after that they go into the stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

In 32 bit, where are the arguments for a function past?

A

The stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name the 6 registers in order that function arguments are passed into in x64

A

RDI
RSI
RDX
RCX
R8
R9

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which registers are function results returned in?

A

RAX and RDX

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the RAX register?

A

The accumulator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the RIP register?

A

The instruction point

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the RSP register point to?

A

The top of the stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the RBP register point to?

A

The bottom of the stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which registers are floating point function arguments pass into?

A

XMM0 to XMM7

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe what happens in memory when a function is called?

A

Arguments are put into registers
The function updates the RSP and RBP values to make new stack space
The old instruction pointer is pushed onto the stack
The old RBP is pushed onto the stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a buffer overflow attack?

A

When you write data that is large than the size of a buffer into a buffer, causing it to overflow and overwrite the old instruction pointer. Allowing you to change where the program resumes from after the function finishes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does the NX-bit defend against buffer overflow attacks?

A

The NX-bit provides a hardware distinction between the text and the stack. Code should only be in the text, and never the stack. If the instruction pointer ever points to the stack it will crash.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does address space layout randomisation (ASLR) protect against buffer overflow attacks?

A

ASLR adds a random offset to the stack and code bases each time a program runs. This makes it harder for an attacker to know the address of particular pieces of code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does do stack canaries protect against buffer overflow attacks?

A

A stack canary is a random value from the heap that is written to the base of the stack. When the function finishes the value on stack is compared to the value on the heap, if they are different the program crashes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is use after free?

A

This is when a memory address is freed by a program and then the program accesses the address later. This allows another program to gain control of the memory address and change the value stored there.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is double free?

A

When the same memory address is freed twice, which means it will be reallocated twice. Which means 2 variables later in the program may point to the same address.

16
Q

Where do canaries go on the stack?

A

Before the old stack base pointer and instruction pointer

17
Q

What is a format string vulnerability?

A

There is no check in the number of % signs in a string inputted by the user. You can then input a string with many %p to get register values and values from the stack.

18
Q

What is a return to libc attack?

A

The standard c library is almost always loaded. It contains many useful functions that can be pointed to, such as system, that allows you to run any command.

19
Q

In x64 calls to libc what must you remember?

A

The RSP must end with 0

20
Q

What is a ROP attack?

A

When you chain together instruction pointer values in the stack that point to single instructions in the text to allow arbitrary code execution.