Final Flashcards
(55 cards)
Machine Code
code computers execute.
Complier
translates high-level code to machine code.(C to assembly to machine code)
Assembly
human readable representation of machine code.(
– Intel syntax: <mnemonic> <dst> <src>
– AT&T: <mnemonic> <src> <dst>)</dst></src></mnemonic></src></dst></mnemonic>
Memory stores ….
both data and code.
little-endian architecture
least significant byte is stored first (ex. 0x112233, 0x33 0x22 0x11)
% is for…
register
$ is for…
immediate (constant value)
Number without a $ …
memory address
displacement formula is what?
displacement(base_reg, index_reg, scale)
result = base_reg + displacement + ( index_reg x scale)
Memory Layout
-kernel space
-stack
-memory mapping
-heap
-bss
-data
-text
Stack frame
-arg2
-arg1
-return address
- saved ebp
- local data
security goals
security goals
● Confidentiality
– The property that information is not made available
to unauthorized entities.
● Integrity
– The property that information is not altered or
destroyed in an unauthorized manner.
● Availability
– The property that information is accessible and
usable upon demand by an authorized entity.
● Authentication
– The act of confirming the identity of an entity
interacting with a system.
● Authorization
– The act of assigning rights and privileges to entities
interacting with a system.
● Non-repudiation
– The ability to associate actions or changes to a
unique entity.
Jmp + call
Jump to call, calls shell code which will push address on to stack, pop address into register
Why can’t we use zero bytes?
string processing functions will stop copying shell code if it encounters 0x00
What to do if zero bytes is in shell code?
- use alternative instructions
-or encode/restructure data
what does the byte for Nop?
\x90
Nop Sled
Instruction that does nothing, the CPU Jumps to the next Nop until shell code is hit.
Shell code injection payload
1.NOP SLED
2. Shell Code
3.Return Address
PLT and GOT
PLT (Procedure Linkage Table) jumps to the address
where a function was previously called and saved in GOT(Global Offset Table)
Memory Corruption
Go beyond memory bounds.
2) Do something malicious.
a) Hijack the execution flow.
b) Overwrite sensitive data.
c) Overread sensitive data.
Human defenses for Memory Corruption prevent from happening in the first place
-Input Validation
- Use safer functions (strncpy instead of strcpy)
- Use memory safe languages
- write better code
Shell injection steps
1)Run out of bounds.
2)Inject malicious code.
3)Overwrite control fields.
4)Guess important addresses.
Non Executable Memory and example
HARDWARE DEFENSE
If an attacker injects malicious code (shellcode) into those regions — like the stack or heap — the CPU will refuse to execute it and throw a segmentation fault (crash).
Ex. NX, DEP, XD
Return-to-libc
Execute existing functions with arguments
you choose.
libc is an attractive target.
– Powerful functions: system(), execve().
– Linked by most programs.
✅ It bypasses NX (Non-Executable) memory protections
✅ Because you’re calling code that already exists in memory
❌ It still requires control over the return address