Basic Assembly Flashcards

SLAE videos 8-12 + additional reading.

1
Q

What is NASM?

A

NASM and LD are used for linking and assembling of binaries.

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

How do system calls work?

A

During program execution, a system call may be used for tasks such as printing text to the console. The IA-32 mechanism for invoking system calls is int 0x80, at which point the system call handlers are referenced by the list of interrupt handlers associated with the program.

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

Where are system calls defined?

A

/usr/include/i386-linux-gnu/asm/unistd_32.h

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

Invoking System Call with 0x80

A

EAX - System Call Number (e.g. 4 for write to screen)
EBX - First Argument
ECX - Second Argument (Hello World string)
EDX - Third Argument
ESI - Fourth Argument
EDI - Fifth Argument

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

Stepping through Assembly files

A

Start by setting a breakpoint on the ‘_start’ element of code.

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

What are the fundamental data types?

A
Byte - 8 bits
Word - 16 bits
Double Word - 32 bits
Quad Word - 64 bits
Double Quad Word - 128 bits
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Signed and Unsigned?

A

Unsigned - all 32 bits are dedicated to storing the value

Signed - 31 bits are dedicated to storing the value, with the last bit designating the sign (+ or -).

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

Declare Uninitialized Data

A

db

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

Special Tokens

A

$ - evaluates to current line

$$ - evaluates to the beginning of current section

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

Figuring out the startpoint of a binary

A

shell readelf -h [BINARY_NAME]

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

Variable information

A

info variables

x/xb [VARIABLE_ADDRESS]
x/xb &[VARIABLE_NAME]

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

Instruction breakdown

A

Instructions may be broken down into Labels, Instructions and Operands.

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

MOV instruction

A

The most common instruction in ASM. Responsible for moving data in the following ways:

  • Between registers
  • Memory to Register and Register to Memory
  • Immediate Data to Register
  • Immediate Data to Memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

LEA instruction

A

Load Effective Address - load pointer values

  • LEA EAX, [label] (loads the pointer inside EAX.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

XCHG instruction

A

Exchanges (swaps) values

  • XCHG Register, Register
  • XCHG Register, Memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

gdb hooking

A

GDB to complete commands as you step through a program. For example:

define hook-stop

>print/x $eax
>print/x $ebx
>print/x $ecx
>print/x $edx
>x/8xb &sample
>disassemble $eip,+10
>end

The above hook prints the contents of the eax, ebx, ecx and edx registers, the contents of sample, and disassemble the program from the current $eip value (current instruction) for the next 10 instructions.

17
Q

Displaying Values after runs

A

display /x [REGISTER/MEMORY]

and then hook to disassmble eip:

define hook-stop
disassemble $eip,+10

18
Q

How does the Stack work?

A

The Stack is a LIFO - Last In First Out data structure. Goes from high memory to low memory. As the stack builds up, ESP points to lower and lower and lower addresses.

ESP - extended stack pointer - always points to the top of the stack.

PUSH instruction (to push 32-bit values to the top of the stack) automatically pushes values to the top of the stack and adjusts ESP accordingly.

POP instruction removes the value from the top of the stack, and automatically adjusts ESP accordingly.