Computer Secr
Computer Secr
Introduction to Cybersecurity
Define what is cybersecurity – Cybersecurity is the art and practice of protecting systems,
networks, and data from cyberattacks, damage, and unauthorized access.
Cybersecurity mindset – Involves being vigilant, proactive, and thinking like an attacker to
defend against potential security risks.
CIA Triad:
• Confidentiality – Ensures that data is accessible only to those who have authorized
access (e.g., encryption).
• Integrity – Ensures that the data has not been altered or tampered with (e.g., hashing).
• Availability – Ensures that the data and systems are accessible and functional when
needed by authorized users.
Linux Access Control – Linux provides greater user control than other operating systems. It
allows fine-grained access control to system resources and the kernel, especially for privileged
users (root).
Define what is penetration testing – Penetration testing (or ethical hacking) is a process where
security professionals simulate cyberattacks to identify vulnerabilities within a system or
network.
3. Cryptography
• Symmetric encryption uses the same key for both encryption and decryption.
• Diffusion spreads the plaintext’s statistical structure into the ciphertext, making it harder
to predict.
• Confusion aims to make the relationship between the plaintext and ciphertext as complex
as possible.
Public Key Cryptography – A cryptographic system that uses a pair of keys: a public key (for
encryption) and a private key (for decryption). It enables secure communication without the need
for exchanging secret keys in advance.
Diffie-Hellman Key Exchange – A method for securely exchanging cryptographic keys over a
public channel.
Where:
What is Set-UID? – Set-UID (Set User ID) allows a program to run with the privileges of the
program's owner, often root, regardless of the user running it.
Usage of Set-UID – It’s used to grant temporary elevated privileges for specific tasks. For
example, the sudo command in Unix/Linux systems uses Set-UID to allow users to perform
administrative actions.
Attacking Set-UID – If a program with Set-UID is vulnerable, an attacker can exploit it to gain
elevated privileges (e.g., root access).
5. Environment Variables
Define Environment Variables – These are dynamic values in the operating system that
provide information to running processes. For example, the PATH variable specifies directories
where executable files are located.
How a process gets its environment variables – When a process is created using fork(), the
child process inherits the environment variables of the parent process.
• Static vs. Dynamic Linking: Static linking combines the program and library code into a
single executable, while dynamic linking references shared libraries at runtime.
• Buffer Overflow: This occurs when data overflows a buffer and overwrites adjacent
memory, potentially allowing attackers to execute malicious code.
• Race Condition: Occurs when two processes access shared resources concurrently,
leading to unpredictable outcomes that attackers can exploit.
Exam Guide:
1-Introduction to cybersecurity
a. Define what is penetration testing - a compnay or internal test to act like a hacker
b. Have an overall view on each phase of the penetration testing process - scanning and reconnise
– backgrounf info, vulnerbily dection – using detectors to find what the vulnerabilities are,
explorition – exploit the vulnerablities found in the prevous step, privialge exploit – use the
vulnerbility to gain access to system, post exploit – how can we pivot and attack other servers,
what other info can we get, cover tracks, report
3- Cryptography
a. Define cryptography, encryption, decryption – the art of protecting a message so only a person
with the key can understand, encrytion, using a key to encode a message, decode
b. Why cryptography - protect a message t only the writer and anyone with hte key can
understand it
c. Symmetric encryption, diffusion, confusion – uses the same key to encrypt and decrypt, spread
the plaintext statistics into long range statistics of the ciphertext, This is usually done by intricate
methods of substitution, by replacing one piece of data with another in a disorderly disordered
way
d. Encryption modes (ECB, CBC,...) - Electronic Codebook, cyther code block, cipher feedback
e. Public key cryptography -
a. Diffie-Hellman Key exchange - generating a symmetric key over a public channel
b. RSA Algorithm -
i. Selct a p q , p and q btoh prime and not equal
ii. N = p*q
iii. P(n) = (p-1)(q-1)
iv. Select e, gcd(p(n),e = 1; 1< e< p(n)
v. Calc d – de mod p(n) = 1
vi. Public key KU = {e,n}
vii. Private key KR = {d,n}
viii. Encryption – plaintext M<n , ciphertext C =M^e(mod n
ix. Decryption – plaintext C , ciphertext M = C^d(mod n)
c. Digital Signature - an electronic signature that authenticates digital info, used to confirm
info from signer hasn’t changed
f. Public key infrastructure - PKI – framework for managing digital cerifacate and public key to
enable secure digital communication
g. One-Way Hash functions - mathmatical function to take input of any length and output a hash
which is fixed length and very difficult to decode, used to store passwords, examples bveing sha
– 256, md5, sha –3
4- Set-UID Privileged Programs
a. What is SETUID – linux permission that lets users run programs with same privileges as file’s
owner
b. Usage of SETUID - grant temporary elevated permission to preform specific task, such as sudo
c. Attacking SETUID – if a vulnerable process uses setiud bit to run as root, code will excute in root
privilges, giving the attacker root access
5- Environment Variables
a. Define the environment variables - a set of dynamtically named values, part of operating
envirmount is which the process runs,
b. Ways to create a process - fork(), family of exec()
c. How a process gets its environment variables - fork() child shares the environment varibles
d. Shell variables - When a shell program starts, it copies the environment variables into its own
shell variables. Changes made to the shell variable will not reflect on the environment variables
e. Attack surfaces caused by environment variables - attacker can attack through dynamic libary,
dynamic meaning link during runtime, Static linking results in a binary file that contains both the
program code and the library code, This can be accomplished with the -static flag in C
compiling, Dynamic linking includes a linker in the library that the OS uses to look
up the required library.attack caused by envirmental varibles, external programs,
exec() or system()
f. To fix vulnerabilities used full path to external prgam, and avoid uncertain value in
path
Note: Labs and homework contents are included as well
Here is a practice exam based on the provided information, with solutions at the end.
11. You are tasked with performing a penetration test on a web application. How would you go
about identifying SQL injection vulnerabilities in the system? Write the steps you would
follow.
12. Given the following code snippet, explain how an attacker could exploit it using environment
variables to execute malicious code:
$ cat vulnerable_script.sh
#!/bin/bash
echo "Executing task..."
/usr/local/bin/$TASK
Solutions:
Part 1: Multiple Choice Solutions
1. B. To protect systems, networks, and data from cyberattacks, damage, and unauthorized
access.
Explanation: Cybersecurity is about protecting the overall system, not just focusing on data or specific
components.
Explanation: A threat actor is a person, group, or entity that causes harm by exploiting system
vulnerabilities.
Explanation: This phase involves gathering information about the target system, such as IP addresses,
services, and vulnerabilities.
4. B. Confidentiality
Explanation: Confidentiality ensures that sensitive data is accessible only to those authorized to view it.
Explanation: Set-UID allows a program to execute with the privileges of the program’s owner, often
root, to perform tasks that require elevated permissions.
6. Risk in Cybersecurity
a. Definition: Risk refers to the potential for a threat to exploit a vulnerability and cause
harm. It is a combination of the likelihood of the threat occurring and the impact it
could have.
b. Quantification: Risk is often quantified by assessing the likelihood (probability) of an
attack occurring and the potential impact it would have on the organization or system. A
risk assessment matrix is commonly used.
7. Symmetric Encryption
a. Definition: Symmetric encryption uses the same key for both encryption and decryption
of data.
b. Example: AES (Advanced Encryption Standard) is a commonly used symmetric
encryption algorithm. Both the sender and the receiver need to have the same key for
secure communication.
8. Buffer Overflow
a. Definition: A buffer overflow occurs when a program writes more data to a buffer than
it can hold, leading to the overwriting of adjacent memory.
b. Exploitation: Attackers can exploit a buffer overflow by injecting malicious code into the
overflowed buffer, potentially gaining control of the system.
9. RSA Algorithm
a. Purpose: RSA is a public-key encryption algorithm that secures communication by using
a pair of keys (public and private).
b. Working:
i. Encryption: The sender encrypts the message (M) using the recipient’s public
key (e, n) to create ciphertext (C).
ii. Decryption: The recipient decrypts the ciphertext (C) using their private key (d,
n) to retrieve the original message (M).
iii. RSA is based on the mathematical properties of large prime numbers and
modular arithmetic.
10. Environment Variables
• Definition: Environment variables are dynamic values used by processes to store information
like system paths, configuration settings, and user-specific variables.
• Attack Surface: Attackers can exploit environment variables to manipulate the behavior of
programs, especially if the program relies on paths or dynamic libraries.
• Exploitation: An attacker can modify environment variables to redirect a program to malicious
libraries or alter its behavior.
This practice exam includes a range of questions to help solidify understanding of cybersecurity
fundamentals, penetration testing, cryptography, and system vulnerabilities.