Network & Security Flashcards

Revision for the Network and Security Module

1
Q

7

What is Computer Security?

A

Correctnes and Efficient algorithms against an Attacker

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

How can data we send over wifi be intercepted or stolen?

A
  • Data is sent over wifi is transmitted through radiowaves
  • Someone with a radio reciever or radio can retrieve and steal and catch this data.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What helps protect your data over the Wifi?

A

Making sure it is encrytped

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

What do we safeguard?

A

Decide on Assests : Information or Infrastructure:
- Sensitive Data
- Control Systems
- Hardware Devices

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

How do you safegaurd?

A
  • Security goal
  • Estimate impacts of attacks
  • Design mitigation
  • Analyse system
  • Spot Vulnerabilities
  • Build Protection
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Information Security Aims:

A
  • Confidentiality: Attacker should not retrieve any info
  • Integrity & Authenticity: Received data is authentic & sender is genuine
  • Avaliabilty: Data should be accessible on demand
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Information Security

Who are Potential Attackers?

A

ANYONE & EVERYONE
-Hackers: Potentially learning by running known attacks, exploting vunlnerabilities.
-Criminals: Take control of computers via bugs in software. Phising attacks or Denial of Service (DoS Attacks)
-Governments: Extreme computing powers. control on resources (wiretaps)
-Business House like ISPS Spying to sell your data

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

What are the Known Attacks?

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

Examples of Ransomware:

A
  • Malware: Trojan disguised as legitimate file
  • Malware encrypted data on computer and ask for payments in bitcoin

**REAL LIFE **
- Wannacry 2017 move automatically via unpatched vulnerablities in Microsoft Windows
- Widespread impacts, NHS & Nissan among affected

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

Examples of Phising:

A
  • Emails pretneding to be from Known people
  • Emails ask for username & password
  • Emails ask for software instillation (includes word macros)
  • Install malware to spread within networks and downloads further malware
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Unix Commands & Shell Scripts

What are Shell Commands?

A

Operations on Files

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

Unix Commands & Shell Scripts

Why do we Utilise OS Commands?

A

Potenitally Faster

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

What is Batch Proecessing?

A

Sequentially Running Programs

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

Modular Arithmetic

How to do simplify modular arithmetic for large (NON POWER) numbers

A
  • Split it up by adding 2 easier number that make the original number
  • Split it up by multiplying 2 easier number that make the original number
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Modular Arithmetic

What is the rule for adding 2 easy numbers?

A

x = (t1)z + r1 => x mod z = r1
y = (t2)x + r2 => y mod z = r2

p = x + y
p mod z =
(x + y) mod z = (r1 + r2) mod z

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

Modular Arthmetic

Why do you need to do mod z in (r1 + r2) mod z & (r1 * r2) mod z?

A

-Because r1+r2 can be larger than z
- mod make the remainder smaller than z

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

Modular Arthimetic

What is the simple rule modular arithmetic for addition?

A

x + y mod z = (x mod z + y mod z ) mod z

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

What is the simple rule modular arithmetic for multiplication?

A

(x * y) mod z = (x mod z * y mod z) mod z

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

Modular Arithmetic

What is the algorithm for power mod?

where time complexity = n

A
product = 1
for i = 1 to n
product = (prodcut * 2) mod m
end for

m is the value you want to mod by

if n = 2^10 it will take 2^10

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

Modular Arithmetic

What’s a better algorithm where T(n) = 2T(n/2) + 1

A
find(n)
product = 1
product = (find(n/2) * find(n/2)) mod m
return product

m is the value you want to mod by

T(n) = 2T(n/2)+ 1 => log n + something

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

Modular Arithmetic

What algorithm gives Total Complexity of log n?

A
find(n)
product = 1
product = (find(n/2))^2 mod m
return product 

**IN ORDER TO COMPUTE **
2 ^n mod 57
I need to compute log n many powers
So Total Complexity ceil (log n)

This gets rid of the extra find call as you just get the same num twice

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

Linux Shell

If you type echo "Hello, welcome to $SHELL" what is the output, in a Linux Shell?

A
Hello, welcome to /bin/bash
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Shell Commands

How to create a directories?

A

FORMAT: mkdir directoryname

EXAMPLE CODE:

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

Shell Commands

How to create Multiple Directories?

Only 2 Directories

A

FORMAT: mkdir directoryname1 direcotryname2

EXAMPLE CODE:

