security and networks Flashcards
what do the following linux commands do?
* echo
* mkdir/rmdir
* ls
* pwd
* cat
* cp
* mv
* rm
* touch
- prints in terminal
- creates/ removes dirs
- lists all files/dirs in location
- prints current full path
- displays content of file
- copies current dirs and files
- moves a file/dir to a new location
- removes file/dir
- creates a new file
what do the following linux commands do?
* locate
* find
* grep
* diff
* du
* head
* tar
* top
* history
what are some attacks on hashes?
- Preimage attack: Find a message for a given hash: very hard.
- Collision attack: Find two messages with the same hash.
- Prefix collision attack: A collision attack where the attacker
can pick a prefix for the message.
what is a message authentication code (MAC)?
it is made by using the symmetric/private key on the message to create a code. this code is sent along with the message so that the receiver can create their own mac from their key on the message. If the MACs match, the message is known to not have been tampered with while sending. (with asym it is verified using the public key)
how is a CBC-MAC made? (cypher block chaining mode)
- A random Initialisation vector is made (IV)
- The mesage is split up into blocks
- The IV is XORed with the first block before it is encrypted
- The result is XORed with the second plaintext block and is encrypted
- This process repeats until the last block is encrypted and the blocks are put together again
What is AES encryption and what modes are there?
An encryption method that maps 128 bit blocks onto other 128 blocks in encryption and decryption. Even non-encryptions can be decrypted.
* CBC mode: any change affects all of the rest of the message.
* ECB mode: any change affects only the block.
* CTR mode: any change affects only the bits altered.
What is CCM mode encryption?
Using the usual method for creating a CBC MAC, it uses blockchain encyption but with AES (CTR mdoe) for the encryption method. The encrypted blocks are added to become the encrypted final result but are also used in the blockchain to create the MAC. This is secure because AES-CTR can easily be tampered with so the MAC is necessary to authenticate.
What is an access control matrix (ACM)?
A table of all principles (users, programs etc) against objects (files, directories etc). It defines permissions rwx for everything. In actual fact, is stored in an Access Control List (ACL) each entry is an object
How do items in ACLs work?
- File type: d (directory/ - (link)/ b or c (device file
- rwx or - for owner then group then other
- link counter
- owner
- group
- size
- date
- file name
What are uids?
They are assigned IDs to processes (running instances of programs).
* ruid: real owner of the process
* euid: effective uid represents the permissions the process has when accessing system resources. (can be changed during execution)
* suid: saved uid. when euid is changed, the old one is saved
* fsuid: filesystem uid. usually the same as the euid. represents permissions when accessing files and directories.
What is a salt hash pair?
Storing passwords as (salt, hash) where salt is a random bitstring and the hash is made from the salt and the password together. This means that checking if two passwords are the same is impossible.
What is password injection?
Getting access to the hard disk and adding your own password to the password file to gain access to a computer.
What are the operations used in AES encryption?
SubBytes: sub-box is a 16x16 matrix that defines what every 8 bit combination becomes. all 8 bits of input are swapped to their corresponding 8 bit string.
ShiftRows: rows are shifted left by 0,1,2 and 3 spaces.
MixRows: entries in each column (a,b,c,d) are made into ax^3+bx^2+cx+d and this polynomial is multiplied by another polynomial (3x^3 + x^2 + x + 2). then you modulo the result by (x^4+1) and put back in the column.
AddRoundKey: A string of 128 bit keys are created from the original key and the matrix is xored against the key that corresponds with the round of encryption.
How does AES encryption work?
They message is split up into 128 bit blocks. Each block is arranged into a 4x4 matrix (as if written left to right top to bottom) with 8 bits inside each. Then the 4 operations are performed on it for multiple rounds depending on the encryption type.
How should you pad blocks?
If there is 1 byte of space, write 01, 2 bytes: 0202… 16 bytes 161616…
How does AES with CTR work?
A random public number (nonce) is concatenated with the counter (increments every block). This value is encrypted with the key and then XORed with the block
What is the main flaw with AES with CTR mode?
If you know a pair of encrypted and plaintext messages, you can encrypt a new message (m2) to cyphertext that looks like its been sent legitimately: enc(m1) ⊕ (m1⊕m2)
How does the Diffie-Hellman key exchange work?
- A and B agree on a large prime (p) and a primitive root modulo of p (q) (a number that q^k mod p can make any number below p
- They both choose private keys (a and b) and calculate public keys A=q^a mod p and B=q^b mod p
- They then calculate a number S that only the both of them can calculate S=A^b mod p and S=B^a mod p
What is the weakness of the Diffie-Hellman algorithm and how can it be resolved?
Man in the middle attacks can pretend to be both parties to each other, intercepting both communications to calculate S also. This can be prevented if the public key is authenticated using a trusted third party. RSA can be used to do this.
How do you calculate the public and private keys using RSA?
- generate two distinct primes 𝑝 and 𝑞 for example 𝑝=3 𝑞=11
- Compute 𝑁 = 𝑝𝑞=33 and 𝜙(𝑁) = (𝑝 − 1)(𝑞 − 1)=20
- choose a random integer e that is between 1 and 𝜙(𝑁) and has no common factors with 𝜙(𝑁): 7
- compute d as de = 1 mod 𝜙(𝑁) so d=3 because (37) mod(21) = 1
- PK= (e=7, N=33) SK= (d=3, N=33)
How does encrypting and decrypting a message m (4) work with RSA?
m has to be < N
encrypting using the PK (e=7, N=33): c = m^e mod(N) = 4^7 mod 33 = 16
decrypting using SK (d=3, N=33): m=c^d mod N = 16^3 mod 33 = 4
How does signing work?
Hash message and encrypt with your private key. Send this along with the message so that it can be decrypted with the public key and compared with the has to show its legitimate.