mkdir folder1 folder2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
# Shell Commands How to make n directories? | 2+ Directories
**FORMAT:** mkdir directoryname1{0..n} ***EXAMPLE CODE:*** *Make 10 directories * ``` mkdir folder1{0..9} ```
26
# Shell Commands what does `cd ` do?
Moves inside the directory of the address given *EXAMPLE:* ``` cd folder1 // Moves into folder1 ```
27
# Shell Commands What does `cd ..` do?
Moves back to the parent directory
28
# Shell Commands What are the two commands to find the content of a directory?
**`ls `** - show all the files and folders in the directory **`ls -l`** - shows the same as ls with extra info *(user, date and time)*
29
# Shell Commands What is the command to find all the content of a directory including hidden files?
**`ls -a`** - Just **`ls`** with hidden files For more details use **`ls -la`** - Same as **`ls -l`** with hidden files
30
# Shell Commands What feature do hidden files have?
A period in the front of / start of their name | example : .filename or (1+ periods (.))
31
# Shell Commands How to Create a File in the Shell?
``` echo "hello" > test ``` - puts "hello" in test - '>' means to write into file
32
# Shell Commands How to Append to a File?
``` echo "Welcome to the shell" >> test ``` - appends "Welcome to the shell" - '>>' means to append into the file
33
# Shell Command How to View the content in a file?
``` cat test ``` - outputs all the content in the test file - Main purpose of this is to concatenate files
34
# Shell Commands What does the command `less` allow?
- allows you to view the file one page at a time **EXAMPLE CODE:** ```less test ```
35
# Shell Command What can you use to get n line from the file?
``` head -n test ``` - gets the first n lines from the test file
36
# Shell Command What is the code to Copy Files in a new directory in the same location?
**FORMAT:** ```cp ``` **EXAMPLE CODE:** ```cp test copiedtest``` - copies all the content in test to copiedtest
37
# Shell Command How to copy files into a directory in another location?
- You need to use the path of the different directory to copy the file from the current one **EXAMPLE CODE:** ``` cp test ./folder1/copiedtest ```
38
# Shell Commands What is the format for copying a file to/from remote computer?
`scp [[user]@source:]sourcefile [[user]@destination:]destinationfile`
39
# Shell Commander What are the 3 Classes that the OS keeps track of permission access rights for?
- Owner - Group - Others
40
# Shell Commander Does Linux consider everything a file?
Yes
41
# Shell Commander What are the 3 permissions types for each class of user?
- read - write - execute
42
# Shell Commander What do File Permissions Describe?
- Describes who, which & what activites could be performed with a specific file - Each file has an owner & a group
43
# Access Control What does Access Control Allow?
Authorised users only have access to what they need
44
# Access Control What are the components of the Access Control Model?
- Principal *(Subject e.g. user/program)* - Action *(e.g. read)* - Resource Monitor - Object *(resource e.g. file)*
45
# Access Control Describe the Access Control Model?
- Principal performs an action on an object - Resource Monitor checks if the action is legal or NOT
46
# Access Control Give an Example of Principal:
Password Program
47
# Access Control Give an Example of Action:
Reading
48
# Access Control Give an Example of Object:
Password FIle
49
# Access Control Give an Example of Resource Monitor:
Operating System
50
# Access Control What is the Access Control Matrix?
Who is allowed to do what is captured in this matrix - What permission do each principal have on each Object
51
# Access Controls What does the permission `x` mean?
execute
52
# Access Control What does the permission `r` mean?
read
53
# Access Control What does the permission `w` mean?
write
54
# Access Control What limits does the Matrix model have?
System Admin can bypass these permission and re-write the os to gain access to specific files - Very large matrix can be difficult to maintain - Corrupted Matrix, all control is lost
55
# Access Control Summary of Access Control Matrix:
- Matric of all principals & objects - Matrix entries describe the permissions - Problem: Maintaining such a matric can be difficult*** (VERY LARGE)*** - If Matrix gets corrupted then all control is lost
56
# Access Control What is the Access Control List (ACL)?
- Don't want to store one massove matrix - Instead we store each column of the matrix with the object it refers to
57
# Access Control Give an example of ALC:
(Account data, [(sam,r),(Bob,r),(Account Program, rw)]) (object,[principal a actions, pricipal b actions]) actions can be a combo of {r,w,x}
58
# Access Control What are Permissions and give an exmaple of what it looks like in Unix Access Control List??
Permission different users have on the file e.g.```-rw-r----- ```
59
# Access Control What is the Link counter in Unix Access Control List & Give example?
File can appear with a different name in different directories. The - **- Link Counter Identitfies this Frequency ** e.g.```1 ``` (Can be any number)
60
# Access Control What is Owner in Unix Access Control List & example?
Owner of the Files e.g.```root OR Bob ```
61
# Access Control What is Size in in Unix Access Control List & example?
How big the file is ```e.g. 2150 ```
62
# Access Control What is Group in in Unix Access Control List & example?
Each user can belong to several groups & a file to only one group ```e.g. Staff ```
63
# Access Control What is File name in in Unix Access Control List & example?
Name of the file ```e.g. text.txt ```
64
# Access Control What is Date in in Unix Access Control List & example?
Indicates when file was last modifed ```e.g. 26 Jan 12:45 ```
65
# Access Control Give an example of Unix Access Control List:
``` |-rw-r-----|1|bob|staff|2150|26 Jan 12:45|test.txt| ```
66
# Access Control Give an example of UNIX File Permissions:
**```drwxrwxrwx ```** - 1st char `(d)` represents ** File Type** - char 2 -4 `(rwx)` represent **Owner Permissions** - char 5-7 `(rwx)` represent **Group Permissions** - char 8-10 `(rwx)` represent **Other Permissions** *(Anyone else)*
67
# Access Control (ACL) Give all the File Types in File Permission :
- `-` => file - `d` => directory - `b/c` => device file
68
# Access Control (ACL) Give all the permissions in File Permission :
- `r` => Read Permission - `w` => Write Permission - `x` => Execute Permission - `-` => No Permissions
69
# Access Control What is Access Control for directories?
- `r`: Read Only for directory contents - `x`: permission to traverse *e.g. switch to, run * - **NO** `x`: Can't run away commands inside the directory - **NO** `r`: Can't list files in the directory
70
# Access Control What is Access Control for Programs?
```e.g: -r-sr-xr-x 1 root wheel 70352 19 Jun 2009 passwd ``` - `x` => Controls who can run a program* (Above example anyone)* - `s` => Indicates that the program runs with permission of its owner* (Root/Owner shoulf be allowed to write to the file)*
71
# Access Control What are the Different User Identifiers (uids)?
- **Real uid (ruid)** - **Effective uid (euid)** - **File System uid (fsuid)** - **Saved User uid (suid)**
72
# Access Control What is **Real uid (ruid)**?
Owner of proccess (*Whoever starts the program*)
73
What is **Effective uid (euid)**?
Used for access checks (*except filesystem*)
74
What is **File System uid (fsuid)**?
Used for access checks & ownership of files (*equal to euid*)
75
What is **Saved User uid (suid)**?
**euid** changed, old **euid** is saved as **suid** - unprivalleged processes may change **euid** only to **ruid** or **suid**
76
# Access Control What do **uids** allow?
Provides flexibility for granting Higher Privileges Temporarily **Example:** - Start as root (*bind to prots < 1024*) - Set **ruid, euid & suid** to unprivileged values - Cannot gain root privileges afterwards Process run as privileged user may set euid to priviledged value then execute non-privileged operations & gain roof privileges afterwards
77
# Access Control What are security Issues with granting Higher Privleges?
- User can run programs with more privileges - Mistakes in program we could use it to do root actions - *Particular Problems:* **Race Condition in code** e.g. `if can_access file then peform_operations on file` - Make sure processes have a low level as possible
78
# Access Control How should passwords be stored?
- **NOT** in Cleat text - Hash the password and store that
79
# Access Control What is wrong with storing password in Clear Text?
Anyone with access to the sytem or has used access can see all the passwords
80
# Access Control What can you do for further Security of Passwords?
- Store pair (salt, Hash) - Hash is the hash of salt & password - Same password for 2 users give rise to different entries in password file - Makes cracking passwords harder *(Crack one user password, won't help with the other users )*
81
# Access Control What is Salt?
Salt is a random bitstring
82
# Access Control How does Windows Hash Passwords?
- **Stores hashes in: system32/config/SAM** - **Need admin level to read** - **Locked & Encrypted with a key, based on other key values ** *(Adds no real security because if you are admin then you need to find out what that key is and decrypt it with a key you can read)*
83
# Access Control What are the uses for Password Hashes in Windows Domain?
- Password hashes are used to authenticate users on host in the domain - Passwords hashes are cached to avoid asking for the password
84
# Access Control What are the devestating Attacks Password hashes give rise too? | **pass the hash**
- Obtain user credential for one host in the domain *(Phising)* - Exploit vulnerability to become local admin - Install process which waits for domain admin to login - Extract cached hash for domain admin - Login as domain admin - Has defence mechanism, but painful to use
85
# Access Control Why is SSH much better in protecting against **pass-the-hash**?
- Public key on untrusted machine *Attacker can get this but cannot get private key* - Private key on trusted machine *Only used by domain admin*
86
# Access Control How to get windows password Hashes?
- Boot into Linux - Get SAM file *Very difficult to defend against attack*
87
# Access Control Give examples of password crackers?
**John the Ripper:** - Most common brute force cracker - open source **Hashcat:** - Claims to be the fastest/best **Ohacrack:** - State of the art, free, rainbow table software
88
# Access Control How are passwords captured?
**Phishing:** Username & password captured by attackers via malicious links *e.g. Fake bank email* - used to login & then for attacks *Ransomware, theft of details, IP...*
89
# Access Control What are the best protection against passwords capture?
**Multi-factor authentication *Besides Username & Password*** - SMS codes - One-time passwords - App approval **SSH with public key authentication ONLY protects against phishing** (*As long as private key is not given out, there is not much the attacker can do*)
90
# Access Control What is Password Injection?
- Want access to the system without cracking passwords - Have access to hard disk - Add your own account ot replace the hash wiht one you know
91
# Access Control What is better security that will help prevent Password injection?
**BIOS:** - Set a password in BIOS to stop the computer booting from anything but the hard disk - Very hard to brute force BIOS *(Cannot Automate)* - *Workaround*: Remove the hard disk from the computer or reset BIOS password
92
# Access Control How to reset BIOS password?
**Opening the Box**: - Applying Jumpers - Removing the battery
93
# Access Control What is the Best Security that will not be affected in any BIOS workarounds?
- Encrypt important files - Whole disk Encryption: - Encrypt the whole drive (*Resetting BIOS psswrd won't work*) - Key can be brute forced - Not safe if the computer is in sleep mode - E.g. *BitLocker (Windows) , FIlevault (IOS) , Luks (Linux)*
94
# Hashes & Encryption What are Hashes?
**- Hash of any message is a short string generated from that message - Hash of a message always the same (*Deterministic*) - Small Change = New Hash - Very Hard to go from Hash to message - Very Unlikely 2 message have the same hash ** -*Cannot say impossible due to pigeonhole principal* - *But it is computationally Infeasible to fins 2 strings that map to same hash*
95
# Hashes & Encryption What is Pigeon Hole Principal?
If you are using a hash function that generates 10 possible hash values (pigeonholes) but have 11 input keys (pigeons), at least one hash value will be shared by two or more input keys. ## Footnote It states that if you place more items into fewer containers than the number of items, at least one container must hold more than one item.
96
# Hashing & Encryption What are the uses of Hashing?
- Verification of download message - Tying parts of a message together (*Hash whole Message*) - Hash the message, then sign the hash *Electronic signature* - Reduces file size & not as computationally expensive as public key encryption - Protect Passwords: - store hash , not passwords - Attacker can get access, but passwords are not clear)
97
# Hashing & Encryption Give the types of Hash Attacks
- Collision Attack - Preimage Attack - Prefix Collision Attack
98
# Hashing & Encryption What is Preimage Attack?
FInd a message for a given hash : VERY HARD - Attacker gets to hash cannot go back and find original password OR Given a random y ∈ {0,1}^n, if the adversary could find a message m such that H(m) = y **the adversary can produce a message 𝑚 that, when hashed by H, results in exactly the binary string 𝑦*
99
# Hashing & Encryption What is an Adversary?
an entity (often an attacker or an opponent) that tries to break or exploit a system.
100
# Hashing & Encryption What does it mean if there is a successful Preimage attack on a Hash?
It would indicate a weakness in the hash function.
101
# Hashing & Encryption What is Collision Attack?
Adversary could find distinct messages m & m' such that H(m) = H(m') *Represents collsions*
102
# Hashing & Encyption What problem does Collision Attack present?
- Weakness beacuse it means that the hash fucntion is not unique for the same hash - **E.g of these Weaknesses:** - Digital Signatures can be forged using a different message - File Integrity/ password Storage, mean differnt inputs could be viewed as identical
103
# Hashing & Encryption What is Prefix Collision Attack?
A collsion where the attacker can pick a prefix for the message - Easier for the attacker *(can pick a prefix for the message & produce a hash, which is a hash only for the prefix of the message )* - Imagine beginning of the message contains all the impritant info then this attack is enough for the attacker.
104
# Hashing & Encryption How many people do you need to ask before 2 people have the same Birthday with a probablity of 0.5? | Birthday Paradox
- 23 people gives (23 * 22)/ 2 = 253 pairs - Probablilty 2 people have different Birthday is 364/365 - Probability is (364/365)^253 = 0.4995
105
# Hashing & Encryption What does H : {0,1} * => {0,1}^n mean?
- Hash Function (H) is random - ∀x ∈ {0,1} * ∀y ∈ {0,1}^n - Pr[H(x) = y] = (1/2^n) - Every point was equally there
106
# Hashing & Encryption What is the Hash Algorithm & Explain it?
**ALGORITHM:** x = 0^n while (collision not found){ compute H(x) & store check if collison else x ++ } **Explanation:** Take a number, hash it and store it then repeat it for the next number unto collision found
107
# Hashing & Collison What is the probability of getting a collision at collision(1)?
Pr[collision(1)] = 0
108
# Hashing & Collison What is the probability of getting a collision at collision(2)?
Pr[collison(2)|¬collision(1)] = 2/(2^n)
109
# Hashing & Collison What is the probability of getting a collision at collision(n)?
Pr[collison(n)|¬collision(1) ||...|| ¬collision(n-1)] = (i-1)/(2^n)
110
# Hashing & Collison
111
# Hashing & Collison | Π
112
# Hashing & Collison
113
# Hashing & Collison
114
# Hashing & Collison
115
# Hashing & Collison
116
# Symmetric Key Cryptography What is the Total Computation for 1 Year?
2^(82)
117
# Symmetric Key Cryptography What is Cryptography?
Describes how to transfer messages between particapants without anyone else being able to read/modify them
118
# Symmetric Key Cryptography What is **code** & give examples?
**Any way to represent data** E.g ASCII , HEX , MORSE CODE
119
# Symmetric Key Cryptography What is a **Cipher**?
Code where it is difficult to derive data from
120
# Symmetric Key Cryptography What are features of Cipher?
- Always uses a key - Data for cipher is **Plaintext** - Encoded Plaintext is **Ciphertext**
121
# Symmetric Key Cryptography What is Encryption?
Function From Plaintext to Ciphertext
122
# Symmetric Key Cryptography What is Decryption?
Function From Ciphertext to Plaintext
123
# Symmetric Key Cryptography What is HEX?
**- Chars from 0 to F - Encode 4 Bits - Easiest way to write binary as text** *- Just use Binary values of 0-14 to represent numbers. i.e 34 would be 0011 0100 (Binary 3 & 4)*
124
# Symmetric Key Cryptography Give 27 as Hex?
0010 0011
125
# Symmetric Key Cryptography What is a Ceaser Cipher?
- One of the oldest Ciphers - Shifts every char in the plaintext 3 spaces to the right (in the alphabet)
126
# Symmetric Key Cryptography Why is the Ceaser Cipher easy to Break?
- As soon as you know the scheme you can decrypt the message. - This is due to the Algorithms to decrypt & encrypt are public.
127
# Symmetric Key Cryptography What is Kerckhoff's Principal:
Cipher should be secure even if the attacker knows everything about it apart from the key. Rule 2: System should not require secrecy
128
# Symmetric Key Cryptography What is the problem with have n rotations Ceaser Cipher and give a better modle?
- 26 rotations, therefore 26 possible key, so you can try them all. **Better Scheme:** - Replace each letter with anothe - thus 26! = 4 * 10^(26) possible keys
129
# Symmetric Key Cryptography How can the Ceaser cipher were it replaces each letter with another be broken?
-**Cannot be broken** by Brute Force - Replacing each letter with another can be broken by **Frquency Analysis**
130
# Symmetric Key Cryptography What does Frequency Analysis count the number of?
- Each Symbol - Each pair of Symbol Then it draws a conclusion
131
# Symmetric Key Cryptography How does Frequency Analysis work?
- Use the most frequently used character , e - Then do the analysis - the most frequent char is what e has been ecrypted to - Find the difference between e and new char and use that difference for the other chars. - If makes no sense use the next most frequent chars
132
# Symmetric Key Cryptography What is XOR?
**Binary Addition MOD 2** - XOR on bit string of same length defined by applying XOR to corresponfing bitd
133
# Symmetric Key Cryptography Solve the following: 1) 0⊕0 2) 1⊕0 3) 0⊕1 4) 1⊕1
1) 0 2) 1 3) 1 4) 0
134
# Symmetric Key Cryptography What is XOR properties?
**-Associative & Commutative - All bit string M , M⊕0 = M - All bit string M , M⊕M = 0 ** *- Where 0 is bit string of 0's of the appropriate length*
135
# Symmetric Key Cryptography What are **One Time Pads**?
Each CHAR is shifted by random offset
136
# Symmetric Key Cryptography How does one time pads work?
- Keys are long as message - Add/XOR key & message - For each char a random is chosen
137
# Symmetric Key Cryptography What is the formula for creating the Cipher for One Time Pad?
**Cipher = Message + Key** -*Mod 26 the value to get the correct one *
138
# Symmetric Key Cryptography What is the formula for finding out the message given Cipher and key?
**Message = Cipher - Key** - *if it negative +26*
139
# Symmetric Key Cryptography What are the problems with One TIme Pads?
- Key needs to be as long as the message - Key must only be used once
140
# Symmetric Key Cryptography Is One Time Pad Perfect Encryption?
Yes, but one when the key is Random
141
# Symmetric Key Cryptography What is Perfect Encryption?
You Learn nothing about plaintext grom ciphertext
142
# Symmetric Key Cryptography What is the Theorem of Perfect Encryption?
**Given any ciphertext of certain length withiut knowing the key the probability of ciphertext being the encryption of a plaintext of same length is the same for all plaintexts of the same length as ciphertext.**
143
# Symmetric Key Cryptography What are Block Ciphers? | More Detail
- Modern Ciphers work on blocks of plaintext, not just single symbol - Key controls the exact nature permutaions & substitution - Made up of a series of permutations & substitution repeated on each block
144
# Symmetric Key Cryptography What is Block Cipher? | Simple
Takes 128-bit & Returns 128-bit - Encrypts n-bit block via a randomly chosen permutation
145
# Symmetric Key Cryptography What is a Stream Cipher?
- Small msg can give a cipher as long as you want - Genreate a random looking bit-stream from a smaller key and XOR the message with the stream
146
# Symmetric Key Cryptography What is AES (Advanced Encryption Standard)?
- Works on Blcoks of 128-bit - Generates 10 round keys from a single 128-bit key
147
# Symmetric Key Cryptography How is 128-bits represented?
4 * 4 matrix - Where each element is a byte (8 bits) - 16 elements all together
148
# Symmetric Key Cryptography What is S-Box (SubBytes)?
- An Operation on byte using a finite field arithmetic - Has a Look up table - Picks a bit from one matrix and using the lookup table matches it to the corresponding value in the other matrix.
149
What is ShiftRows?
Move the : -2nd row 1 byte to the left - 3rd row 2 bytes - 4th row 3 bytes
150
# Symmetric Key Cryptography What is MixColumn?
Substitution of each column such that: (m1(x^3) + m2(x^2) + m3(x) + m4) * (3x^3 + x^2 + x + 2) mod (x^4 + 1) = b0(x^3) + b1(x^2) + b2(x) = b3 | mn are elemnts from matrix m and bn is outupt matrix
151
# Symmetric Key Cryptography What does Adding Round Key do?
-Applies XOR to the Block & the 128-bit round key *(generated by main key) *
152
# Symmetric Key Cryptography How Secure is AES?
- NO FORMAL PROOF - Best Know cyrptographic attack require 2^126 key guesses. - An improvement of factor 4 compared to 2^128 key guesses for brute force attack.
153
# Symmetric Key Cryptography What are the Side Channel Attacks?
- Measuring Power Consumption - Execution Time
154
# Symmetric Key Cryptography What the Key aspects of Security?
- Shuffle rows & colums to ensure small change in input causes very big output change - Requires at least one non linear operation on the data **(Given by SubByte Operation)**
155
# Symmetric Key Cryptography What is DES (DATA ENCRYPTION STANDARD)
- Previous Standard before AES - Designed by IBM in 70s - Before accepted, NSA adddes S-Boxes & fixed key length at 56 bits
156
# Symmetric Key Cryptography What are S-Boxes | DES
- Type of Substituion - Unknown why NSA added it - Thought to be a backdoor for NSA
157
# Symmetric Key Cryptography What is 3-DES?
-Triple DES, was a stop gap unit AES - Takes 3 keys (k1,k2,k3) - Expected to be good unitl 2030 (Computing power won't increase quickly) - Used in Bank card & RFID Chips - Setting the keys equal to each other you get DES.
158
# Symmetric Key Cryptography Explain 3 DES encryption:
**E{k1,k2,k3}(M) = E{k3}(E{K2}(E{k1}(M)))** - Encrypt M with K1 First - Then Decrypt with K2 - Then Encrypt with K3
159
# Symmetric Key Cryptography What is Padding ?
- Block Ciphers only work on fixed size blocks - If message isn't of the right block need to pad it - Reciever need to tell the difference between padding & message
160
# Symmetric Key Cryptography What is used as Padding?
PKCS 5 / PKCS 7
161
# Symmetric Key Cryptography Explain how PK5 / PK7 Work:
- 1 Byte of space write **01** - 2 Bytes of Space write **0202** - 3 Bytes of Space write **030303** *LEFT OVER BYTES* - If message goes to the end of the block add a new block of **16161616...** (*Message exactly fits the block*) ## Footnote If you have something that takes 5 bytes and block has 8 you need 3 bytes to fill it so use **030303** to fill it
162
# Symmetric Key Cryptography What is the block size for PKCS 5?
8 Byte Blocks
163
# Symmetric Key Cryptography What is the block size for PKCS 7?
16 Byte Blocks
164
# Symmetric Key Cryptography Give the Block Cipher Modes:
- Electronic Codebook Mode (ECB) - Cipher Block Chaning Mode (CBC) - Counter Mode (CTR)
165
# Symmetric Key Cryptography What is Electronic Codebook Mode (ECB)?
- Each block is encrypted indvidually - Encrypted blocks are assembled in the same order as plaintext blocks - Blocks are repeated in plaintext, revealed by Ciphertext
166
# Symmetric Key Cryptography What is CBC
- Each Block is XOR'd with previous one - Start with a random *Initialisation Vector* **IV** - Helps overcome relay attacks
167
# Symmetric Key Cryptography Give format of CBC Encryption
*Plaintext is B1,...,Bn. Ciphertext is C1,...,Cn Where:* - IV => RANDOM NUM (SET IN CLEAR) - C1 => Encrypt(B1 ⊕ IV) - C2 => Encrypt(B2 ⊕ C1) **...** - Cn => Encrypt(Bn ⊕ C(n-1))
168
# Symmetric Key Cryptography Give format of CBC Decryption:
*Recive IV & Ciphertext. Plaintext is B1,..,Bn Where:* - B1 = decrypt(C1) ⊕ IV - B2 = decrypt(C2) ⊕ C1 **...** - B3 = decrypt(Cn) ⊕ C(n-1)
169
# Symmetric Key Cryptography What is Probabilistic Encryption?
Schemes use random Elements to make every encryption different
170
# Symmetric Key Cryptography What is an Example of a Good Probabilistic Encryption & Benefit ?
CBC with **RANDOM IV** is a good way to make encryption probabilistic *Benefit* - Using both allows us to encrypt same message & key without attacker realising
171
# Symmetric Key Cryptography How can IV be Misused?
By Choosing IV as it can have devastating Attacks - IV must be random and unique for each encrypted block
172
# Symmetric Key Cryptography What happend in ZEROLOGON?
- IV was set as 0 - Encryption on All-Zero Plaintext will provide All-Zero Ciphertext - Can be used to bypass Authentication completely & set domain controller bypass - Only requires network access to domain controller (*Avaliable from any machine*)
173
# Symmetric Key Cryptography What is Counter Mode (CTR)
Mode used with block ciphers like AES to turn them into a stream cipher. It works by encrypting a counter value and XOR-ing it with the plaintext.
174
# Symmetric Key Cryptography Give the format of CTR Encryption:
*Plaintext: B1,...,Bn. IV => RANDOM (Set In Clear)* - C1 = B1 ⊕ encrypt(IV) - C2 = B2 ⊕ encrypt(IV+1) **...** - Cn = Bn ⊕ encrypt(IV + (n-1)) COUNTER = NONCE + COUNTER | IV / Counter are interchangable
175
# Symmetric Key Cryptography What is XOR symbol
176
# Symmetric Key Cryptography What Happens if the Message > 128 bits?
**- Break the message into Chunks of 128** - m0 = m1 , so C0 = C1 - Inputs are the same then the outputs are the same therefore the message may still be visible & not encrypted fully. ## Footnote Mode is ECB : Parallel Applications of Block Cipher
177
# Symmetric Key Cryptography Explain the Counter Mode:
- Same messages map to diiferent ciphertext - m0 = m1 but C0 != C1 - as Counter0 != Counter1 - As we XOR m0 & m1 with different Counter values the ciphertext will be different
178
# Symmetric Key Cryptography What is a Caution for CTR?
**Ciphertexts are malleable** - If you flip bit of C0 to make C0' then C0'||C1 is a ciphertext of message m0'm1 where m0' is m0 with last bit flipped (GET DIFFERENT MESSAGE BUT CHANGE IS CIPHERTEXT & PLAINTEXT IS THE SAME)
179
# Symmetric Key Cryptography Summaries AES:
-** Encryption (128/256 bit block) & Decryption ** with a specific key maps any 128-bit block to a 128-bit block - Decrypt can run on any block ( just NOT encryption)
180
# Symmetric Key Cryptography What is the Know Plaintext Attacks?
**I know the plaintext, I can change the CTR encrypted Message**
181
# Symmetric Key Cryptography Give an Example of *Known Plaintext Attacks*
*I Know Enc{CTR}(M1) & M1 I can make a ciphertext that decrypts to any message* **NEW CIPHERTEXT:** - Enc{CTR}(M1) ⊕ (M1 ⊕ M2) **Decrypt It:** - Dec{CTR} (Enc{CTR}(M1) ⊕ (M1 ⊕ M2)) - = Dec{CTR} ((Enc(N||Ctr) ⊕ (M1)) ⊕ (M1 ⊕ M2)) - = Enc(N||Ctr) ⊕ ((Enc(N||Ctr) ⊕ (M1)) ⊕ (M1 ⊕ M2)) - = M2 ## Footnote N = Nonce Ctr = Counter M1 = Message1 M2 = Message 2 Dec = Decrypt Enc = Encrypt CTR = Countrer Mode
182
# Symmetric Key Cryptography & MACs What are Authenticated Encryption Modes?
- They stop Plaintext Attacks - Can ONLY form valid ciphertext if you know the key - Common way to do this is by Adding MAC to ciphertext
183
# Symmetric Key Cryptography & MACs Give an Example of Authenticated Encryption Modes?
CCM mode Encryption
184
# Symmetric Key Cryptography & MACs Explain CCM mode Encryption process
- 1st calculates an AES CBC-MAC on Data - Encrypts message followed by MAC using same key & CTR mode - Proven to be secure * fully defined as RFC 3610*
185
# Message Authentication Codes What are MACs (Message Authentication Codes)?
**- Used for authentication** e.g. Alice & Bank share Key k Alice sends "Pay Bob £10" to bank, MAC{k} ("Pay Bob £10") MAC & k allows bank to authnticate the request | - NOT RELATED TO MAC ADDRESS
186
# Message Authentication Codes What are Possible Attack with MACs?
**LENGTH EXTENSION** - Adding data to MAC without knowing the key | IF ATTACKER DOESN'T HAVE SHARED KEY WON'T BE ABLE TO DO ANYTHING
187
# Message Authentication Codes How do we Make MAC?
- Making a CBC MAC: - Need to make it determininstic - Set IV to always be 0 - Keep the key - Only use last block of plaintext | LOOK AT NOTES FOR PICTURE / DIAGRAM ## Footnote CAN USE an Ineffcient hash function where we set the key to 0
188
# Message Authentication Codes How to go From Broken Hash to MAC?
Have a hash try and make a MAC by: **MAC{key}(M) = H (Key,M)** - Use the output from the previous block as the input for the next block until the last block which is final output | LOOK AT NOTES FOR IMAGE
189
# Message Authentication Codes What is the Problem with Broken Hash to MAC?
**- Can lead to Length Extension Attacks** *e.g.*: - Alice tells bank to "Pay Bob £10" - Adversary can easily add another step "Pay Eve £10" - Takes Output of "Pay Bob £10" as input & XORs it with "Pay Eve £10" & the encrypts it -*Bank is none the wiser to this attack when attacker adds/extend the length of MAC*
190
# Message Authentication Codes / TAGS How to Make a Tag?
Tag = MAC (key, message)
191
# Message Authentication Codes & Tags What are TAGS?
- Fixed length - They are generated alongside ciphertext to provide confidentiality + integrity - Decryption verifies the tag to detect tampering - Part of encrypted output
192
# Message Authentication Codes & Tags Can Adversary Generate a Valid Tag?
**Not without knowing the Key** - They can modify ciphertext but without valid Tag it will not change, as decryption would reject it.
193
# Public-Key Cryptography What are the 4 Objective / Direction Cryptography aim to achieve?
- **Confidentiality** - **Message Integrity** - **Sender Authentication** - **(soft) Sender Undenialbilty (NON-REPUDIATION)**
194
# Public-Key Cryptography What is Confidentiality?
Transmitted message should remain hidden to adversary
195
# Public-Key Cryptography What is Message Integrity?
Any modifications made by Adversary should be detected
196
# Public-Key Cryptography Where Sender Authentication?
Ensure sender of messages before accepting it
197
# Public-Key Cryptography What is (soft) Sender Undeniability?
Sender of a message should not be able to deny they sent a message
198
# Public-Key Cryptography What is Symmetic Key Cryptography?
- 2 Users hold Identical keys - Encryption / Decryption use the same keys - Message Authentication Keys must be used to indentify the MAC
199
# Public-Key Cryptography How are Symmetric Keys Shared?
Secret Communication to share it
200
# Public-Key Cryptography What are the main Issues with Symmetric Key Encryption?
- Every pair needs a separate key - Everyone needs n-1 many different key (one for each person) This is insufficent & Probibitively Expensive
201
# Public-Key Cryptography What is Private Key Cryptography?
- Each person has 2 keys: One Private & One Public - Keys are Asymmetric (Related but not identical) - Public Keys are Known to everyone - Private Keys are Secret
202
# Public-Key Cryptography Give an example of Public Key Encryption:
- Sender encrypts with reciever's public key - Reciever decrypts with their private key ## Footnote No one will be able to decrypt message even if they know the public key
203
# Public-Key Cryptography How many keys does Public Key Encryption need?
- No longer require pairwise distinct key - For secret communication amoung n people, we need n secret keys & n public keys
204
# Public-Key Cryptography How are Public Keys Authenticated?
- Signatures ## Footnote Receiver need to be convinced message is not tampered & was sent by correct sender
205
# Public-Key Cryptography How to check integrity?
We have signatures
206
# Public-Key Cryptography What are Public Key Signatures?
- Like Physical Signature: Public key signature a signer creates a signature message pair (*Signed Message*)
207
# Public-Key Cryptography How does a signing algorithm ensure that a signature is unforgeable?
- Signer uses sign Algorithms, for security the signature needs to be unforgeable - The sign Algorithms would take a Private key & message as input to make signed document
208
# Public-Key Cryptography How can the Signature / Signed Message be Authenticated?
- Authenticity can be verified by anyone - Use Verify Algorithm
209
# Public-Key Cryptography Explain the Verify Algorithm:
- Takes a public key of signer & signed message & Algo will accept or reject the input - Authenticated Signer the Algorithm will accept the inputs - Forger does not know the secret key, the Algorithm can reject it.
210
# Public-Key Cryptography What are the steps for Public Key Infrastructure?
- User registers to system & obtain public/private key pair 1) Register with Registration Authority 2) Registration Authority requests certificate Authority to generate public/private key pair 3) Certificate Authority provide user a certificate Authority for public key, with public & private key 4) Certifcate Authority also put user certificate of public key in the directory (PUBLIC)
211
# Public-Key Cryptography Give an Example of 2 User Communication:
1) User A obtians & verfies User B's public key from the public directory 2) Then User A sends User B a meesage & encrypts it using verified public key obtianed
212
# Public-Key Cryptography What is the Requirement for the Public Key Infrastructure?
Trusted 3rd Party {Certificate Authority}
213
# Public-Key Cryptography How to Secure Key Exchange?
User needs to agree on a secret key
214
# Public-Key Cryptography What is the MultiRound Solution?
- User needs to transfer a set of keys in the physical world | Solution: Postal Service
215
# Public-Key Cryptography What is the idea of MultiRound solution steps?
1) User A obtains a 2 sided lockbox 2) User A puts secret key in the box & lock using their own lock & key 3) User A ships box to User B 4) User B recives box with User A's lock 5) User B adds their own lock & key 6) User B sends it back to User A, who takes the lock and sends it back to User B 7) User B opens their lock and takes the shared key
216
# Public-Key Cryptography Why is the lockbox solution secure?
- Secure if the padlocks on box cannot be opened without the key - Not impossible, just assume it difficult to do so - Assumption: Anyone carrying box has no intrest in opening it
217
# Public-Key Cryptography What are the parameter in the Deffie Hellman (DH) Key Exchange Protocal?
- *p*=>a prime - *g*=>an integer, *g* < *p* , such that gcd(*g*,*p*-1) = 1 | gcd => greatest common divisor A.K.A HCF
218
# Public-Key Cryptography How does DH protcol Work?
1) User A & B publicly announce *g* & *p* 2) User A & B choose their corresponding Secret (e.g. a/b∈R {2,...,*p*-2}) 3) User A computes X = *g*^a mod *p* User B computes Y = *g*^b mod *p* 4) User A sends X to User B & User B sends Y to User A 5) User A derives Key as: k = (B)^a mod *p* = *g*^(ba) mod *p* User A derives Key as: k = (A)^b mod *p* = *g*^(ab) mod *p* ## Footnote Adversary knows *g* & *p*, X, Y
219
# Public-Key Cryptography Why is the shared key in Diffie-Hellman secure against brute-force attacks?
- B = *g*^b mod *p* (similarly A = *g*^a mod *p*) is not an increasing function as mod cycles through 0 - *p-1*. - Small changes in b do not lead to small, predictable changes in B. - It is resistant to Brute force approaches like aylor series approximation because it assumes continuity and differentiability. - No polytime algorithms to solve discrete log problem, therefore an adversary cannot compute the shared secret key.
220
# Public-Key Cryptography What are the Assumptions in DH?
- No Polytime solutions to solve B = *g*^b mod *p* (similarly A = *g*^a mod *p*) - The Adversary does not tamper with X & Y ## Footnote -2nd assumption may not be true in practice (Courier may have adversary that causes Man-in-the-Middle Attack)
221
# Public-Key Cryptography What is the Man-in-the-Middle Attack?
- Advesary sits in between User A & B (pretends to be User A to B & User B to A) - User A sends X, the adversary recieves it & Y from User B - User A & B secret keys don't match as they didn't recieve message from each other only from adversary - Adversary will know secret key for both user, so when they send messages the adversary can easily retrieve the message.
222
# Public-Key Cryptography What are the solutions to Man-in-the-middle?
- Authenticating Public Key (Authenticate Sender) - Requires a trusted 3rd party like certifcation Authority - ## Footnote Authenticate that User A is sending message to User B & vice versa
223
224
# Public-Key Cryptography What are the 3 RSA Algorithms?
- Gen (key Generation): Produces a Public & Private key Pair - Enc (Encryption) - Dec (Decryption)
225
# Public-Key Cryptography What are the Steps of for Gen Algorithm in RSA?
On a security parameter λ (No. of bits public & private keys will have) 1) Generate 2 distinct primes p & q of bit-size λ 2) Compute N = pq & Ø(N) = (p-1)(q-1) 3) Choose a random int e where e is (1< e< Ø(N)) s.t gcd(e, Ø(N)) = 1 4) Let Z{n} * = {x|0
226
# Public-Key Cryptography what is Z{n} * ?
- All Ints between 0 & N s.t gcd(x,N) = 1 - Basic Num Theory tell use their are Ø(N) integers
227
# Public-Key Cryptography Give an example of RSA:
1) p = 3 & q = 11 2) N = 3 * 11 & Ø(N) = (3-1)(11-1) = 2 * 10 = 20 3) Let e = 7 (gdc(7,20) = 1) 4) Find d = 3 as (7 * 3 ) + (-1) * 20 = 1 (Find a value to times e with to get 1 when you subtract Ø(N) from it) 5) PK = (e = 7 , N = 33) 6) SK = (e =7 , d = 3 , N = 33)
228
# Public-Key Cryptography What does the Encryption Algorithm do?
Enc(PK,m): On input an element (m∈Z{N} * ) & public PK = (e,N) compute - c = (m^e) (mod N) - c is an element (m∈Z{N} * )
229
# Public-Key Cryptography Give an Example of Encryption in RSA:
Z{N} * = {1,2,4,5,7,8,10,13,14,16,17,19,20,23,25,26,28,29,31,32} 1) m =4 2) c = m^e (mod N) = 4^7 (mod 33) = 16 (mod 33) 3) c = 16 | Z{N} * => Ints between 0-N, that are Prime to N(Not factor of N)
230
# Public-Key Cryptography What does the Decryption Algorithm do?
DEC(SK,c): On input an element (c∈Z{N} * ) & private key SK = (e,d,N) compute - m = c^d (mod N) | m is an element of Z{N} *
231
# Public-Key Cryptography Give an Example of Decryption:
- Recover m = c^d (mod N) - 16^3 (mod 33) = 4 (mod 33) - m = 4
232
# Public-Key Cryptography What are Digital Signatures?
- Primary tool to achieve Authentication in public key setting - Aims to achieve what hand-written signatures achieve in real world - Ensures hardness of forgery (signature prodcued by fraud, should be easily detected)
233
# Public-Key Cryptography What is the Hand-written Signature Function?
- Bind a statement/message to its Author(i.e Job offer should have signature of employer) - Verification is Public (Against a Prior Authenticated one)
234
# Public-Key Cryptography What are the Properties of Digital Signature?
- **Correctness**: A correct signature should always be verified as true - **Security**: Hard to forge (s.t the bank doesn't pass a fake as valid)
235
# Public-Key Cryptography What are the Applications of Digital Signatures?
- **Public Key Infrastructure**: Provide authentication of Public Keys (*Used in certificate to certify validity of public key*) - **Software Authentication**: Boot loader authentication, software updates (*Verifies signature before booting OS/ installing Update*) - **Contract Signing**: Legal documents, smart contracts, Authorise assets transfers in blockchain
236
# Public-Key Cryptography What are the 3 Algorithms of Signature Scheme?
- Gen (Key Generation) - Sign - Verify
237
# Public-Key Cryptography What is Gen Algorithm in Digital Scheme?
- Takes security parameters & creates & secret key - Secret key is used for signing, so called Signing Key ## Footnote (1^k) => Gen => (PK,SK)
238
# Public-Key Cryptography What is the Sign Algorithm in Digital Signature?
- Takes signing key & public key & message, to produce a signature σ (sigma) ## Footnote M => Sign(PK,SK) => σ
239
# Public-Key Cryptography What is the Verify Algorithm in Digital Algorithm?
- Takes message & candidate signature x, with public key & either accept or rejects the message, signature pair ## Footnote (M,x) => Verify{PK} => Accept/Reject
240
# Public-Key Cryptography What is Correctness?
If a message, signature pair was generated by Sign Algorithm, with the public key & secret key pair, then the verification algorithm wiht same public key & message, signature pair should ALWAYS ACCEPT ## Footnote If message signature pair was created honestly should always accept it
241
# Public-Key Cryptography What is Unforgeability?
Adversary would not be able to produce a message, signature that will be accepted - Verify the algo will always reject the adversary's message & signature pair
242
# Public-Key Cryptography What is RSA-Full Domain Hash?
Based on the idea of applying a cryptographic hash function to a message before signing it with RSA.
243
# Public-Key Cryptography What is involved in RSA-Full Domain Hash?
- **Public Function**: A Hash Function H (*Standard hash function e.g. SHA-3*) - **keygen**: Runs RSA.keygen.PK = (e,N) , SK = (d,N) - **Sign**: Input: SK,M Output: σ = RSA.Des(SK,H(M)) = H(M)^d mod N - **Verify**: Input: PK, M , σ => if RSA.Enc(PK,σ) = H(M) => Output: Accepted else Rejected *** (If σ^e mod N = H(M) => ouput accepted else rejected)***
244
# Public-Key Cryptography How to Prove Correctness?
CORRECTNESS: verify(PK,M,Sign(SK,M)) = Accept RSA.Enc(PK,Sign(SK,M)) = RSA.Enc(PK,H(M)^d mod N) = (H(M)^d) mod N = H(M) => by correctness of RSA
245
# Public-Key Cryptography Can Textbook RSA be Practical for Encryption?
NO
246
# Public-Key Cryptography The RSA security depends on...
...Hardness of finding *d* from *e,n*
247
# Public-Key Cryptography Is RSA Deterministic?
- Textbook algorithms are - In practice some random padding is used
248
# Public-Key Cryptography When will m < N work?
- Requires gcd(m,n) =1 - However, finding a m < n s.t gcd(m,n) >1, leads to finding *p* or *q* & break the system - NO
249
# Public-Key Cryptography What Algorithm can solve factoring in polytime?
- Shor's Quantum Algorithm - Quantum Computer of required capacity is still quite far away in the future
250
# Internet & Sockets What is the Internet? | Dictionary Definiton
A global computer network providing a variety of info & connumication facilities, comsisting of interconnected networks using standardized communication protocols
251
# Internet & Sockets What is the Interent?
- Internet is not a single entity but a network of networks - Uses protocols to enable devices worldwide to exchange data - Packet of data travel through different routes & devices, making intenet decentralised & flexible
252
# Internet & Sockets What does decentralised mean in Interent definition?
- Packets do not rely on a single path or central hub to tavel from one place to another. - Takes multiple paths, making system flexible & resilient to failures
253
# Internet & Sockets What did we have before the Internet?
- Isolated local networkd with minimal external communications - Telephone-based connection (SLOW & COSTLY) - Dedicated leased lines for exclusive, high-cost connections - File sharing required physical transfers (floppy disk)
254
# Internet & Sockets What are the challenges with the methods before the internet?
**Limited Interoperability:** - Different systems couldn't easily connect. - Need to know exact IP of device you were connecting to **Expensive & Low-speed Data exchange:** - Due to dedicated connections **No Universal communication Standard **
255
# Internet & Sockets What is Leased Line Connection?
- Big cables underground - Decictaed Lines between Computers - High Cost but reliable for direct communication - Limited Scaliability as more node join | (More device = cost rises exponetially )
256
# Internet & Sockets What is the Problem with Leased Line Connection?
- Bottle Necks leads to slow communciation **E.G: ** *A talks to D, B cannot communicate with C Simultaneously *
257
# Internet & Sockets What is the solution to Bottlenecks in Leased Line Connection?
Packet Switching
258
# Internet & Sockets What is Packet Switching?
- Data is plit inot packets rather than continuos communication - Packets travel separately allowing multiple conversation at the same time
259
# Internet & Sockets What is a Packet and What does it contain?
- A Packet is a Message/Data split into small chunks Contains Packets: - **HEADER:** Source, destination, size stored here - **Actual Data:** The message being sent
260
# Internet & Sockets How does data travel (IP PACKETS)?
Each Packet: - Travels Independently - Reassembles at the destination - Use IP for Routing ## Footnote Helps diagnose slow connections ?& network issues
261
# Internet & Sockets What does Traceroute allow?
Allows us to trace the route our packets takes to gain access to a website
262
# Internet & Sockets What was the issue with packets before the TCP was introduced?
Many packets were getting lost & arriving out of order
263
# Internet & Sockets How did the TCP solve the Issues?
- Ensuring lost packets are retransmitted - Guaranteed ordered,complete & error-checked data transfer - User Acknowledgment (Recievers confirms recieved data) ## Footnote Leads to Reliable file download, web browsing & video streaming
264
# Internet & Sockets What are Domain Names?
- IP is too hard to remember - We use Domain names, a name to match IP which will be easier to remeber
265
# Internet & Sockets What is DNS & Hierarchy?
- DNS translates names into IP address via a hierarchial system
266
# Internet & Sockets What are the steps for DNS?
- Request first go to the ISP's DNS resolver, then higher level DNS Servers - Authoritative DNS server provides the correct IP
267
# Internet & Sockets Why do Ports matter in TCP?
- Allows multiple connections - Each connection is uniquely identified by a TCP socket
268
# Internet & Sockets What is TCP connection defined by?
- Destination IP - Destination Port - Source IP - Source Port
269
# Internet & Sockets What does the Destination Port depend on?
The Service ## Footnote HTTP => 80 SSH => 22 DNS => 53
270
# Internet & Sockets How is Source port chosen
Chosen Randomly
271
# Internet & Sockets What is Netcat (nc)?
- A versatile tool for making TCP & UDP connections - Used to SEND, RECIECE, & LISTEN on network ports
272
# Internet & Sockets What is Nmap?
- A tool for discovering hosts & open doors - Scans system for open ports
273
# Internet & Sockets How does Internet Communication Work?
- Follows a Stack of protocols - Each layer depends on the layer below to send & recieve data - Layers focus on a specific task
274
# Internet & Sockets What are the 4 Layer ihe Internet Protocol Stack?
- Application - Transport - Internet - Link
275
# Internet & Sockets What is the Function of the Application Layer?
- Handles user-facing applications - Formats data for application - Decides what to send | e.g Web, Email, FTP, DNS ## Footnote Adds the protocol the application will follow i.e HTTP,HTTPS,FTP
276
# Internet & Sockets What is the Function of the Transport Layer?
- Manages end-to-end connections - Adds port Number to direct the packets to travel across different networks **TCP**: Ensures data is recieved completely & in the correct order **UDP**: Sends data quickly without checking for errors
277
# Internet & Sockets What is the function of the Internet Layer?
- Routes packets across networks - Handles the addressing & Routing using IP - Determining the best path for packets to travel across | IP, ICMP, Routing
278
# Internet & Sockets What is the function of the Link Layer?
- Manages physical network connections - Converts data in signals - Manges the physical transmission & error decetion in the communication ## Footnote Signal Sent over : Ethernet (CABLES) , WIFI (WIRELESS) ARP is also done here
279
# Internet & Sockets Why does the Internet Protocol Matter?
- **Scalability**: Network can grow without needign to change everything - **Flexibility**: New technologies can be added at specific layers without breaking everything -** Interoperability**: Different hardware & structure can work together as long as they follow te protol rules
280
# Internet & Sockets What is MAC (Media Access Control) Address ?
- Unique to each device - Assigned by manufactuer - Identifies a user - Can be changes quite easily (Negative) | E.g 48:D7:05:D6:7A:51
281
# Internet & Sockets What is the IP (Internet Protocol) Address?
Identifies devices golabally across networks | E.g. 147.133.123.15
282
# Internet & Sockets What are NAT (Network Adress Translations)?
- Private IPs - Not Unique - Enable multiple devices to share a single public IP
283
# Internet & Sockets What is DHCP?
- Assigns an IP to machine based on MAC address - IP assignment is temporary & not stored long term
284
# Internet & Sockets What is ARP?
-Helps routers map IP addresses to MAC adresses - Discovers who is using a specific IP
285
# Internet & Sockets What is the Process for ARP?
- Send a Request to fins who has specific IP - Person who has it replies back with IP
286
# Internet & Sockets What is ARP Spoofing (Network Attack)?
- Malicious machin can inpersonate another by faking ARP response - Allows Man-in-the-Middle Attacks
287
# Internet & Sockets What is Wireshark?
Powerful network protocol analyzer that records & inspects networks
288
# Internet & Sockets What happens in ARP spoof Attacks?
- Attacker send fake ARP reply, pretending to be gateway - Tricks victim into sending traffic to them - Attacker can now intercept, modify or drop packets ## Footnote Lack of Authentication
289
# Internet & Sockets What are the Assumptions for modern Security?
- All modles assume the attacker controls the network - Strong encryption is **only** protection (**True Defense**) - Data is unencrypted, should be considered compromised
290
# Internet & Sockets What was the Internet Designed for?
- Connectivity, not security - Traffic can be monitored,intercepted or altered
291
# Internet & Sockets When can Network attacks Occur?
Any point along the path | Path of the packets / communication
292
# Cryptographic Protocols What is a Simple Protocol?
**A => B** - A sends a messgae to B - Message can be "I am Alice" It has basic authentication but lack security
293
# Cryptographic Protocols What is the Impersonation Attack in a Simple Protocol?
**E(A) => B** - Attacker/ Adversary pretends to be a user - No way to check of sender is who they say they are. | E(A) => Adversary impersonating A
294
# Cryptographic Protocols Give a Solution for Impersonation on a Simple Protocol?
Symmetric Key Encryption: - Message encrypted & decrypted by the shared key Steps: - User A encrypts message using shared key kab - User B know its User A becaue they only share a key kab
295
# Cryptographic Protocols Eventhough the Replay Attack can occur with symemetric key encryption is the message still secure?
Yes, as long as the adversary does not know the key kab, which will be hard to retrieve the message is still secure.
296
# Cryptographic Protocols How can the Adversary bypass the symmetric key assumption?
Replay Attack: - Even if a message is encrypted an attacker can record it and resend it later. How it works: - User A send User B a message - Attacker either steals it through man-in-the-midde or using wireshark and records it to send to User B. ## Footnote Attacker will not know messgae due to not knowing the Key
297
# Cryptographic Protocols How to resolve Replay attack?
- Use a Nonce (a number that is only used once) Steps: - User A introduces themseleves to User B - User B sends a Random Num (Nonce) - User A sends the Nonce + 1 and the message
298
# Cryptographic Protocols How does nonce resolve replay attacks?
- Nonce is used once and if message is replayed checked and finds that the nonce is the same it was sent by an attacker, therfore can reject the message/ don't send packet to them. - This is due to Attacker not knowing shared key so they don't know the nonce value and the update value from the other user.
299
# Cryptographic Protocols What attack is still possible with nonces?
- Man-in-the-middle - Nothing is authenticated. - Due to the return message being split in 2 parts & the second part has no nonce therefore easy to change it. - If attacker knows ciphertext, they know the outcome, therfore can use previous message to swap with new message. ## Footnote Slide example, the attacker know the message gave him money last time so swap the new message with the old message will give him more money.
300
# Cryptographic Protocols How to resolve Man-in-the-middle for nonce simple protocol? ## Footnote In slides this is the 'A better protocol'
- Merge the 2 part of the message / packts, so that the nonce and message are together and the adversary cannot change it.
301
# Cryptographic Protocols What does the solution for MITM attack ensure in a better protocol?
- Users can be sure they are talking to the actual person they want to talk to. (B is talking to A - The message sent is the actual message (e.g send £5 to Bob) - The nonce & messages are fresh (NOT REPLAYED)
302
# Cryptographic Protocols What is the Key Establishment Protocol?
- A way to generate and exchange keys. - It is neede because A & B shared a key - Creates a session key so not too much happens of session key is compromised as it it one time use.
303
# Cryptographic Protocols What is a Session Key & how is it set up?
- A key used once to encrypted & secrypted messages. - Not too much if key is intecrpted only loss 1 message. Set up: The principals need to set up a session key using a Key establisment ## Footnote Principals are the entities involved in setting up the shared key.
304
# Cryptographic Protocols How to ensure you communicating with the correct principal?
Must know either: - Each other's public key (AES Key Est) - Use a trusted Third Party (Symmettic Key Est.) | 3rd Party ~ cannot have cryptography without trusting someone ## Footnote Est = Establisment
305
# Cryptographic Protocols What is the Needham-Schroder Public Key Protocol?
Used to establish a shared symmetric session key between two parties. The protocol itself relies on public-key encryption for the exchange.
306
# Cryptographic Protocols What are the step for Needham-Schroeder & explaination?
- User A encrypts a nonce Na and their indentity A with User B's public Key [E{B}(Na,A)] - User B decrypts Na & send it back with their own Nonce Nb (They send back [E{A}(Na,Nb)]) - User A decrypts the message and sends back Nb [E{B}(Nb)] This ensure users are talking to each other & generate a shared key using Na & Nb ## Footnote E{x} => mean encrypted with x's public key
307
# Cryptographic Protocols What are the goals of Needham-Schroeder?
- Users A & B are sure they are talking to each other - Whoever knows Na is the person to decrypt the first message. - Whoever Knows Nb is the person to decrypt the second message
308
# Cryptographic Protocols Explain the MITM attack on Needham-Schroeder?
STEPS: - User A sends nonce Na & their Identity A to User B, But Attacker intercepts it and replaces the identity with theirs E. - User B sends Ne & Nb to Attacker who forwards a modified version Na & Ne to User A. - User A send Attacker Ne & the attacker decrypts it and re-encrypts Nb and send it to User B - Attacker can now impersonate A & B, due to having a key with both users, so they can read the messages and modify it.
309
# Cryptographic Protocols Solution for MITM in Needham-Schreoder?
New Protocol called Needham-Schreoder-Lowe. - When User B sends back Na,Nb to user A they also send back their Identity. This is now secure because: - A & B mutually authenticate each other - Attacker can no longer impersonate User B (MITM protection) ## Footnote Needham-Schreider-Lowe ensures Mutual Authentication by including User B's identity
310
# Cryptographic Protocols What attack can occur in Needham-Schroeder-Lowe?
- Eventhough adversary cannot see the identity message they can still do a replay attack
311
# Cryptographic Protocols Can the Attacker read the Message encrypted with key (Na,Nb)?
No, the key is secure against : - Intecept , replay, delete & Alter attacks
312
# Cryptographic Protocols Can Government read your message?
- By law they can legally force you to give up your key, after the protocol has ran.
313
# Cryptographic Protocols What is Forward Secrecy?
Protocol has forward secrecy if it keep the messaf secrt from an attacker who has: - Recording of the protocol run - Long term keys (SHARED KEYS) of the principals They Protect Against: - Government forcing people to give up keys - Hacker that might steal private keys
314
# Cryptographic Protocols What are the steps for Station-to-Station Protocol? ## Footnote A.K.A STS
STEPS: - User A sends User B random DH value g^x - User B sends User A a Random DH value g^y and a signed message (g^y , g^x) encrypted by g^xy - User A send a signed message (g^y,g^x) encrypted by g^xy - User B sends A a Message encrypted by g^xy ## Footnote The Signed messages are used to prove identity of the user, Signature computed by a Users Private Key ensure it can only be generated by that user. PREVENTS MITM ATTACKS Key Arrangement is based on DH exchange Well desinged protocls prevent key leaks from compromisng post conversation
315
# Cryptographic Protocols How is STS Secure?
- x,y,g^xy are not stored after protocol run - A & B's keys don't let attacker read M - STS ensure Forward Secrecy as we don't store g^xy and keys are different everytime.
316
# Cryptographic Protocols STS & Forward Secrecy?
STS ensures forward secrecy because it does not store g^xy (the shared key), and a new key pair is generated for each session. This means that even if the long-term private keys are compromised, past session keys (which are used to encrypt the data) cannot be decrypted.
317
# Cryptographic Protocols How do user's verfiy each other without knowing the Public Key?
Possible Solutions: - Meet face to face & exchange keys - Use a pre-shared key mechanism Better Solutions: - Trusted 3rd Party (Signed Identies & public key, creating) - A certificate that verifies each other's keys ## Footnote This is important as it prevents MITM attacks that ensure only real users can decrypts other user messages
318
# Cryptographic Protocols What are the steps for Full Station to Station Protocol?
- User A sends g^x to User B - User B sends User A : g^y, Certificate for B CertB & Signed message containing (g^x,g^y) encrypted by g^xy - User A sends User B: Certificate for A CertA & Signed Message containing (g^x,g^y) encrypted by g^xy ## Footnote Verify Signature b#using certificate to make sure sender is who they say they are
319
# Cryptographic Protocols What is CertX ?
CertX is the certificate for user X - Contains public key X - Signed by a trusted Certificate Authority To authenticate X
320
# Cryptographic Protocols
321
# Cryptographic Protocols Why do we add a certificate?
- Full STS protocol includes certificates for A & B - Certificated contain public keys signed by Trusted 3rd Party - Don't nned to know Public key beforehand
322
# Cryptographic Protocols What is the Needham-Schroeder Key Establishment Protocol Steps?
- User A send the Server its Identity A , Indentity B & Nonce Na - Server Sends User A, Nonce Na, Idnetity B & Session Key K{ab}, the Session Key K{ab} & A's Idneity encrypted with S's Session key K{bs} All of this is encrypted by K{as} - User A sends User B the Session Key K{ab} & A's Identity encrypted with B's Session key K{bs} - User B send User A a Nonce Nb encrypted with the session key K{ab} - User A sends User B Nb+1 encrypted in the session ket K{ab}
323
# Cryptographic Protocols How does Needham-Schroeder Key Establishment Protocol Work?
- S is a Trusted 3rd Party that helps establish a shared key K{ab} - S enccrypts the session key for A & B - A & B mutulally authenticate using Nonce Na & Nb - Ensure that only A & B K{ab}
324
# Cryptographic Protocols What are some Key Establishment Goals?
- **Key Freshness:** Don't want to use the same key all the time / Key estabished is new - **Key Exclusivity:** Only the intended users know it. - **Good Key:** A good key is both fresh & exclusive
325
# Cryptographic Protocols What is Hierarchy of Goals?
Good Key / \ Fresh Key Key Exclusivity
326
# Cryptographic Protocols What is Far-end Operative Authentication Goals?
- A knows that B exists / Currently active E.g.: - A sends B a Nonce Na - B sends A a signed message of Na
327
# Cryptographic Protocols What is Once Authentication , Authentication Goals?
A knows B want to communicate with A E.g.: B sends A a message a Signed message A {B might have the name A is the message }
328
# Cryptographic Protocols What is Entity Authentication ?
A Knows B is currently active & wants to communicate. - They will verify each other. E.g.: - A sends B Na - B sends A a signed message of A & Na
329
# Cryptographic Protocols What do Strong Protocols provide all 3 forms of Authentication?
- Entity Aythentication - Far-End Operative - Once Authentication
330
# Cryptographic Protocols What is the Highest Goal?
- Protocol Provides Mutual Belief in a Key K for A with respcet to B if, after running the protocol, B can be sure that: - K is a good key A - A can be sure B wishes to communicate with B using K - A knows that B believes that K is good key for B
331
# Cryptographic Protocols Show the Heirarchy of Goals?
1) Mutual Beleif in Key 2) Good Key & Entity Authentication 3) Fresh key , Key Exclusivity, Far-end Operative & Once Authentication
332
# Cryptographic Protocols What is the Ultimate Goal?
Mutual Belief in a Key - ensuring bith A & B trust the estabkished key & each other
333
# TLS/SSL What is an X.509 Certificate
Contains: - Subject (entity Indentity) (Who the certificate is for) - Subject's public key - Issuer's name (Authority that signed the certificate)
334
# TLS/SSL What is the SSL/TSL Protocol?
- SSL was renamed to TLS - Provides encrypted communication & authentication using public keys | SSL => Secure Sockets Layer TLS => Transport Layer Security
335
# TLS/SSL What is TLS/SSL Encryption & Authentication?
TLS/SSL supports: - RSA - DES - DH Specific cipher suite is negotiated at the start of the session
336
# TLS/SSL What were the X.509 Verification Process?
- Issuer signs the hash of all certificate data - To Verify a certificate: - Compute the hash of the data - Check the signature using the issuer's public key - If I can trust the issuer's public key, I can trust the subject's pulbic key
337
# TLS/SSL What is the IP Stack?
- **Application:** Where your program will operate e.g. web browser - **Transport:** Uses TCP/UDP to manahe data transmission - **Network:** Uses IP for routing Data - **Link/Hardware:** Underlies phyiscal connections
338
# TLS/SSL What is the IP with TLS?
- TLS layer runs inbetween the Application & Transport Layer - Encryption is transparent to the Application layer - Normal TCP & IP protocol etc. can be used at the low layers - TLS handles encryption/decryption before the data is passed to TCP/IP (Making secure communication 'invisible' to application)
339
# TLS/SSL What is the TLS protocol?
**TLS Handshake: establishing a secure connection:** 1) C sends a message listing supported cipher & random Numbers to S 2) Server responds with its chosen cipher suite & its own random Nonce 3) Server sens its certificate, which contains public key 4) The client sends a pre-master secret encrypted with the server's public key 5) Both Parties exchange verification messages to confirm that the handshake was successful **Key Exchange Options:** - RSA: client encrypts pre-master secret with server's public key - Diffie-Hellman: Client & server derive a shared secret After the handshake, all communication is encrypted using the negotiated symmetric key
340
# TLS/SSL What are the Simplified Steps for TLS?
1) Client send sever a nonce Nc 2) The server responds with its nonce NC & certificate CertS 3) Client sends an encrypted pre-master secret (denoted E{s}(kSeed)) plus a hash encrypted with a session key 4) Server relies with its own hash encrypted with K{CS}
341
# TLS/SSL What is the Key Derivation?
- Both side then compute session as: K{CS} = f (Nc,Ns,Kseed) -Where f is a key derivation function ensuring bith parties use the same key
342
# TLS/SSL What is ClientHello (C => S) ?
- Textual: Client sends a random nonce & support cipher list - Transmits a Random Nonce Nc & list of supported Ciphers - Avoid Repay Attacks | Mathematical: C => S: Nc ## Footnote Nc => client's Nonce & used in key derivations
343
# TLS/SSL What is ServerHello + Certificate (S => C)?
- Textual: Server responds with a random nonce & chosen cipher suite - Server send its certificate (signed by CA) - The Server's response incldes its nonce Ns & certificate containing its public ket | Mathematical: S => C : Ns , Cert{S} ## Footnote Ns => Server's Random Nonce Cert{S} => Server Certificate containing its public key
344
# TLS/SSL What is Key Exchange(C => S)?
- Textual: Client encrypts a pre-master with the server's public key - Client encrypts the pre-master secret with the server's public key - A hash is computed over the exchaged values to ensute integrity Mathematical: C => S: E{S}(Kseed),{Hash1}Kcs ## Footnote E{S}(Kseed) => Pre-master secret encrypted with the server's public key Hash1 => ensures the integrity & is encrypted using the session key Kcs
345
# TLS/SSL What is Server Verfies & Responds (S=>C)?
- Textual: Server verfies handshake & confirms key agreement - Server verfies this Hash & sends back another hash to confirm mutual agreement Mathematical: S => C : {Hash2}Kcs ## Footnote Hash2 => Is computed over handshake date, confiriming mutual agreement
346
# TLS/SSL What is Key Derivation?
- Textual: Both sides dervie the session key using nonces & exchnaged key material - Use a function of Nc, Ns & keySeed Mathematical: - Kcs = f (Nc,Ns,Kseed) - f is key derivation function KDF that combined Nc, Ns & Kseed to generate Kcs.
347
# TLS/SSL What are Cipher Suites for TLS?
- Some suites provide encryption & authenitcation - Others provide authentication OR just encryption
348
# TLS/SSL What is the Negotiation with Cipher Suites for TLS?
Client & server agree on one suite from the list they both support to govern cryptographic methods used in the session ## Footnote Usually the Highest level of security, the both have
349
# TLS/SSL What is Weakness in TLS?
** - Cipher Downgrading: ** - Forcing a session to use a weaker cipher than both parties are capable of ** - Self-Singed certificates:** - Accepting certificates that are not validated by a trusted Authority 3RD Party
350
# TLS/SSL What is the Cipher Downgrading Attack?
How it Works: - Both the client & server list their supported cipher suites in order of prefrences. - Attacker can interfer with the handshake to force both parites to use the highest mutulally supported cipher. (Lie & say you only support the weaker ciphet, so not secure) (Reduce it by using latest / secure protocols)
351
# TLS/SSL What is the Impact of Cipher Downgrading Attack?
- Weaker cioer may lacj robust authentication, can make session vulnerable to further attacks - Like MITM attack
352
# TLS/SSL What are Self-signed Certificates?
- Maintiang a set of certificates is hard - Much easier just to accept any certificate Trade Off: - In enviroments like loT or certian apps, maintain a full set of trusted certificate us challenginh - Easier to acceots self-signed certificates Security Problems: - Accepting self-signed certificates can allow attackes to easily impersonate servers, facilitating MITM attacks
353
# TLS/SSL What is Apple's 'go fail' Bug in TLS & What Happened? ## Footnote 2014
- Allowed attackers to bypass TLS/SSL certificate validation What Happened: - Found in Apple's Secure Transport Library - A misplaced goto statement caused the certificate validation chek to be skipped - Allows MITM attack agaonst secure connections
354
# TLS/SSL What was the Impact of the Apple's 'goto fail' Bug?
Affected Safari, Mail, iCloud & other apple services using TLS. - These were all at risk as the bug meant that invalid certificates were accepted without proper verification
355
# TLS/SSL How could the Attacker Expoit the Apple's 'goto fail'?
- Client blindly trusts any certificate (Valid or not) - MITM Attacker could impersonate trusted website - Encrypted Communication coul be intercepted
356
# TLS/SSL What was the bug in the code for Apple's 'goto fail'?
in the SSLVerifySignedServerKey Exchange Function, in the if((err= SSLHashSHA1.final(...)...)), there was an additional goto final which skipped verification, and any certificate was trusted, making secure connections vulnerable
357
# TLS/SSL What are Apple's 'goto fail' fix?
Remove the additional goto fail
358
# TLS/SSL What was the Lesson Learned from Apple's 'goto fail'?
Need to have proper coding practices & through testing to avoid vulnerabilities - **Code Style matter:** Good Indentation & clear structure can prevent logic errors. - **Testing Matters: **Automated Tests can catch subtle bugs that mutual reviews miss. - **Open review in valuable:**Bug was unnoticed for years, wider security can help identify vulnerabilities early
359
# TLS/SSL What if one side supports a weaker cipher suite but the other does not? ## Footnote Cipher Suites
- Genrealy considered safe. - Developer removed all weak ciphers, some remained in servers. - Depnends on different cioher suites being incompatible ## Footnote - Handshake will select the highest mutually supported cipher - Attacker forces the use of weak cipher, security maybe comprimised
360
# TLS/SSL Give an example of incompatible cipher suites:
SSL_RSA_WITH_DES_CBC_SHA & TLS_DHE_DSS_WITH_AES_256_CBC_SHA
361
# TLS/SSL What is the LogJam:Breaking TLS encryption? ## Footnote Give KeyInsight also
- Attacker can force a downgrade to these weak groups & then use precomputed discrete logarithms to break the encryption in real time Key Insight: Weak DH groups are compatible with strong groups (Stronger DH group can be decrypted by a weaker DH group) ## Footnote DH => Diffie Hellman History : Snowden leaks revealed NSA's large-scale TLS interception
362
# TLS/SSL What are the Key Takeaways of LogJam?
- TLS Servers commonly support weak 512-bit 'export-grade' DH groups - MITM attacker can force TLS to use weak DH group, even if strong group is avaliable - Precomputed discrete logs allow attackers to break key in real-time *(Lets attacker passively decrypts TLS traffic in scale)*
363
# TLS/SSL How is Diffie-Hellman done in TLS?
DH key exchange is widely used in TLS for forward secrecy: 1) C & S agree of a **prime** p & **generator** g 2) C picks a secret a, Computes A = g^a & sends it to S 3) S picks a secret b, Comutes B = g^b & sends it to C 4) S & C compute shared secret: K = B^a mod p = A^b mod p ## Footnote C => Client S => Server
364
# TLS/SSL What is the problem in DH in TLS?
- server reuse the same small set of DH primes, making them vulnerable to precomputatuin attacks - Making Pre-computatuon attacks feasible if weak primes are used
365
# TLS/SSL How does LogJams Works?
**Step 1 : MITM Attack** - Attacker intercepts the ClientHelllo message - Client proposes a strong DH group (2048-bit) - Attacker modifies this to request an export-grade 512-bit DH group **Step 2 :Server Accepts Weak DH Group** - Server allows the downgrade & responds with a weak DH group - Attacker can now easily compute the discrte log for the shared key
366
# TLS/SSL What are the Steps for the Original Secure TLS handshake?
1) C => S: ClientHello (Strong DH group, e.g. 2048 bits) 2) S => C: ServerHello (Same DH group) 3) S => C: Certificate, DH Params 4) C => S: Key Exchange
367
# TLS/SSL What are the Steps for Downgraded TLS Handshake (LogJam Attack)?
The Server, supporitng export-grade DH for legacy reason, accepts the weak group. 1) C => MITM => S: ClientHello (Requesting weak 512-bit) 2) S => MITM => C: ServerHello (Accepting weak 512-bit) 3) S => C: Certificte, Weak DH Param 4) Attacker quickly computes the shared secret due to precomputed discrete logs 5) Attackers decrypts & relays traffic in real-time RESULT: Attacker can derive the session & decrypt communications
368
# TLS/SSL What is the comparison Betwenn normal Handshake & downgraded Handshake?
- Normal handshake, a strong DH is used, making it computationally hard to break. - Handshake is manipulated to use a weak size-bit group
369
# TLS/SSL How is the Key Broken in LogJams?
With weak parameter, the attacker can compute the shared secret quicklt & decrypt TLS traffic in real time
370
# TLS/SSL Why does LogJam Work?
1) **Many server reuse the same small set of DH primes:** - NSA can precompute discrete logs for these primes 2)**Export-grade cryptography is still widley supported:** - Weak DH groups weere left in for legacy reasons - Attackers can downgrade connections to force weaker groups 3) **No Authentication Required of DH Params** - TLS handshake does not authenticate the DH group selection - Attackers can ,odify the handshake without detection
371
# TLS/SSL How to Defend Against LogJams?
**Mitigation Steps:** - Increase minimum DH key size (~2048 bits) - Disable export-grade ciphers completely - Use unique DH groups, instead of common shared primes - Prefer Elliptic Curve DH over Traditional DH **Industry Response:** - Browser vendors removed support for weak DH groups - TLS 1.3 removes support for static DH & export-grade cryptography
372
# TLS/SSL What is the Heartbleed: A Critical OpenSSL Bug?
- Allowed Attackers to read up to 64kb of memory from a server potentially exposing private keys, session cookies, passwords & other sensitive data ## Footnote Affected OpenSSL versions 1.0.1 to 1.0.1f
373
# TLS/SSL What went wrong with Heartbleed?
- OpenSSL implemented a Heartbeat extension to keep TLS conncetion alive. - Bound-checking failure allowed attacker to read up to 64 kb of memory - No authenitcation, so memonry can be requested by an attakcer without being a legitimate user
374
# TLS/SSL What did TLS Heatbeat exist?
- Allows clients & server to check if connection is still open - Works by sending a small requests & expecting the same response - Meant to prevent unescessary re-negotiations in TLS
375
# TLS/SSL How does the Heartbleed exploit work?
EXPLOT: ``` Client => Server: HeartbeatRequest("Hello", length = 64KB) Server => Client: HeartbeatResponse(Leaked memory up to 64Kb) ``` - An attacker send a HeartbeatRequest with a deiliberately inflated length field - The server, not verfiying the actual length of tha payload, responds by sending back extra data from its memory ## Footnote Attacker could repeatedly send malicious reauest to extract private keys, passwords or other data
376
# TLS/SSL What were the Mistakes & Vulnerabilities in the code?
- Lack of proper bound checking is the root cause of the vulnerability - Memory beyond legitimate data is copied & sent back to attacker - Attackers could srnd small packets, but request large response, causing leaks - Server reads a 'length' value from the request & then copies that many bytes from memory without checking if the requests actually contained that much data
377
# TLS/SSL What could be stolen? ## Footnote Heartbleed
Could Expose: - **Server private keys** Allowing attacker to decrypt past & future TLS traffic - **User Credentials** Including session cookies & passwords - **Sensitive session data** Any Info presents in the server's memory (**Internal API Keys, OAuth tokens, SSH Keys** ) - **Anything stored in memory** Since OpenSSL is widely used, many systems were affected
378
# TLS/SSL Why is Heartbleed Bad?
- Steak session cookies without triggering alerts - Compromised Private keys meant attackers could decrypt past traffic - Attack left no logs - **Undetectable unless you were monitoring memory leaks**
379
# TLS/SSL How did Heartbleed impact the real world? ## Footnote e.g services affected & damges/responses
**Affected Services:** - **Major websites:** Yahoo, Tumnlr, GitHub & Google - **VPNs & Firewalls:** Cisco, Juniper Networks - **Cloud Providers:** AWS, Google Cloud, Azure **Response & Damages:** - OpenSSL released a patch 1.0.1g (after discovery) - Websites scrambled to revoke & reissue TLS Certificates - Users were told to change their passwords - Attacker likely had access to sensitive data for years before discovery
380
# TLS/SSL How was Heartbleed Fixed?
1) **Proper Bound Checking:** - Length field must be checked against actual input size - Length is greater thand provided data, it is rejected 2) **OpenSSL Patch:** - Introduced proper bounds checking - Disablrd heartbeat extension unless explicitly enabled 3) **Industry Response:** - Websites had to revoke compromised certificates - Users advised to change passwords - Organisations moved away from Open SSL
381
# TOR What is a Proxy?
- Proxy server sit between you & the Internet - Hides your IP address from the webiste you visit
382
# TOR What are VPNs?
- Securely connect you to another network over the internet - Provides privacy & security by encrypting your connection - promise "Anonymity" (to website not to the VPN company) - Access to private networks remotely - Single (ONE) proxy
383
# TOR Can an Internet connection reveal your IP number?
YES
384
# TOR What is Hotspot Shield VPN?
- VPN acts like a proxy by routing traffic through a differnet server - Recipent websites only sees the VPN's IP, not yours - VPN provider knows your original IP
385
# TOR How does VPN connect to websites?
- Connection made via their servers - Intended recipent server never sees your IP
386
# TOR Encryption in VPNs?
- Use encryption like TLS & IPSec to protect data - Ensures that your ISP & hackers cannot easily intercept your traffic
387
# TOR VPNs for Anonymity? ## Footnote Limitations & Anonymity
Helps with Anonymity?: - Server thinks you are the VPN provider - ISP sees the connection to VPN - Global observar can probablu link your connections Limitiations: - Global observer may still link your VPN activity to your identity - VPN provider itself can see your traffic & could store logs (NOT ANONYMOUS)
388
# TOR When using a VPN what does the WIFI provider Know?
- WIFI's Outgoing IP address - That you are connect to the VPN Means, public WIFI cannot monitor your browusing habits if you use a VPN
389
# TOR When using a VPN what does the VPN provider Know?
- WIFI's Outgoing IP address - You are connected to VPN - VPNs Outgoing IP address - The website you are browisng VPN provider can track & log everything you do. If provider is compromised, then your privacy is at Risk.
390
# TOR When using a VPN what does the website provider know about you?
- The VPNs Outgoing IP address - The Website you are browsing - The contents of your website - Shouldn't know you are using VPN (can be inferred) Website does not know your real IP when using VPN, but know your activity
391
# TOR Where do you get the best anonymity?
Onion Routing (TOR)
392
# TOR What is Onion Routing?
- Best Anonymity by routing traffic via multiple proxies - Ensures your message is **seurely encrypted in layers** & routed through multiple nodes - Each node only know the PREV & NEXT hop, thus ensuring no single enity can trace full path
393
# TOR How does TOR Onion Routing work?
- Each proxy only learns the IP of the PREV & NEXT Proxy in circuit - Public Keys of each proxy is known - Soruce IP is visible only to entry node - Destination IP is visible to exit node - Use picks 3 Proxies & remain anonymous as long as at least one node is not compromised
394
# TOR How does TOR work?
User Picks 3 Proxies (Nodes): - **Entry Node:** Knows user's IP - **Middle Node:** Acts as Relay - **Exit Node:** Knows the destination websites
395
# TOR Why is TOR Secure?
As long as at least one node is not compromised, anonymity is maintained - Entry Node doesn't allow the destination - Exit Node doesn't know the Sender
396
# TOR How are TOR Onion Routed? ## Footnote SIMPLE
- Each node only decrypts one layer, enough to know where to send it - Final Layer is decrypted at the exit node, and goes to the website/gets message - Prevent any single entity from tacking their connection
397
# TOR TOR Routing Explained in Detail:
- Message is Encrypted 3 times (for 3 node) - Each node decrypt the relative layer & if it cannot decrypt it, it will send it ot the next node - Then the node will send it back to the user & the decrypted message sent to it & repeats until final node is reached - Final node, the message gets decrypted and send back a response being encrypted layer by layer by each node. To be decrypted by the User
398
# TOR Problem of TOR?
Due to the constant decrypting and encrypting TOR is very slow (Dercypting to send website message & encrypting response back to user to decrypt)
399
# TOR What are TOR Hidden Servers?
- Hide Server from you (USER) - Give websites .'onion' addresses (Only accessible through TOR network)
400
# TOR How do Hidden Services work?
- Server dies not reveal its IP address - Instead, it connect through TOR relay to stay anonymous
401
# TOR What are the Steps to set up a Hidden services & User to connect to it?
1) Service Provider picks some introduction points (IPs from TOR Cloud) & builds circuit to them 2) Service Procider puts their service name.onion in Database & uses the IPs of the nodes (information Points). DONT use your own 3) User hear that the name.onion exist and request more info from database & she sets up a rendezvous point (Can be done before) 4) User writes to privder an encrypted message using their PK, lisiting the rendezvous point & one time secret and ask the indroduction point to deliver it to the service provider 5) Provider connects to User's redezvous point & provides their one-time secret {if connection is accepted} (Connection can be rejected) 6) User & provider proceed to use their TOR circuits like normal (User never knows Provider IP & vice versa)
402
# TOR Does TOR provide Security? ## Footnote Explain why/ why not?
NO - Protects anonmity but not security - If exit node is compromised/ is malicoius, it can see unecrypted data send to website/service - If you login to your account (Facebook), your identity is exposed
403
# TOR What is the Summary of TOR?
**Final Takeaways:** PROS: - Provides strong anonymity by routing traffic through multiple nodes - Hides IP, making tracking difficult - TOR hidden services allow anonymous websites CONS: - Remains one of the best tools for online privacy - **Not foolproof:** - entry node sees your IP - Exit node sees your traffic (if unencrypted) - Government & adversaries try to break TOR
404
# SQL Injection
405
# Web Attacks
406
# Web Security What is Cross-site Scripting XSS?
- Inject client-side code into pages viewed by other users - Attacker tricks web application to include malicious code
407
# Web Security What are the goals of XSS?
- Display images, open popups - Change page contents - Session Hijacking: Steal Cookies
408
# Web Security What is the Underlying Issues of XSS?
Input/Output Validation - NEVER TRUST USER'S INPUT (THEY CAN BE ATTACKER)
409
# Web Security How does attacker perform Cross-site Scripting XSS?
Attacker sends script to application, that sends it to the web application to send database, so it gets sent to others users
410
# Web Security What is Stored XSS?
Occurs when the attacker can inject malicious code into server-side & code is later displayed to other users.
411
# Web Security Give Examples of Stored XSS Attacks?
In an area with little access control you can put: - HTML : `

comment

` - Script : `` WORMS: - Self Replicating Attack - (NO. of links/comments appear multiple times) - E.g. If user goes to malicious page with worm, everytime they access that page it will output the output the worm produces.
412
# Web Security What is Reflected XSS?
Attacker sends user URL with malicious code already in it. Not stored on server, but is displayed on the visted page `e.g: https://web.site/?search=`
413
# Web Security Give Examples of Reflected XSS Attacks?
- Edit Script to flip page 180 degrees - HTML edit code to show other values OR get other inputs
414
# Web Security What are the Steps for Session Hijacking with XSS?
1) Attacker injects script on the victim server & waits for a victim 2) Server passes a session cookie & the Attacker's Script to Visitor 3) Scriot runs in the victim's browser, & passes the session cookie to the attacker 4) Attacker passes the stolen cookie, making the server think he is the victim ## Footnote - Redirects Victim's browser to attackers site , passing cookies - Might also pass currently visited web page - ALT , a Request, load an image
415
# Web Security What are XSS Protections?
- **Validate User Input** - **Output Filtering** - **HttpOnly Cookies** - **Content Security Policy**
416
# Web Security How does **Validate User Input** work? | XSS protection
It only allows a very strict subset of inputs e.g : alphanumeric Chars | Validation can be tricky, so you need to understand dataflow through app
417
# Web Security How does **Output Filtering** work? | XSS Protection
**Plain Output: HTML Encoding** - Stored data values need to be encoded to represent HTML **Marked up output: Encoding + Domain Specific Language (DSL)** - Use a dedicated syntax & convert it tot a safe subset of HTML
418
# Web Security How do **HttpOnly Cookies** work? | XSS Protection
Cookies with HttpOnly flag, so they are not accessible via Javascript, preventing theft via document.cookies
419
# Web Security How does **Content Security Policy (CPS)** work? | XSS Protection
A Strict CSP can prevent inline scripts & limit which domians can be requested.
420
# Broken Access Control What is Broken Access Control?
Attacker can act otuside their intended Permissions
421
# Broken Access Control Give Examples of Broken Access Control:
- Violation of the principle of least privilege OR deny by default - Bypassing access control checks by modifying the URL - Permitting viewinf OR editing someone else's account - Elevation of Privilege
422
# Broken Access Control What is Violation of the Principle of least privilege?
Access should be granted for particular capabilities, roles, or users, but is available to anyone | (HIDE LINK OF ADMIN AREA)
423
# Broken Access Control What is Bypassing Access cotnrol check by modifying the URL?
Parameter tampering OR force browsing Internal application state, OR the HTML page , or by using an attack tool modifying API request | (PATH TRAVERSAL)
424
# Broken Access Control How is Permitting viewing or editing someone else's account done?
Providin its unqiue identifier | (OBJECT REFRENCES )
425
# Broken Access Control How is Elevation of Privilege done?
Acting as a user without being logged in OR acting as admin when logged in as user | (REDIRECTING)
426
# Broken Access Control What is the issue with path traversal designed like this: **https://myblog.org/index.php?entry=2025-03-17.html**
- Format is not reliable as you can change URL to something else to open different file - If you know paths in the application you can access them - Remote user can potentially vist any file on the system
427
# Broken Access Control What does index.php do in https://myblog.org/index.php?entry=2025-03-17.html?
- Reads a plain HTML file - Wraps it with navigation links. site style
428
# Broken Access Control What are defenses against path traversal?
- http sever should not serve hust any file - Use internal web server config (Each webapp is separate) - Add External OS config (e.g. nobody users , chroot) - Use of allow-list (Filter inputs against Know / safe options)
429
# Broken Access Control What is the Issue with Object reference where all HTML code is visible / personal info visible?
- Can Modify & re-run HTML on your devise - Can change HTML, Change account and access it ## Footnote Uses Post to protect sensitve data
430
# Broken Access Control What are Solutions for Object Reference?
- **Re-validate**: Check authorisation again after every action from user, to make sure they have the access to perform the action - **Add a data Indirection**: Session specific server side array of account numbers - **Use of database/hashtables**: Use SQL to make sure users can access their accounts only
431
# Broken Access Control What is the Issue with Too much information in Object references?
- Passing Potentially unnecessary info to the client - Expecting it unmodified - User can change types / HTML code/ User (email)
432
# Broken Access Control How to protect Information in Object References?
- If the info is not needed, don't send it/ add it to frontend - If it needs to be in visible frontend, encrypt it - Add MAC constructed with server-side key
433
# Broken Access Control Can Hiding a link in the navigation for unauthorsed users prevent them from visiting it?
NO
434
# Broken Access Control How to prevent unauthorised users accessing hidden links?
- Manage Authorisation in a separate module - Single Route through Code - Trace to make sure authentication happens - Make authorisation checks for each function - Use deny-by-default policy *{if you forget it its not accessible}*
435
# Broken Access Control What is Cross-site Request Forgery (CSRF)?
Exploit Browser's trust relationship with website *E.g. Existing login* ## Footnote Examples: home router admin, banking, email , browser is authorised to connet here
436
# Broken Access Control How is CSRF Attack work?
- Attacker Triggers malicious action - get user to open malicious link - Browser undertakes action on target site on behalf of authorised user
437
# Broken Access Control How is CSRF different from XSS?
- User goes to bad website then to the good website in CSRF - XSS Changes/Modifes good website, user goes to good then gets bad page sent back
438
# Broken Access Control Explain Steps of CSRF?
1) Attacker Send user a link to a website, and user opens it 2) Website has an image which triggers a get request in the browser 3) The get request access the actual website, the get request will perform transaction without user's knowledge (INCLUDES COOKIES) 4) Using the Cookies a transactions is performed ## Footnote example of transactions: Email, banking
439
# Broken Access Control How to prevent CSRF?
- Include a CRSF token that the attacker cannot load in the HTML code The token is Hidden and the value is randomly genreated, it gets checked by server to make sure CSRF doesn't occur
440
# Broken Access Control What is Same-origin Policy?
- Standard browser-side mechanism to protect simultaneously running web apps from one another
441
# Broken Access Control What does Same-origin Policy Restrict?
- DOM - APIs for web access - Cookies, HTML5 local storage APIs Prevents attacker website from reading data from other website To pages from the same domain, i.e., protocol-host-port { Different ports for website cannot access each other data} - TOO RESTRICTIVE for legitmate cases , e.g. APIs / 3rd party services ## Footnote SANDBOXING enhances this
442
# Broken Access Control What is Access Control : Cross-Origin Resource Sharing?
- Modern Web Apps use Javascript APIs like fetch to send & recieve data asynchronously - Relaxes Same-origin Policy securely - Works by allowing servers to specify permitted origins using special HTTP Header
443
# Broken Access Control Give examples of Specail HTTP Headers?
**Access-Control-Allow-Origin: http://www.example.com** OR **Access-Control-Allow-Origin: * **
444
# Broken Access Control What are the Security Configuration for Deployment?
- Whole web app stack must be secure - Makes sure its up-to-date with security patches - Disable unnecessary features - Use minimum Privilege - Ensure Error handling does not expose info - Have repeatable security config process - Have automated checking process
445
# Broken Access Control Why should Everything {OS, WEB, SERVER, DBMS, APP FRAMEWORK , LIBARIES} be kept up to date?
Most attacks are due to systems being outdated
446
# Broken Access Control Give Examples of Unnecessary Features:
- Default Accounts - Demo pages - Debug Interfaces
447
# Broken Access Control What are Minimum Privileges?
- Separate Concerns - ACLs per component/app
448
# Broken Access Control What are repeatable security config process?
- App-specific checklist to work through - Unifrom config for development, QA & deployment
449
# Broken Access Control What is the Purpose of having an automated checking process?
Ensure an automated checking process
450
# Broken Access Control What are redirects & forwards?
- Apps often allow redirections - Sends user off-site with a polite message - Reroute them immediately OR Forwards them to different part of the same site
451
# Broken Access Control What are the security concerns with Redirects?
- Attacker could redirect to their website to steal your data E.g. Bank website in email, when clicked can redirect you to the phishing website, the ultimate destination can be concelaed in URL encoding
452
# Broken Access Control In Open Redirect links for phishing can the ultimate destination be concealed?
YES, by URL encoding
453
# Broken Access Control What is a typical Example of a community-wide desirable security measure?
- Preventing open redirects - Open mail Relays - ICMP broadcast GOOD PRACTICE OF ALL PROVIDES SECURITY FOR OTHERS
454
# Reverse Engineering What is Reverse engineering?
- Means of analysing software to figure out how it works, often without original code (LIKE TALING APART A TOY & SEEING HOW INSIDES WORK) - Examining low-level code, can remove protection & alter function - Good protection slows this down, NOT STOP IT
455
# Reverse Engineering Issues with "Data can be Code":
Lots of attacks we have seen trick a program into accepting data that is really code: - SQL Injection - XSS
456
# Reverse Engineering What is the Issue with "Code being data"?
Executable code can be written & edited - An attacker can do anything they want with the program, edit the code
457
# Reverse Engineering Goals of Reverse Engineering:
- Security research - Debugging & Performance Optimiation - Learning how compliers & systems work
458
# Reverse Engineering What is a Binary?
- File that computer can rin and understand. - Complier converts programs it into this binary format - Helps understand which tools are needed for reverse engineeing on each system
459
# Reverse Engineering Can differnet Sytems translate or understand other system's binary files?
NO
460
# Reverse Engineering What are different systems & Instruction Sets?
- Each OS has it own Binary format {Program compiled for one system won't run on another} - CPUs Understand specific Instruction
461
# Reverse Engineering Why are different systems & instruction sets IMPORTANT for Reverse Enginerring?
Need to know the binary format & CPU type the program is built for (DETERMINES TE TOOLS YOU SHOULD USE)
462
# Reverse Engineering What are Reverse Engineering Tools?
- Debugger - Disassembler - Decompiler
463
# Reverse Engineering What is a Debugger?
- Allows you to pause & inspect our running program - Helps you follow the program step-by-step & see's what's happening - Modify Contents of memory, CPU Registers & stack Frames
464
# Reverse Engineering What is a Disassembler?
- Converts machine code into assembly code. - Show the assembly Instructions Binary is Machine code Assembly is Low-Level Language
465
# Reverse Engineering What is a Decompiler?
- Translates machine code back into High-Level code to make it even easier to understand - Tries to recreate the original source cose (NOT PERFECT)
466
# Reverse Engineering What are the steps for using the different tools for to get High level code to Assembly?
- The complier converts the high level code into machine code (Like Lossy Compression removes Variable names, an other redundant data) (IN Assembly each luine corresponds to a part to complete the function) - The Disassembler converts the Machine code into Assembly.
467
# Reverse Engineering What are the steps for using the different tools for the Assembly to High Level?
- Assembler converts assembly to binary - - Decomplier converts the Binary file into higher level code (NOT THE SAME AS ORIGINAL CODE)
468
# Reverse Engineering Why is it hard to Reverse Code from Assembly/Machine Code to High Level?
**Optimisation:** Compiler may simplify the code, removing same steps **Variables Names:** Compiled, meaningful names like num are replaced with vauge things like edi **Onfuscation:** Some program are intentionally make harder to to reverse engineer mixing up the instruction.
469
# Reverse Engineering What happens when the High level code gets translated into Assembly?
- Optimisation remove parts - Removes Variable names - Other info can get lost
470
# Reverse Engineering What happens when the Assembly code gets recompiled into High Level code?
- Program might not be the orginal code written in C - Complier migh be unkniwn - Onfuscation can make decomping impossible
471
# Reverse Engineering What are Registers?
- Small, super-fast storage location inside the cpu - Holds data the CPU os currently working with - Registers are fast than normal memory because they are inside processor
472
# Reverse Engineering What are General Purpose Registers?
Used for most calculations & Data movements
473
# Reverse Engineering What are the 2 types of specalised Registers?
- **Instruction Pointer (RIP):** Keeps track of where the CPU it in the program - **Stack Pointer (RSP):** Points to the top of the stack (USED FOR FUN CALLS & VARIABLES)
474
# Reverse Engineering What is RAM?
- Large data - Referenced by Address - Stores large amounts of data for longer periods while program runs
475
# Reverse Engineering What does RAM hold?
- **Code** : Instruction the CPU executes - **Heap**: For Dynamic Memory - **Stack**: Temporary data like local Variables
476
# Reverse Engineering What are the IMPORTANCE of MEMORY in Reverse Engineering?
Reverse Engineering, knowing where the data is stored helps you understand what the program is doing
477
# Reverse Engineering What is Register Aliasing?
Registers that describe different parts of the same memory cell
478
# Reverse Engineering Why does Register Aliasing matter?
- Understand these register is key to reading assembly - E.g: If a program multiple numbers, will probably use RAX
479
# Reverse Engineering What are the 2 most inportant Registers?
- **RSP** in 64-bits *Stack Pointer AKA: ESP(32)/SPL(8)* - **RBP** in 64-bits *Base Pointer AKA: EBP(32)/BPL(8)*
480
# Reverse Engineering Why are Registers important in RE?
- Key to reading assembly - Registers hold specific data for function
481
# Reverse Engineering What are the Registers for Accumulator?
**- 64 bit:** RAX **- 32 bit:** EAX **- 8 high bits of lower 16 bits:** AH **- 8 bit:** AL
482
# Reverse Engineering What are the Registers for Base?
**- 64 bit:** RBX **- 32 bit:** EBX **- 8 high bits of lower 16 bits:** BH **- 8 bit:** BL
483
# Reverse Engineering What are the Registers for Counter?
**- 64 bit:** RCX **- 32 bit:** ECX **- 8 high bits of lower 16 bits:** CH **- 8 bit:** CL
484
# Reverse Engineering What are Registers for Data?
**- 64 bit:** RDX **- 32 bit:** EDX **- 8 high bits of lower 16 bits:** DH **- 8 bit:** DL
485
# Reverse Engineering What are Registers for Source Index for string Operations?
**- 64 bit:** RSI **- 32 bit:** ESI **- 8 bit:** SIL
486
# Reverse Engineering What are the Registers for Destination index for string operations?
**- 64 bit:** RDI **- 32 bit:** EDI **- 8 bit:** DIL
487
# Reverse Engineering What are the Registers for General Purpose?
**- 64 bit:** R8-R15
488
# Reverse Engineering Give the Common Instructions for Data Movement:
- **move dst,scr** => puts the value in scr into dst - **push scr** => stores the current value scr onto the stack - **pop dst** => Loads data from dst to scr *Loads last stores value into scr* ## Footnote scr (SOURCE) dst (DESTINATION)
489
# Reverse Engineering Give the Common Instructions for Arithmetic:
- **add dst,scr** => adds scr to dst *e.g. add rax, 10 => Adds 10 to the rax register* - **sub dst,scr** => subs scr from dst *e.g. sub rbx, 10 => subs 10 to the rbx register* - **imul dst, scr** => multiplies dst to sct *e.g. imul rax, 10 => multiplies the value in rax by 10*
490
# Reverse Engineering Give the Flags for Rev Eng:
- **ZF: Zero flag** set to 1 if the result is 0 - **SF: Sign flag** set 1 if the result is -VE - **OF: Overflow flag** set to 1 if operation overflowed
491
# Reverse Engineering Why do flags matter?
- Important for decisions in code - In Rev Eng, watch the flag change to understand the program flow
492
# Reverse Engineering Give the Common Instructions for Control Flow:
- **jmp label** jumps to label *e.g. jmp exit => Jumps to section labelled exit* - **call fn** calls a function, pushes current* IP* onto stack, and jumps to the function *e.g. call myFun => calls function named myFun* - **ret** Pop* IP* from the stack & continues from saved positon on stack *e.g. ret (Goes back to point from the stack)* - **cmp a,b** calculates b-a & sets flags *e.g. cmp rax,5 => compares rax with 5* - **test a,b** calcuates a&b & sets flags - **je label** Jumps to label if zero flag is set *e.g. je done => Jumps to done if the prev cmp was equal* - **jne label** Jumps to label if zero flag not set *e.g. Jumps if not equal (Opposite of jn)* - **nop** No-op instructions *DON'T DO ANYTHING*
493
# Reverse Engineering Why does Control Flows Matter?
- Instruction control program's logic - When REV ENG, follow these jumps to trace how the program works
494
# Reverse Engineering What are Common Instructions with Bitwise Operations?
- **and dst,scr** Performs a bitwise AND *e.g. and rax,0xFF keeps ont the loest 8 bits* (Both Bits must be 1) - **or dst,scr** Performs a bitwise OR *e.g. or rax,0x1 keeps ont hte loest 8 bits* (Either Bits can be 1) - **xor dst,scr** Performs a bitwise XOR *e.g. xor rax,rax sets rax to 0* (Flips bits where one is 1)
495
# Reverse Engineering Why is Memory Addressing Important?
- Memory Access helps you track vatiables in a program - Crucial for understanding function arguments & local variables [] => REPRESENT that operand is Mem Address
496
# Reverse Engineering What is Direct Memory Access: [address]?
- Use a specific memory address -e.g.:**mov eax,[0x1234]** *moves the value at 0x1234 into eax*
497
# Reverse Engineering What is Register-based Memory Access [register] :
- Use a register holding an address - e.g.: **mov eax, [ebp]** *Moves the value at the address in ebp itno eax*
498
# Reverse Engineering What is Register-based Memory Access [register + offset] :
- Access memory relative to a register - e.g.: **mov eax, [rbp-4]** *Loads data 4 bytes before rbp*
499
# Reverse Engineering Why are Patterns useful in Rev Eng?
- **Find important Vals:** Looks for mov instruction moving data to register - **Trace Decisions:** Id cmp by conditional jumps - **Modify Behaviour:** Bypass checks by relpacing jump with nop (Do nothing instructions)
500
# Reverse Engineering Explain this common pattern: **mov eax, [esp+1] add [esp+18], eax**
**What is Happening:** - ***mov eax, [esp+1]* ** Loads a value from memory location 1 byte after esp inot eax register. esp hold the current position on the stack, so this reads data from stack - ** *add [esp +1]* ** This takes the value in eax & adds it to the value located 18 bytes after esp **Interpretation:** - Pattern typically moves data from mem to a register, modify & write it back - Common calculations for handling variables stored on stack **Importance:** -Pattern means the program is manipulating local variables in a function - In Rev Eng, the iding the pattern allow you to identify where importance data is stored & changed
501
# Reverse Engineering Explain this common pattern: **cmp [esp+1], 3 je lable1**
**What is Happening:** - *** cmp [esp+1],3* ** Compare the value 1 byte after esp with 3 Doesn't change data, only updates flags - ** *je label1* ** Jumps to a specific part o the code if the 2 values are equal **Interpretation:** - Conditional checks; if the program jumps to another part of the code - Condition is false, program continues to next instruction **Importance:** - Used for if statements, loops & error checking - Understanding these jumps is critical for Rev Eng beacuse modifying the jumo can alter program behaviour
502
# Reverse Engineering Describe the Stack, where CPU stores temporary data?
- Last-in-First-Out - Grows from high address to Low address - Top is always the lowest address - Bottom of stack is the oldest item *(i.e first function call)* - Used to manage & organise information for functions (func args, return address & local variables)
503
# Reverse Engineering What does RSP (Stack Pointer) do?
- RSP always points to top of stack - Data added, RSP values decreases - Data Removed, RSP value increases
504
# Reverse Engineering How to push rax instruction equivalent to?
**sub rsp,8** (subs 8 from stack pointer) *beacause 64 bit register holds 8 bytes* **mov [rsp], rax** (move rax into new position ontop of stack) (stores the rax value in the new mem location)
505
# Reverse Engineering What does **push** do?
- Saves a value onto the stack - Pushes the value onto the lowest adrees in the stack
506
# Reverse Engineering What happens when you push mutliple values?
Multiple push instructions decreases stack pointer further
507
# Reverse Engineering What is ***pop eax*** instruction is equivalent to?
**mov rax, [rsp]** Get the value from the top of the stack **add rsp,8** Move stack pointer up
508
# Reverse Engineering What does **pop** do?
- Returns the top of the stack - Then moves the Stack pointer to the next lowest position
509
# Reverse Engineering What happens to the data, when pointer is changed during pop?
- Data does not overwrite memory - Data is not erased (No longer referenced) - Value still exist until a new push, puts new data onto the stcak
510
# Reverse Engineering What are Calling Conventions?
- How data is passed to & from functions - Ensures that both caller & callee agree on how to handle the stack - First 6 integers & pointers arguments should be passed by registers ***Example:*** 1. rdi (1st Arg) 2. rsi (2nd Arg) 3. rdx (3rd Arg) 4. rcx (4th Arg) 5. r8 (5th Arg) 6. r9 (6th Arg) - Extra Args go on Stack - Return val is stored in rax
511
# Reverse Engineering In Assembly what happens in the function call: **long a = myFunc(1,2,3,4,5,6,7,8);**
1) First, args 7 & 8 are pushed on the stack 2) Other args go in registers (rdi,rsi,etc) 3) Call Instruction is used to jump to myFunc 4) returns value stored in rax
512
# Reverse Engineering What happens during a function call?
- Register hold the first 6 args - Extra arguments go on the stack - **RIP** is saved to return after the call
513
# Reverse Engineering What is the Return Address?
- Location the program returns to after finishing a function - **call** instruction saves this address on the stack - **ret** instruction pops it to resume execution **Importance:** - Changing the return address can redirect the program
514
# Reverse Engineering What is a Stack Frame?
- Is the organised setion of the stack where the function's: - Args - return Address - Local Variables Are stored
515
# Reverse Engineering What is the Standard Fun Prologue? ## Footnote A.K.A Start Function
**push rbp, 24;** save old base pointer **move rbp,rsp;** set new base pointer **sub rsp,24;** reverse space for local vars
516
# Reverse Engineering What is the Function Epilogue? ## Footnote A.K.A End of Function
**add rsp,24;** clean up local vars **pop rbp;** restore old base pointer **ret;** return to caller
517
# Reverse Engineering What are the Common techniques for Reverse Engineering?
- Look for human-readable text (*e.g. error message*) - Instruction Manipluataion (*e.g. Swap je & jne*) - Id key tests & check the vals in the register using debugger - Replace the instruction that perform checks with a nop (*e.g. can bypass security attacks*)
518
# Reverse Engineering What are the defenses for Reverse Engineering?
**Dynamically Construct Code:** - *Attacker can run the code * **Encrypt the Binary:** - Program must include the key for it to be executable (Not readable until its ran) **Obfuscation:** - Mix data & code so its harder to read - Can slow down attacks by months/years **Online Activation:** - Force the program to connect to a server - *Completely disabled by an attacker* **Require Online Content** **Require a hardware dongle** **Hardware-based protection:**store & run part of the code in tamper-resistant hardware